Skip to content
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

[PL-133119] Topological sort before rewriting aggregate jobs #1

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Nov 14, 2024

Given the leaf jobs packages.foo & packages.bar, an aggregate job aggregate0 with

_hydraGlobConstituents = true;
constituents = [ "packages.*" ];

and an aggregate job aggregate1 with

constituents = [ "aggregate0" ];

then it may happen depending on the order of evaluation that aggregate1 depends on the old derivation of aggregate0 (i.e. the one without rewritten constituents) and doesn't depend on packages.foo and packages.bar because it was rewritten before aggregate0 was rewritten.

Using a toposort (derived from the one in CppNix's libutil) to solve that. Cycles are a hard error, then all aggregates are failed to make sure we don't finish one of those too early.

This also extracts the code into a few helper functions and a slightly better data structure, otherwise this would've gotten too chaotic.

Given the leaf jobs `packages.foo` & `packages.bar`, an aggregate job
`aggregate0` with

    _hydraGlobConstituents = true;
    constituents = [ "packages.*" ];

and an aggregate job `aggregate1` with

    constituents = [ "aggregate0" ];

then it may happen depending on the order of evaluation that `aggregate1`
depends on the old derivation of `aggregate0` (i.e. the one without
rewritten constituents) and doesn't depend on `packages.foo` and
`packages.bar` because it was rewritten before `aggregate0` was
rewritten.

Using a toposort (derived from the one in CppNix's libutil) to solve
that. Cycles are a hard error, then _all_ aggregates are failed to make
sure we don't finish one of those too early.

This also extracts the code into a few helper functions and a slightly
better data structure, otherwise this would've gotten too chaotic.
Copy link
Member

@ctheune ctheune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The involved C++ is a bit much for me to quickly grasp. It looks reasonable overall and the risk here is low, so I'm happy to just move this forward.

If you'd like a more detailed review, we can go through the code together next week.

@ctheune ctheune merged commit 9b6f973 into hydra.flyingcircus.io Nov 14, 2024
2 checks passed
Copy link
Member

@ctheune ctheune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, the one little adjustment would be nice.

for (auto job = jobs.begin(); job != jobs.end(); job++) {
// If all jobs are selected by an aggregate job, select all
// jobs except itself.
if (childJobName == "*" && job.key() == jobName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop the "*" comparison and just always filter out the parent job.

@Ma27 Ma27 deleted the wip-fc branch November 28, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants