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
CA derivations that depend on other CA derivations #3958
Conversation
Co-authored-by: Théophane Hufschmitt <regnat@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bad news is input-addressed derivations still cannot depend on CA derivations, that will wait for later.
What's preventing this except the need to recompute the output paths?
} | ||
} | ||
/* can't just use else-if instead of `!haveCached` because we need to unlock | ||
`drvPathResolutions` before it is locked in `Derivation::resolve`. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a silly question, but what is preventing us from reusing resolutions
rather than re-locking drvPathResolutions
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function and queryPartialDerivationOutputMap
are mutually recursive, so it would deadlock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there should be internal variants that take a reference to the locked drvPathResolutions
? Then you only need to lock it once.
Thanks for catching, @regnat.
… into ca-floating-upstream
Nothing major. I'd need to change the types and drv file format at least somewhat to accommodate the lack of a known output path, and I just didn't want to get into that yet until this was all good. |
…loating-upstream Tests also now fail as they should
We will sometimes try to query the outputs of derivations we can't resolve. That's fine; it just means we don't know what those outputs are yet.
If we resolve using the known path of a derivation whose output we didn't have, we previously blew up. Now we just fail gracefully, returning the map of all outputs unknown.
so we can link outputs to deriver and thus properly cache.
OK, I think this is ready. Everything should work except for remote building, which will require changes to the build hook protocol to fix. I think that's best dealt with in another PR. The CI failure is that spurious impure fixed output derviation one that keeps on cropping up from time to time, ugh. |
I tried bootsraping firefox with this branch (as I had done for #3883), but I ran into a lot of (apparently random) failures. The errors are
|
It's still building the world, but nothing crashed so far on master, so it's likely to be specific to this branch |
@regnat huh, weird. Are those happening when building input-addressed derivations too? |
I tried again tonight and this morning, and I actually hit twice the same kind of error on master.
It seems to be less frequent than what I had yesterday, but might just be an accident − I'm using a shared machine for that, maybe it had a higher load yesterday or something like that which caused it to trigger this more often. |
@regnat Just looking at the code, I had no idea what could go wrong/differently in the non-floating-CA case, so I'm relieved you could reproduce without this branch! Anything else need changing here then? With the latest pushes I have Nix writing down resolved trees for sake of caching (resolving means no super-linear storage overhead, and no new network overhead, thankfully) but we can always revisit these things later. I think we're ready! |
#4056 (comment) I take it this means we agree this is ready. |
@@ -644,4 +644,57 @@ std::string downstreamPlaceholder(const Store & store, const StorePath & drvPath | |||
return "/" + hashString(htSHA256, clearText).to_string(Base32, false); | |||
} | |||
|
|||
|
|||
// N.B. Outputs are left unchanged | |||
static void rewriteDerivation(Store & store, BasicDerivation & drv, const StringMap & rewrites) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static void rewriteDerivation(Store & store, BasicDerivation & drv, const StringMap & rewrites) { | |
static void rewriteDerivation(Store & store, BasicDerivation & drv, const StringMap & rewrites) | |
{ |
Style nitpick.
assert(attempt); | ||
Derivation drvResolved { *std::move(attempt) }; | ||
|
||
auto pathResolved = writeDerivation(worker.store, drvResolved); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note we are writing down the resolved derivation so we can link the deriver to the CA output in the sqlite db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need that? It doubles the number of .drv files on disk, while we'd like to get rid of them eventually...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it only doubles them for floating CA derivations. Not doing this means changing the SQL schema, and I think there's a few such change's will end up wanting to make, so I rather save that for later to think about them all at once.
@@ -1906,6 +1941,9 @@ void DerivationGoal::buildDone() | |||
done(BuildResult::Built); | |||
} | |||
|
|||
void DerivationGoal::resolvedFinished() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seems a bit unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well many derivation goals could resolve to the same derivation, Trying to make the resolve derivations track all those to call done
on seems wrong to me.
This is tested and works, but some things should be cleaned wrt the new TODOs.
Feature-wise, the good news is that we no longer rebuild resolution-equivalent drvs for CA derivations. We resolve the derivation if it isn't already resolved, and then build that instead.
The bad news is input-addressed derivations still cannot depend on CA derivations, that will wait for later.
Finally, thanks to @regnat, as I stole a few things of stuff from #3776 :).