Repository navigation
Elide clone in V::follow_cell_path for record - #12325
Merged
sholderbach merged 1 commit intoMar 30, 2024
Merged
Conversation
This clone is not necessary and tanks the performance of deep nested access. As soon as we found the value we now we discard the old value so can `std::mem::take` the inner (`impl Default for Value` to the rescue) We may be able to further optimize this but not having to clone the value is vital.
sholderbach
added a commit
to sholderbach/nushell
that referenced
this pull request
Mar 28, 2024
This shrinks `Record`'s size in half and should make it again amenable to be part of `Value` directly. Might have slightly different performance characteristics as the cache locality changes on lookups (if you directly need the value, it should be closer, but in other cases may blow up the cache line budget) Also different perf characteristics on creation expected. `from_raw_cols_vals` now probably worse. Comparison with the main branch (boxed Record) revealed no significant change to the creation but an improvement when accessing larger N. The fact that this was more pronounced for nested (still cloning before nushell#12325) leads to the conclusion that this may still be dominated by the smaller clone necessary for a 24-byte `Record` over the previous 48 bytes.
Contributor
|
Awesome! This is a simple way to get better performance out of the record cell path lookup for sure |
sholderbach
added a commit
that referenced
this pull request
Mar 30, 2024
# Description This shrinks `Record`'s size in half and and allows you to include it in `Value` without growing the size. Changing the `Record` internals may have slightly different performance characteristics as the cache locality changes on lookups (if you directly need the value, it should be closer, but in other cases may blow up the cache line budget) Also different perf characteristics on creation expected. `Record::from_raw_cols_vals` now probably worse. ## Benchmarking Comparison with the main branch (boxed Record) revealed no significant change to the creation but an improvement when accessing larger N. The fact that this was more pronounced for nested access (still cloning before #12325) leads to the conclusion that this may still be dominated by the smaller clone necessary for a 24-byte `Record` over the previous 48 bytes. # User-Facing Changes Reduced memory usage
2 tasks
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.
Description
This clone is not necessary and tanks the performance of deep nested access.
As soon as we found the value we now we discard the old value so can
std::mem::takethe inner (impl Default for Valueto the rescue)We may be able to further optimize this but not having to clone the value is vital.
Benchmarking
I basically took @devyn 's benchmark script from #12305 and ran it with default setting (no change to the time, potential thermal rampup/slowdown)
devynbench.nuResults
highlight
nest_accessfirst line
mainsecond line
i-follow-records-deep-nest-babyFull output
User-Facing Changes
MOAR speed