Repository navigation
feat: support optimizations at the graph level - #1122
Merged
bhearsum merged 4 commits intoDec 1, 2026
Merged
Conversation
ahal
approved these changes
Dec 1, 2026
ahal
left a comment
Contributor
There was a problem hiding this comment.
Thanks, this looks like a great improvement!
This gets rid of the (IMO) confusing `optimizations` closure, and paves the way evaluating graph-level optimizations. This does mean we will resolve strategies for all tasks all of the time, which is slightly different than now: during early returns in `remove_tasks` and `replace_tasks` we currently avoid this for some tasks. As far as I can tell, this has no notable impact on performance even in a graph of Gecko's size.
This changes the entry point to removals from optimization to `should_remove_tasks`, which allows OptimizationStrategy's to make decisions based on the entire graph, not individual tasks. The default implementation simply calls the existing `should_remove_task`, so this is more or less backwards compatible (at least when it comes to the main interface), and allows OptimizationStrategy implementations to continue operating at the task-level when desired.
Similar to the previous commit, this changes the replacement entry point to `should_replace_tasks` and defaults to calling `should_replace_task` for each task.
Now that we have the ability to do graph-level replacement, we can move the IndexSearch special case out of `optimize_task_graph` and into `IndexSearch` where it belongs. As a bonus, IndexSearch will now work if we ever use it in a composite strategy.
bhearsum
force-pushed
the
refactor-move-indexsearch-look
branch
from
December 1, 2026 14:13
0044b07 to
f18b3d3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The high level of this is introducing
should_replace_tasksandshould_remove_taskstoOptimizationStrategy. These become the new entry points for optimization, and the default implementations fall back to the existing singular implementations to maintain backwards compatibility. I've done my best to minimize the amount of change here,remove_tasksandreplace_tasksneeded some amount of reworking to allow things to operate at the graph level.As far as I know, this is completely backwards compatible, and no there are no differences in generated taskgraphs as a result of it. I tested with various Gecko graphs to confirm this.
This is best looked at commit-by-commit due to the necessary refactor in the first commit. The last commit could move to its own PR, but it seemed fairly reasonable to include here seeing as it's a refactor enabled by this work.
This work was motivated by https://bugzilla.mozilla.org/show_bug.cgi?id=1927227.