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

Shrink QueryRevisions size by 3 words #636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Dec 22, 2024

No description provided.

Copy link

netlify bot commented Dec 22, 2024

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit eb4340b
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/677908db64d68900088bc233

Copy link

codspeed-hq bot commented Dec 22, 2024

CodSpeed Performance Report

Merging #636 will not alter performance

Comparing Veykril:veykril/push-accumulated (eb4340b) with master (32bd57c)

Summary

✅ 9 untouched benchmarks

@Veykril
Copy link
Member Author

Veykril commented Dec 22, 2024

I wonder if #629 would help here a bit by reducing the need to allocate additionally (or whether the cause of the perf regression is the extra indirection)

@MichaReiser
Copy link
Contributor

I haven't reviewed the code changes but any chance you undid the optimization introduced in #615

@Veykril
Copy link
Member Author

Veykril commented Dec 22, 2024

Ah I believe I did by accident!

@Veykril Veykril force-pushed the veykril/push-accumulated branch 2 times, most recently from d0b5fd4 to 96d7780 Compare December 22, 2024 18:31
@Veykril Veykril force-pushed the veykril/push-accumulated branch from 96d7780 to 009c91f Compare December 31, 2024 10:43
@Veykril Veykril marked this pull request as ready for review December 31, 2024 10:43
Comment on lines -77 to +80
) -> Option<&'db AccumulatedMap>;
) -> (Option<&'db AccumulatedMap>, InputAccumulatedValues) {
_ = (db, key_index);
(None, InputAccumulatedValues::Any)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

One thing to note is that I have this trait method a default impl to reduce some code noise. I imagine the intent was to force the implementor to think about this function but it does make changing signatures really annoying as well.

@Veykril Veykril force-pushed the veykril/push-accumulated branch from 009c91f to 0537864 Compare December 31, 2024 10:46
src/active_query.rs Outdated Show resolved Hide resolved
@Veykril Veykril force-pushed the veykril/push-accumulated branch from 0537864 to dfec276 Compare December 31, 2024 11:41
@@ -7,10 +9,6 @@ use super::{accumulated::Accumulated, Accumulator, AnyAccumulated};
#[derive(Default, Debug)]
pub struct AccumulatedMap {
map: FxHashMap<IngredientIndex, Box<dyn AnyAccumulated>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess a more local change would be to change map here to Option<Box<FxHashMap>>. It would have the advantage that all accumualted fields remain closer together.

Copy link
Member Author

Choose a reason for hiding this comment

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

Generally not a bad idea but I think (will have to verify but I am fairly certain) that moving InputAccumulatedValues back into AccumulatedMap will increase the size of QueryRevisions as the field can't be batched together with other fields that are smaller than the alignment.

@davidbarsky
Copy link
Contributor

This was a pretty substantial improvement to rust-analyzer's memory benchmark (analysis-stats) when I rebased this change atop of my forked branch of Salsa: we went from 4053mb to 3968mb.

@Veykril
Copy link
Member Author

Veykril commented Jan 4, 2025

We could save another 24 bytes by option boxing QueryRevisions::tracked_struct_ids field, assuming a decent number of queries do not need it on average.

@Veykril
Copy link
Member Author

Veykril commented Jan 4, 2025

And another 8 bytes by having access to a ThinBox (I don't know if there is a stable way to createa ThinBox<[T]> type today)

@Veykril Veykril force-pushed the veykril/push-accumulated branch from dfec276 to 4abb000 Compare January 4, 2025 09:24
@Veykril Veykril force-pushed the veykril/push-accumulated branch from 4abb000 to eb4340b Compare January 4, 2025 10:09
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