profiler: Don't store the unnecessary length field for Sample Observations#219
Merged
Conversation
danielsn
force-pushed
the
dsn/observation-inside-map
branch
from
August 18, 2023 14:28
a7287a9 to
94919c5
Compare
danielsn
force-pushed
the
dsn/observation-inside-map
branch
from
August 18, 2023 18:43
2f6bd1b to
996c18e
Compare
danielsn
marked this pull request as ready for review
August 18, 2023 18:43
danielsn
force-pushed
the
dsn/observation-inside-map
branch
from
August 21, 2023 19:46
8dfab97 to
6703b47
Compare
morrisonlevi
previously approved these changes
Aug 21, 2023
Odd that locally my clippy did not whine
morrisonlevi
force-pushed
the
dsn/observation-inside-map
branch
from
August 21, 2023 23:23
9d52cd1 to
6fa9625
Compare
morrisonlevi
approved these changes
Aug 21, 2023
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.
What does this PR do?
Replaces the 24 byte
Vec<i64>used by each sample with an 8 byte pointer.Motivation
Each sample has a vec of observations, which has both a capacity and a length member, both of which are 8 bytes. This is wasteful, because all observations for a Profile are of the same length. Instead, we only actually need a single pointer, and can store the length off to the side.
Additional Notes
unsafecode and could use an extra careful review.Map. All we do is put stuff into the map, and then iterate over it later. This means that each map carries its ownObservationLengthalong with it, allowing multiple profiles to coexist happily.How to test the change?
I added a bunch of tests. You can check them for functional correctness using
You can also check them for memory leaks and UB using miri:
Note that doing so may require you to
cargo updatefirst to avoid issues with an old version ofproc_macrosinteracting badly withmiri