Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend #[bench] with memory usage #22666

Open
l0kod opened this issue Feb 22, 2015 · 5 comments
Open

Extend #[bench] with memory usage #22666

l0kod opened this issue Feb 22, 2015 · 5 comments
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@l0kod
Copy link
Contributor

l0kod commented Feb 22, 2015

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

@l0kod l0kod changed the title Extend #[bench] with memory usage Extend #[bench] with memory usage Feb 22, 2015
@llogiq
Copy link
Contributor

llogiq commented Jun 16, 2015

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 malloctl function which allows to directly gather information of interest. je_malloc_stats_print is 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 perf counters in the benchmarking harness? Those may also show performance issues (e.g. cache misses, branch prediction misses, etc.) that the plain runtime cannot.

@steveklabnik steveklabnik added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Nov 15, 2016
@steveklabnik steveklabnik added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed A-libs labels Mar 24, 2017
@Mark-Simulacrum Mark-Simulacrum added C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Sep 10, 2017
@gilescope
Copy link
Contributor

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 )

@dtolnay dtolnay added C-feature-accepted Category: A feature request that has been accepted pending implementation. and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Nov 15, 2017
@dtolnay
Copy link
Member

dtolnay commented Nov 15, 2017

I would love to see a PR to show memory usage information in #[bench].

@dralley
Copy link
Contributor

dralley commented Aug 1, 2019

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.

@ghost
Copy link

ghost commented Sep 2, 2020

Serve has a library for easy query of heap size at here (Though they have switched to an internal tool malloc_size_of in 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].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants