iai icon indicating copy to clipboard operation
iai copied to clipboard

[idea] Running this on MacOS / without valgrind dependency

Open untitaker opened this issue 3 years ago • 4 comments

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.

untitaker avatar Jan 24 '22 19:01 untitaker

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/

d-bucur avatar Jan 29 '22 21:01 d-bucur

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

madsmtm avatar Feb 03 '22 22:02 madsmtm

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" }
    

danielparks avatar Jan 11 '23 14:01 danielparks

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.

madsmtm avatar Jan 11 '23 19:01 madsmtm