Skip to content

refactor: Discard unnecessary atomic load #780

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 3 commits into from
Apr 17, 2025

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Mar 26, 2025

No description provided.

db,
revision_now,
database_key_index,
memo.revisions.accumulated_inputs.load(),
Copy link
Member Author

Choose a reason for hiding this comment

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

This one specifically, we load the value here just to set it to the same one

Copy link

netlify bot commented Mar 26, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit a45711a
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/6800dce470d7b40008dabedc

Comment on lines 415 to 405
break 'cycle VerifyResult::Unchanged(
InputAccumulatedValues::Empty,
CycleHeads::from(cycle_heads),
);
break 'cycle VerifyResult::Unchanged(inputs, CycleHeads::from(cycle_heads));
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to get a check on this, I believe Empty by default is incorrect here hence the change, but I am not 100% sure

Copy link
Contributor

Choose a reason for hiding this comment

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

CC: @carljm

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, sorry for missing this ping, apparently twice! I think this is change is right. It would probably be ideal to write a test that fails without this fix, though. If this fix is needed, I don't think the test should even require a cycle, as this is also the path for non-cycles. It would probably be a test with accumulated values across multiple revisions, with some inputs changing but some sub-graph (that has accumulated values in it) not changing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I gave this a quick try with building a test but couldn't really figure out one that hits this. I don't really know the accumulation stuff well enough here

Copy link

codspeed-hq bot commented Mar 26, 2025

CodSpeed Performance Report

Merging #780 will improve performances by 4.71%

Comparing Veykril:veykril/push-zxssxpkmuqlr (a45711a) with master (5cd929d)

Summary

⚡ 2 improvements
✅ 10 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
amortized[Input] 3.7 µs 3.5 µs +4.71%
amortized[InternedInput] 3.7 µs 3.5 µs +4.71%

@Veykril Veykril force-pushed the veykril/push-zxssxpkmuqlr branch from a552fd9 to 64b0746 Compare March 28, 2025 07:51
Comment on lines 415 to 405
break 'cycle VerifyResult::Unchanged(
InputAccumulatedValues::Empty,
CycleHeads::from(cycle_heads),
);
break 'cycle VerifyResult::Unchanged(inputs, CycleHeads::from(cycle_heads));
Copy link
Contributor

Choose a reason for hiding this comment

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

CC: @carljm

@Veykril
Copy link
Member Author

Veykril commented Mar 28, 2025

CC: @carljm

Unsure why I can't reply to that but right, forgot to call that change out. It looks like a bug to me but please double check

@Veykril Veykril force-pushed the veykril/push-zxssxpkmuqlr branch from 64b0746 to e046789 Compare April 5, 2025 08:29
@MichaReiser
Copy link
Contributor

Sorry for the ping but @carljm did you see @Veykril comment?

Comment on lines 166 to 185
// We don't access the accumulator anyways
let revisions = AssertUnwindSafe(revisions);
self.with_query_stack(|stack| {
if let Some(top_query) = stack.last_mut() {
top_query.add_read(input, durability, changed_at, accumulated, cycle_heads);
top_query.add_read(input, { revisions }.0, cycle_heads);
}
})
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I prefer the old method signature in that case to avoid this very easy to get outdated comment about accumulators.

Not changing the signature (or only remuving accumulated) also has the benefit that it makes the diff a bit clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not changing it isn't really an option though, as we then are back to eagerly loading the atomic. Unless we pass the atomic field by ref I suppose

Copy link
Member Author

Choose a reason for hiding this comment

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

Went for that and #[inline]'d the function given ti has only one use site

@Veykril Veykril force-pushed the veykril/push-zxssxpkmuqlr branch from e046789 to a45711a Compare April 17, 2025 10:50
@Veykril Veykril added this pull request to the merge queue Apr 17, 2025
Merged via the queue into salsa-rs:master with commit 189e619 Apr 17, 2025
11 checks passed
@Veykril Veykril deleted the veykril/push-zxssxpkmuqlr branch April 17, 2025 11:59
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.

3 participants