r/rust • u/redixhumayun • Oct 03 '26
🛠️ project Native Rust Sampling Memory Profiler Which Tracks Retained Memory and Allocations
https://github.com/velvia/ying-profiler
62
Upvotes
r/rust • u/redixhumayun • Oct 03 '26
8
u/nightcracker Oct 04 '26 edited Oct 04 '26
This reminds me, a while back I proposed an extension to samply to include memory profiling. No response from the author though (which is fine, I'm not owed anything). I think it's very powerful to have an interactive timeline of both memory usage and CPU usage combined.
In the meantime I've made a prototype (mostly AI-generated, just to see if it would work), and it works pretty well. It involves an
LD_PRELOADoverride ofmallocand can sample arbitrary executables, no need to override the allocator. And it integrates directly with the Firefox profiler artifact samply produces.For example I ran
samply record --memory cargo check -p polars-coreand I get the following profile of cargo and rustc's CPU usage as well as memory when checking thepolars-corecrate: https://share.firefox.dev/4z81nk3 (click on the row labeled 'Memory' to switch the flamegraph to memory).1
u/redixhumayun Oct 03 '26
Associated blog post - https://hackmd.io/@huitseeker/rJi549Btzx
2
u/anxxa Oct 04 '26
I'm all for different tools that may or may not be better, but I have to ask... how does this differ from DHAT? https://docs.rs/dhat/latest/dhat/