Support allocative with features = ["allocative"]#340
Open
cormacrelf wants to merge 1 commit intoRoaringBitmap:mainfrom
Open
Support allocative with features = ["allocative"]#340cormacrelf wants to merge 1 commit intoRoaringBitmap:mainfrom
features = ["allocative"]#340cormacrelf wants to merge 1 commit intoRoaringBitmap:mainfrom
Conversation
Allocative is a trait that lets you trace allocations. This gives you insight similar to `RoaringBitmap::statistics()`, but built-in to larger allocative traces of arbitrary data structures.
Kerollmops
requested changes
Jan 12, 2026
Member
Kerollmops
left a comment
There was a problem hiding this comment.
Hey @cormacrelf 👋
Thank you very much for the addition. Looks actually really cool. Could you talk about these flamegraphs, how to use them in the README, and rebase this branch on main, please?
Have a nide day 🌵
Dr-Emann
reviewed
Jan 13, 2026
Comment on lines
+10
to
+50
| #[test] | ||
| fn flamegraph_bitmap() { | ||
| let mut foo1 = RoaringBitmap::new(); | ||
| foo1.insert_range(0..1_000_000); | ||
| foo1.insert(2_000_000); | ||
| foo1.insert(9_000_000); | ||
|
|
||
| let mut flamegraph = FlameGraphBuilder::default(); | ||
| flamegraph.visit_root(&foo1); | ||
| let flamegraph_src = flamegraph.finish().flamegraph().write(); | ||
| let mut f = File::create("../target/bitmap.folded").unwrap(); | ||
| write!(f, "{}", flamegraph_src).unwrap(); | ||
|
|
||
| /* | ||
| cargo test -p roaring --features allocative --test allocative | ||
| inferno-flamegraph target/bitmap.folded > target/bitmap.flamegraph.svg | ||
| open target/bitmap.flamegraph.svg | ||
| */ | ||
| } | ||
|
|
||
| #[test] | ||
| fn flamegraph_treemap() { | ||
| let mut foo1 = RoaringTreemap::new(); | ||
| foo1.insert_range(0..1_000_000); | ||
| foo1.insert(2_000_000); | ||
| foo1.insert(9_000_000); | ||
| foo1.insert((1 << 32) + 9000); | ||
| foo1.insert((2 << 32) + 9000); | ||
|
|
||
| let mut flamegraph = FlameGraphBuilder::default(); | ||
| flamegraph.visit_root(&foo1); | ||
| let flamegraph_src = flamegraph.finish().flamegraph().write(); | ||
| let mut f = File::create("../target/treemap.folded").unwrap(); | ||
| write!(f, "{}", flamegraph_src).unwrap(); | ||
|
|
||
| /* | ||
| cargo test -p roaring --features allocative --test allocative | ||
| inferno-flamegraph target/treemap.folded > target/treemap.flamegraph.svg | ||
| open target/treemap.flamegraph.svg | ||
| */ | ||
| } |
Member
There was a problem hiding this comment.
I think these would be better as examples than tests
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.
Allocative is a trait (see https://docs.rs/allocative) that lets you profile allocations. This gives you insight similar to
RoaringBitmap::statistics(), but built-in to larger allocative traces of arbitrary data structures.This just derives allocative on all the container types and anything within them, doesn't need anything fancy.
This is what you get: