Skip to content

Library cycle graph loader recursion support #3966

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

Merged
merged 2 commits into from
Apr 9, 2025

Conversation

davidmorgan
Copy link
Contributor

@davidmorgan davidmorgan commented Apr 8, 2025

For #3811.

Trying to use this on real builds quickly shows that it does not quite work yet, it needs to support reads triggering builds of earlier phase assets.

So, do that :) ... the main trick being to change the local "next IDs" list into a class-level list by phase, so recursive runs at earlier phases can finish the pending work that they need.

In doing so, simplify a bit: remove _newAssets, use _graphsToComputeAtPhase for phase 0 instead.

And expand test coverage to include recursive loads.

Copy link

github-actions bot commented Apr 8, 2025

PR Health

@davidmorgan davidmorgan force-pushed the parallel-resolve-three branch 2 times, most recently from 8c57097 to b240361 Compare April 9, 2025 08:25
@davidmorgan davidmorgan force-pushed the parallel-resolve-three branch from b240361 to 63461ad Compare April 9, 2025 08:52
@davidmorgan davidmorgan marked this pull request as ready for review April 9, 2025 09:06
@davidmorgan davidmorgan requested a review from jensjoha April 9, 2025 09:07
_buildCycles(assetDepsLoader.phase);
return _cycles[id]!;
} finally {
_runningAtPhases.removeLast();
Copy link

Choose a reason for hiding this comment

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

I assume this is assumed to be the same as the one added above..? Maybe assert that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, thanks, done.

Removed the try/finally since the linter doesn't like me throwing inside a "finally", the code isn't actually designed to work when there are exceptions anyway.

final Map<int, Set<AssetId>> _assetDepsToLoadByPhase = {};
/// The `key` is the phase to load them at or after. A [SplayTreeMap] is used
/// to keep the keys sorted so earlier phases are processed first.
final SplayTreeMap<int, List<AssetId>> _idsToLoad = SplayTreeMap();
Copy link

Choose a reason for hiding this comment

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

Where is the sorted order used? I can't seem to find it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's implicit in _nextIdToLoad, tweaked the comment to mention it.

Copy link

Choose a reason for hiding this comment

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

Yeah, it does _idsToLoad.entries.where((entry) => entry.key <= upToPhase).first; --- though wouldn't that just be a slow way to do _idsToLoad.entries.first then (well, and a check that i is in fact <= upToPhase)?

@davidmorgan davidmorgan merged commit 3494d50 into dart-lang:master Apr 9, 2025
75 checks passed
@davidmorgan davidmorgan deleted the parallel-resolve-three branch April 9, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants