-
Notifications
You must be signed in to change notification settings - Fork 176
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
Add Memory benchmarks #107
Comments
Seems I was a bit optimistic. Criterion doesn't have an easy way to capture custom values from benchmarks yet - bheisler/criterion.rs#97 |
By compiling to WASM, you can get some good data on code size. For memory usage, is there a Rust equivalent of valgrind (or does valgrind work with Rust code)? |
valgrind works great. I recall there being some issues with zero-sized types in the past but I think those are fixed. |
We should use njn's recommendations - https://nnethercote.github.io/perf-book/introduction.html |
I was talking to @zbraniecki about this, and I'm interested in taking on this work. |
I've been researching using
The total bytes is the total amount of allocations over the entire run of the program. Here it's 21,642 bytes. The At this point, I'll need to figure out how to programmatically gather this information. I took some time to understand the output JSON format, and all of this information is easily accessible. Some negatives here are that each file we want to test will need to be manually instrumented, dhat-rs can't attached from the outside. It's a pretty simple setup, but will pollute the examples a bit. In addition, it will output additional information to stdout. The JSON outputs to a fixed location, so a script runner will need to clean up things after running. As for a more detailed analysis, I found the valgrind viewer to be a bit difficult to work with, so doing anything other than a direct measurement may be a bit difficult. Here is a commit showing the work so far: https://github.com/unicode-org/icu4x/compare/master...gregtatum:dhat?expand=1 |
Here is a hosted version of the viewer: https://gregtatum.github.io/dhat-viewer/dh_view.html Here is an example run, which will need to be unzipped, and loaded in the viewer. I also hacked it into the Firefox Profiler format to explore what the data looks like a bit more, and what's available in the analysis. The data is only working in the call tree view. |
Could we have a script that injects dhat into examples? It seems that all it would take is:
#[global_allocator]
static ALLOCATOR: dhat::DhatAlloc = dhat::DhatAlloc; let _dhat = dhat::Dhat::start_heap_profiling(); and done. |
https://github.com/google/rerast Rerast looks like it could handle the code modding. |
I think Valgrind can be used directly on Rust binaries, too. It takes machine code binaries and runs them in a virtualized environment to track heap allocations.
There are ways to make it output additional metrics or print them in a more machine-readable format. |
One drawback is that Valgrind is Linux only, which would be fine for the CI to run it, but can only reproduced on Linux machines. |
I got the charts generating today: Here is an example run, the artifacts can be downloaded: https://github.com/gregtatum/icu4x/actions/runs/470094202 I ended up forking the benchmarking library in order to get generic reporting working, by creating an I'll try and upstream the changes, but the repo doesn't look like it's actively maintained anymore. Here are the TODOs remaining:
|
I'm going to try to add memory/size benchmarks to our
cargo bench
.For size, I'm going to add a simple example binary that will pull ICU4X and we'll measure the impact of that.
The text was updated successfully, but these errors were encountered: