bheisler / iai

Experimental one-shot benchmarking/profiling harness for Rust
Apache License 2.0
591 stars 24 forks source link

[idea] Running this on MacOS / without valgrind dependency #25

Open untitaker opened 2 years ago

untitaker commented 2 years ago

I'm thinking of ways to run this on platforms where valgrind is not easily available. My current thinking is that iai could launch a Docker container with valgrind preinstalled and run its benchmarks there, then delete the container again. Docker (and the Linux VM that comes with Docker for Mac) is already "priced in" cost in my developer experience.

I don't think it makes a ton of sense to do all of Rust development in Docker though, after all compilation is still faster on M1, and most other things work.

d-bucur commented 2 years ago

You can probably write a Dockerfile to install valgrind and run the bench suite inside the container. Then launch it with a shell script. Seems pretty straightforward. https://www.gungorbudak.com/blog/2018/06/13/memory-leak-testing-with-valgrind-on-macos-using-docker-containers/

madsmtm commented 2 years ago

Another alternative: Install a fork of valgrind that works on macOS

danielparks commented 1 year ago

Unfortunately valgrind-macos seems to give results that are all over the place. Each run returns different numbers, whereas in a Docker container it seems to always return the same numbers until I change the code.

For people who are curious, there are two ways to use this crate on macOS once you’ve installed valgrind.

  1. Use the released version and put a fake setarch into your $PATH. My horrible hack looks like this:

    #!/bin/bash
    
    while [[ "$1" != valgrind && "$1" != "" ]] ; do
     shift
    done
    
    exec "$@"
  2. Install an unreleased version of this crate:
    iai = { git = "https://github.com/bheisler/iai" }
madsmtm commented 1 year ago

It seems dynamic linker startup is quite noisy.

I created https://github.com/bheisler/iai/pull/26 which makes things a lot more stable for me.