-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better calculation of SourceMap/buildplans (improves cache as well) #3922
Comments
One approach to solving this would be strategic: implement logic in the SourceMap phase to deal with build tools, the same way we do in ConstructPlan. This kind of strategic change will be like playing whack-a-mole again. The code will continue to get harder to follow, and it will be easier to introduce regressions. Integration tests will help, but it would be better to solve this more holistically. Instead, I want to lay out a plan for a fairly significant refactoring, which I believe will make the code easier to maintain, fix a few bugs (including some we haven't experienced yet), and improve caching. Some relevant related issues:
I'm guessing there are others too. I may edit this comment to add them to this list. I'm going to add two more comments now, one describing the status quo today, and one describing some ideas to a new, better system. |
At a bird's eye view, this is how build plans are constructed today in Stack:
|
I'd like to take a step back from all of this and use the new ideas in the "better cache" approach to try a new stab at this. Let's start it all off from the source map phase. Instead of separating snapshot vs local packages, we should consider immutable vs mutable. See #3860 for more information, but basically: if it comes from the local file system, or depends on something on the local filesystem, the package is mutable. Otherwise, it's immutable. In order to proper calculate this mutable vs immutable idea, we'll need to move the build tool discovery to the source map phase, away from the construct plan phase. It may end up being logical to move version bounds checking to this phase too, away from the construct plan phase. Here's a new invariant: whenever we install an immutable package, we install it into a location like Also, a new piece of information (which @mgsloan has been pushing for a while): we bypass having a separate snapshot database, and only have a global database (by necessity of GHC) and a local database. When we load up the installed map, we will do a package pruning as before. For immutable packages in the source map, we'll be able to ensure that the directory the library is installed into matches the expectation we have. And since this includes the hash mentioned above, we're ensuring that it's exactly the same package. (A different approach would be adding this information the GHC package database registration file, but I think that would require deeper changes to Cabal.) For mutable packages, the need to prune would be determined differently: based on whether the source files it depends on have changed on the filesystem. Plan construction would then go basically the same as it had before. However, if as I mentioned above we move some logic to the source map phase, that would mean things like build tools and bounds checking are not done in the construct plan phase. I think this would make both @nh2 and @ezyang happy from previous comments. Finally: when actually building a package, we'll have some slightly new rules in place, in line with #3860. When building an immutable package, we'll do something like:
Alright, brain dump over :) |
That all sounds good to me 👍 . Definitely in favor of improving this part of stack. What is the purpose of including |
I'm not certain that the GHC version needs to be in the path, good catch.
…On Mon, Mar 19, 2018, 9:52 PM Michael Sloan ***@***.***> wrote:
That all sounds good to me 👍 . Definitely in favor of improving this
part of stack.
What is the purpose of including ghc-X.Y.Z in the immutable package path?
Couldn't think be included in the hash? One reason I can imagine for
including it is so that you can easily blow away all the caches for a
particular compiler. I believe that these broken package registrations
would be noticed and removed.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3922 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADBBwOm6h1YGw6RseE_wS-DmgcjnYojks5tgAyNgaJpZM4SqZCd>
.
|
This is nowhere near ready, it just paints a basic idea of a direction to start in. This is based on a whiteboard drawing I did, which may or may not be helpful. https://imgur.com/a/1jv3WLp
This is nowhere near ready, it just paints a basic idea of a direction to start in. This is based on a whiteboard drawing I did, which may or may not be helpful. https://imgur.com/a/1jv3WLp
Using local version of
|
Repro: create a directory with the following two files:
NOTE: If someone knows of a package in a Stackage snapshot that uses either happy or alex, and compiles quicker than
haskell-src-exts
, please let me know, we can make this repro easier to trigger.Next: observe the following session:
Expected: the
--dry-run
call should report a no-op, since all of the packages have already been built.Actual: it insists on rebuilding
haskell-src-exts
. The reason is clear when you look at the following--verbose
bit of output:Stack believes that
haskell-src-exts
should appear in the snapshot database, since all of its dependencies are in the snapshot unchanged. However, this is a lie: one of its dependencies is actuallyhappy
as a build tool. ButSourceMap
construction does not consider build tools, and therefore theSourceMap
andConstructPlan
steps are out of sync!I think the most straightforward resolution is to move all of the build tool calculation to the
SourceMap
level.The text was updated successfully, but these errors were encountered: