Extend #[bench] with memory usage
It would be nice to be able to see memory usage (and memory leak) in #[bench] tests to detect regressions. I guess jemalloc can do that with something like je_malloc_stats_print.
cc #14119 cc #14875 cc #19776
I was a bit surprised that this isn't already done – especially in light of the fact that rust programs in publicized benchmarks appear to indulge in a bit more memory than corresponding C programs.
Looking at memory consumption is also usually the first thing I do when trying to optimize code, and if the runtime is similar, I will take the solution which uses less memory. Reducing memory usage can lead to performance benefits elsewhere because of cache effects.
By the way, jemalloc has the
malloctlfunction which allows to directly gather information of interest.je_malloc_stats_printis meant to be readable to a human, and there is no guarantee on what format it will print.Also hijacking this issue a bit, would it be feasible to include
perfcounters in the benchmarking harness? Those may also show performance issues (e.g. cache misses, branch prediction misses, etc.) that the plain runtime cannot.llogiq at 2015-06-16 08:29:45
Memory would be nice. Then we can have teamcity service messages pushing out the stat so that it can be nicely graphed against commit history. (With #43381 )
Squirrel at 2017-09-20 21:20:53
I would love to see a PR to show memory usage information in #[bench].
David Tolnay at 2017-11-15 07:01:38
Yup, this would be great.
Although since jemalloc usage is no longer universal, it would be a bit more difficult than it used to be.
Daniel Alley at 2019-08-01 21:22:52
Serve has a library for easy query of heap size at here (Though they have switched to an internal tool
malloc_size_ofin the Servo project).Jemalloc, which Rust uses by default, has support for monitoring memory usage.
I think it is a nice and feasible component to be added into the standard library, not only
#[bench].Deleted user at 2020-09-02 04:51:09