-
Notifications
You must be signed in to change notification settings - Fork 155
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
Faster accumulators #615
Faster accumulators #615
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
src/accumulator/accumulated_map.rs
Outdated
@@ -17,6 +22,16 @@ impl AccumulatedMap { | |||
.accumulate(value); | |||
} | |||
|
|||
/// Marks the accumulator result that some nested query has some accumulated values. | |||
pub fn add_dependency_with_accumulated_values(&mut self) { |
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.
I don't like the naming at all but struggled to come up with something better.
CodSpeed Performance ReportMerging #615 will not alter performanceComparing Summary
Benchmarks breakdown
|
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.
approving modulo one nit. I'll let you decide whether to merge or not.
60fdbc8
to
a43468c
Compare
a43468c
to
76079d2
Compare
This PR implements faster accumulators.
Accumulators are relatively costly today because collecting the accumulated values requires iterating over the queries' entire dependency tree.
This cost is negligible with a cold DB but adds up for very deep trees.
For example, adding accumulators to Ruff resulted in a 30% perf regression astral-sh/ruff#14116
This PR adds a new field to
AccumulatedMap
that tracks whether any dependency of the current query has any accumulated values. It checks that field when collecting the accumulated values, allowing it to skip entire subtrees.This approach should make accumulated values nearly "free" in the common cases where there are no or only very few diagnostics.
Test Plan
I added a benchmark and I verified that the perf regression in the linked Ruff PR is mostly gone after using this salsa version.
Running the benchmark locally gives me
where the baseline is main