-
Notifications
You must be signed in to change notification settings - Fork 121
How to handle conditional/optional dependencies? #794
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
Comments
Do you know why this process cannot be resumed? Is it something that could be fixed at the ghc-api level, or would it require fundamental changes to the compiler? |
We would need "Fat interface files" to be implemented: https://mail.haskell.org/pipermail/ghc-devs/2020-October/019324.html |
Why couldn't the api return a |
This doesn't really solve the problem, since the delayed |
So the idea of some kind of dependency with this structure seems plausible and fairly sensible. You depend on a value that is ordered, and if the new value of your dependency is lower than the current value, you don't need to recompute. I quite like it. As for whether ChangedStore can accomplish it, I don't think ChangedStore is particularly relevant. ChangedStore says that the bits stored have changed, but pretend they haven't - its used for when you do modtime OR digest changes, and the modtime changes. You mark the rule as having not changed at all, but update its bits on disk. Not quite what we want here. However, the very closely related ChangedRecomputeDiff/ChangedRecomputeSame might be enough. When we compute a value, given the previous value, if it goes up you'd return Diff, if it goes down, you'd return Same. I think for ghcide, you'd enhance defineEarlyCutoff with a |
In fact that equality is on the encoded bytestring, and we never include a decode from bytestring method, so you might want to do the equality check of the previous encoded bytestring against the currently value - making it |
Yeah, I was planning to encode the value as Abstractly, I guess it would be nice to just require a partial order on values, but since we don't really need that as of now, I think it would be simplest to just stick to a total order on bytestrings. I'm assuming that if some other dependency of |
If the rule returns |
That makes a lot of sense. Good plan.
Yep, if the rule reruns for other reasons, it will all work out.
Yes. The value might be the same, but the dependencies and profiling info are likely to be different, so it stores the new ByteString. |
In addition, we tune the newness check of the redefined NeedsCompilation rule so that the generated linkables are not thrown away unnecessarily, as described in: ndmitchell/shake#794
…hen Evaluating In addition, we tune the newness check of the redefined NeedsCompilation rule so that the generated linkables are not thrown away unnecessarily, as described in: ndmitchell/shake#794
…hen Evaluating In addition, we tune the newness check of the redefined NeedsCompilation rule so that the generated linkables are not thrown away unnecessarily, as described in: ndmitchell/shake#794
…hen Evaluating In addition, we tune the newness check of the redefined NeedsCompilation rule so that the generated linkables are not thrown away unnecessarily, as described in: ndmitchell/shake#794
…hen Evaluating In addition, we tune the newness check of the redefined NeedsCompilation rule so that the generated linkables are not thrown away unnecessarily, as described in: ndmitchell/shake#794
…hen Evaluating In addition, we tune the newness check of the redefined NeedsCompilation rule so that the generated linkables are not thrown away unnecessarily, as described in: ndmitchell/shake#794
* [hls-graph] clean up databaseDirtySet When I ported https://github.com/ndmitchell/shake/pull/802/files to hls-graph, I changed the encoding of the dirty set. Instead, Dirty became a constructor in the Status union. But the databaseDirtySet stayed around accidentally, leading to some confusion. * extract GetEvalComments rule * override NeedsCompilation rule in eval plugin to generate linkables when Evaluating In addition, we tune the newness check of the redefined NeedsCompilation rule so that the generated linkables are not thrown away unnecessarily, as described in: ndmitchell/shake#794 * getLastBuildKeys * Test that the linkables are being produced * honor LSP_TEST_LOG_STDERR * add comments and use custom newness check in ghcide too * fix build * fix 9.0 build
This is in the context of ghcide, but is more of a general query on how to accomplish this sort of thing with shake, so I'm asking here.
A bit of background first -
ModIface
, or we can go all the way and do code-gen, producing aLinkable
.ModIface
to aLinkable
, we need to redo the entire compilation pipeline in order to produce aLinkable
Linkables
for modules that are depended on by something that uses TemplateHaskellNeedsCompilation
which analyses the the reverse dependencies of a module to check if we need to do code-gen. It returnsTrue
if this is the case, orFalse
if we can stop after generating theModIface
.GetModIface
rule generates a pair(ModIface, Maybe Linkable)
, where the invariant is that theLinkable
is guaranteed to be present ifNeedsCompilation
returned true. (NeedsCompilation
is a dependency ofGetModIface
)All this seems to have been working fine. However, the complication is introduced with the eval plugin.
To evaluate an expression in the context of a module, we must have
Linkable
s for it and all of its dependencies.A first approach at supporting this can be:
NeedsCompilation
consult this bit of global state when it makes a decision.Linkables
we require, and we can evaluate the expressionThis looks reasonable at first, but it means we will just throw away all the
Linkable
s we computed for eval on subsequent builds after evaluation, and we will have to rebuild everything, sinceNeedsCompilation
changed fromTrue
toFalse
, and it is a dependency ofGetModIface
.Ideally, as long as all dependencies of
GetModIface
exceptNeedsCompilation
are unchanged, we would not need to recompute theModIface
(The extraLinkable
doesn't really hurt, and it could be used by subsequent evaluations). If some dependency ofGetModIface
other thanNeedsCompilation
did change, then we want to do a rebuild, but without producing aLinkable
.Also, we only want to have this behavior when
NeedsCompilation
flips fromTrue
toFalse
. If it flips fromFalse
toTrue
, then we really do need to rebuild.While going through the shake documentation, I came across the
ChangedStore
constructor ofRunChanged
. Its documentation reads "The stored value has changed, but in a way that should be considered identical (used rarely)." which does seem like it somewhat fits this situation. However, I'm still not sure if this is its purpose, and if using it would work in this scenario.Is something like this possible with the shake model? Is
ChangedStore
the way to accomplish this?/cc @pepeiborra
The text was updated successfully, but these errors were encountered: