-
Notifications
You must be signed in to change notification settings - Fork 8
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
Draft: use Arc<str> and lasso for string interning #766
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #766 +/- ##
==========================================
+ Coverage 53.55% 53.81% +0.26%
==========================================
Files 258 240 -18
Lines 20466 19116 -1350
==========================================
- Hits 10960 10288 -672
+ Misses 9506 8828 -678 ☔ View full report in Codecov by Sentry. |
Here's what I'm seeing before and after using dhat solving the same requests.
The size difference is not massive here but the number of blocks went down a lot. As for run speed differences, using an optimized build without any profiling enabled, so far I'm seeing roughly the same run times for either build. Lasso can perform a lot better if you can know you no longer need to intern any more strings, but we don't have a way to do that in the solver. |
Interesting - it's too bad that the performance doesn't get affected too much but the reduction in memory usage still seems pretty worth while |
From the meeting today:
|
First in a series of commits to make this kind of change for values that are part of `State` and will benefit greatly from faster cloning and lower memory footprint. Cloning an Arc is an O(1) operation and the solver has to make many clones of State as it progresses. There is currently a lot of `.to_string()` used on these values but this is expected to change into Arc::clone as other things get similarly converted. Signed-off-by: J Robert Ray <[email protected]>
Use the lasso crate to intern package name strings, so that any instances of the same name share the same backing memory. These are also very cheap to clone because it only clones the "Spur" (a u32). The tradeoff is that there is some contention from using `ThreadedRodeo` since we need to support accessing the backing store from multiple threads. Signed-off-by: J Robert Ray <[email protected]>
leaving this here for posterity: ratatui/ratatui#601 |
Here is some exploration of making the members of
State
take up less memory and/or faster to clone. It uses theArc<str>
technique for the values inOptionMap
, since these values are deemed to have somewhat high cardinality, and uses lasso to do string interning for PkgNameBuf and friends, since these values should have relatively low cardinality.Benchmarking and memory profiling are on my todo list, to see if this is worthwhile.