Cache exposed package modules in Pantry DB#4628
Conversation
|
|
||
| loadExposedModulePackages | ||
| :: (HasPantryConfig env, HasLogFunc env) | ||
| => SnapshotCacheHash |
There was a problem hiding this comment.
A guess would be that it would be more efficient to use SnapshotCacheId here to avoid serializing a ByteString each time.
| getPackagesFromModuleNames mns = do | ||
| hash <- hashSnapshot | ||
| withSnapshotCache hash mapSnapshotPackageModules $ \getModulePackages -> do | ||
| mutableMapping <- mapMutablePackageModules |
There was a problem hiding this comment.
The script command does not allow for any mutable packages, so if desired for simplicity, I think you could simply add an assertion that there are no mutable packages.
There was a problem hiding this comment.
I didn't know about that, is it documented somewhere?
There was a problem hiding this comment.
I don't think so, it's an implication of the requirement that there's no local config for stack script, and when I wrote that documentation, we didn't have the mutable/immutable breakdown yet.
| compilerInfo <- getCompilerInfo wc | ||
| let maybePliHash dep | PLImmutable pli <- dpLocation dep = | ||
| Just $ immutableLocShaBs pli | ||
| | otherwise = Nothing |
There was a problem hiding this comment.
Similarly this could be an error "No mutable packages are allowed in the `script` command
|
|
||
| allExposedModules :: PD.GenericPackageDescription -> RIO EnvConfig [ModuleName] | ||
| allExposedModules gpd = do | ||
| -- FIXME add os, arch conditionals |
There was a problem hiding this comment.
Can you clarify this FIXME? It looks like you've already implemented these conditionals correctly.
| haddocks = if cpHaddocks dpCommon then "haddocks" else "" | ||
| hash = treeKeyToBs $ locationTreeKey pli | ||
| hash = immutableLocShaBs pli | ||
| return $ B.concat ([hash, haddocks] ++ flags ++ ghcOptions) |
There was a problem hiding this comment.
Possible optimization: instead of using ByteStrings here, use Builders, which will more efficiently concatenate together. May not be worth the overhead of changing things.
|
@snoyberg I think I've addressed all the points you raised |
Note: Documentation fixes for https://docs.haskellstack.org/en/stable/ should target the "stable" branch, not master.
Please include the following checklist in your PR:
Fixes #4536
Fixes #4624
I've switched to a script with some imports actually (otherwise there's an easy way to cheat by not getting any packages at all) :
And on my local machine I get the following results:
Thus we get only noticeable slowdown only when there's no module cache and otherwise
stack scriptin this PR is only marginally slower than with the stable Stack. And with #4550 resolved we could get closer to the stable version or even get faster than it.