-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Get rid of addWantedOutputs
#13240
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
base: master
Are you sure you want to change the base?
Get rid of addWantedOutputs
#13240
Conversation
15d4fb0
to
3969fcb
Compare
DerivationCreationAndRealisationGoal
, get rid of addWantedOutputs
addWantedOutputs
3969fcb
to
8a9bde3
Compare
🎉 All dependencies have been resolved ! |
8a9bde3
to
a60ad96
Compare
src/libstore/build/worker.cc
Outdated
static bool removeGoal(std::shared_ptr<G> goal, std::weak_ptr<G> & gp) | ||
{ | ||
/* !!! inefficient */ | ||
cullMap(goalMap, [&](const std::weak_ptr<G> & gp) -> bool { | ||
return gp.lock() != goal; | ||
}); | ||
return gp.lock() != goal; |
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.
It's a bit strange that removeGoal
does't actually remove anything now. Maybe something like shouldRemoveGoal
is more fitting?
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.
Actually it has to have the same as the others for overloading/recursion reasons.
src/libstore/include/nix/store/build/derivation-creation-and-realisation-goal.hh
Outdated
Show resolved
Hide resolved
a8965c5
to
2ff8cbc
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2025-05-28-nix-team-meeting-minutes-229/65205/1 |
2ff8cbc
to
30ccdd8
Compare
🎉 All dependencies have been resolved ! |
try { | ||
drvPath = resolveDerivedPath(worker.store, *drvReq); | ||
} catch (MissingRealisation &) { | ||
return std::nullopt; | ||
} |
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.
Not a big fan of using exceptions as control flow like this. But this is just moving code around, so not a big deal.
30ccdd8
to
cdcbf52
Compare
cdcbf52
to
ce93ef2
Compare
This is a minor oversight from 012453d.
This is just a code cleanup; it should not be behavior change. `addWantedOutputs` is removed by introducing `DerivationTrampolineGoal`. `DerivationGoal` now only tracks a single output, and is back to tracking a plain store path `drvPath`, not a deriving path one. Its `addWantedOutputs` method is gone. These changes will allow subsequent PRs to simplify it greatly. Because the purpose of each goal is back to being immutable, we can also once again make `Goal::buildResult` a public field, and get rid of the `getBuildResult` method. This simplifies things also. `DerivationTrampolineGoal` is, as the nane is supposed to indicate, a cheap "trampoline" goal. It takes immutable sets of wanted outputs, and just kicks of `DerivationGoal`s for them. Since now "actual work" is done in these goals, it is not wasteful to have separate ones for separate sets of outputs, even if those outputs (and the derivations they are from) overlap. This design is described in more detail in the doc comments on the goal types, which I've now greatly expanded. --- This separation of concerns will make it possible for future work on issues like NixOS#11928, and to continue the path of having more goal types, but each goal type does fewer things (issue NixOS#12628). --- This commit in some sense reverts f4f28cd, but that one kept around `addWantedOutputs`. I am quite sure it was having two layers of goals with `addWantedOutputs` that caused the issues --- restarting logic like `addWantedOutputs` has is very tempermental! In this version of the change, we have *zero* layers of `addWantedOutputs` --- no goal type needs it, or otherwise has a mutable objective --- and so I think this change is safe. Co-authored-by: Sergei Zimmerman <145775305+xokdvium@users.noreply.github.com>
ce93ef2
to
a55806a
Compare
OK got your last two things, @xokdvium |
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.
High-level design SGTM, but I'm not very familiar with the code yet. This does seem like a good division of responsibilities and is better in terms of SRP.
Left one non-blocking question.
auto & g = *concreteDrvGoals.begin(); | ||
buildResult = g->buildResult; | ||
for (auto & g2 : concreteDrvGoals) { | ||
for (auto && [x, y] : g2->buildResult.builtOutputs) | ||
buildResult.builtOutputs.insert_or_assign(x, y); | ||
} | ||
|
||
co_return amDone(g->exitCode, g->ex); |
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.
Non-blocking question: what is the semantics of buildResult
now? Is the exitCode
and ex
the same for all concrete goals and only the builtOutputs
are now different? I think you've had some low-hanging ideas for a follow-up simplication wrt to this.
Motivation
Do this by introducing
DerivationTrampolineGoal
.DerivationGoal
now only tracks a single output, and is back to tracking a plain store pathdrvPath
, not a deriving path one. ItsaddWantedOutputs
method is gone. These changes will allow subsequent PRs to simplify it greatly.Because the purpose of each goal is back to being immutable, we can also once again make
Goal::buildResult
a public field, and get rid of thegetBuildResult
method. This simplifies things also.DerivationTrampolineGoal
is, as the nane is supposed to indicate, a cheap "trampoline" goal. It takes immutable sets of wanted outputs, and just kicks ofDerivationGoal
s for them. Since now "actual work" is done in these goals, it is not wasteful to have separate ones for separate sets of outputs, even if those outputs (and the derivations they are from) overlap.This design is described in more detail in the doc comments on the goal types, which I've now greatly expanded.
Context
This separation of concerns will make it possible for future work on issues like #11928, and to continue the path of having more goal types, but each goal type does fewer things (issue #12628).
This commit in some sense reverts f4f28cd, but that one kept around
addWantedOutputs
. I am quite sure it was having two layers of goals withaddWantedOutputs
that caused the issues --- restarting logic likeaddWantedOutputs
has is very tempermental! In this version of the change, we have zero layers ofaddWantedOutputs
--- no goal type needs it, or otherwise has a mutable objective --- and so I think this change is safe.depends on #13186depends on #13294Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.