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

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

Open
untitaker opened this issue Jan 24, 2022 · 4 comments
Open

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

untitaker opened this issue Jan 24, 2022 · 4 comments

Comments

@untitaker
Copy link

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
Copy link

d-bucur commented Jan 29, 2022

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
Copy link

madsmtm commented Feb 3, 2022

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

danielparks added a commit to danielparks/htmlize that referenced this issue Jan 11, 2023
[iai] “benchmarks” functions by counting instructions, cache hits, and
memory accesses. It also estimates cycles.

It uses [`valgrind`], which officially doesn’t run on macOS (though
there is a [port]), and `setarch`, a Linux-only command they use to
disable address space layout randomization (ASLR). See [iai #25] for
more information about running on macOS.

This includes a Dockerfile to provide an environment to run `valgrind`.

Note that iai hasn’t been updated since February 2021.

To do:

  * [ ] Look for a maintained alternative.
  * [ ] Write macros to remove duplication in benchmarks.
  * [ ] Document how to run iai benchmarks.
  * [ ] Add CI report from iai run?

[iai]: https://github.com/bheisler/iai
[`valgrind`]: https://valgrind.org
[port]: https://github.com/LouisBrunner/valgrind-macos
[iai #25]: bheisler/iai#25
danielparks added a commit to danielparks/htmlize that referenced this issue Jan 11, 2023
[iai] “benchmarks” functions by counting instructions, cache hits, and
memory accesses. It also estimates cycles.

It uses [`valgrind`], which officially doesn’t run on macOS (though
there is a [port]), and `setarch`, a Linux-only command they use to
disable address space layout randomization (ASLR). See [iai #25] for
more information about running on macOS.

This includes a Dockerfile to provide an environment to run `valgrind`.

Note that iai hasn’t been updated since February 2021.

To do:

  * [ ] Look for a maintained alternative.
  * [ ] Write macros to remove duplication in benchmarks.
  * [ ] Document how to run iai benchmarks.
  * [ ] Add CI report from iai run?

[iai]: https://github.com/bheisler/iai
[`valgrind`]: https://valgrind.org
[port]: https://github.com/LouisBrunner/valgrind-macos
[iai #25]: bheisler/iai#25
@danielparks
Copy link

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
Copy link

madsmtm commented Jan 11, 2023

It seems dynamic linker startup is quite noisy.

I created #26 which makes things a lot more stable for me.

danielparks added a commit to danielparks/htmlize that referenced this issue Jan 12, 2023
[iai] “benchmarks” functions by counting instructions, cache hits, and
memory accesses. It also estimates cycles.

It uses [`valgrind`], which officially doesn’t run on macOS (though
there is a [port]), and `setarch`, a Linux-only command they use to
disable address space layout randomization (ASLR). See [iai #25] for
more information about running on macOS.

This includes a Dockerfile and a docker.sh script to provide an
environment to run `valgrind`.

Note that iai hasn’t been updated since February 2021.

To do:

  * [x] Look for a maintained alternative.
  * [ ] Write macros to remove duplication in benchmarks.
  * [x] Document how to run iai benchmarks.
  * [ ] Add CI report from iai run?

[iai]: https://github.com/bheisler/iai
[`valgrind`]: https://valgrind.org
[port]: https://github.com/LouisBrunner/valgrind-macos
[iai #25]: bheisler/iai#25
danielparks added a commit to danielparks/htmlize that referenced this issue Jan 12, 2023
[iai] “benchmarks” functions by counting instructions, cache hits, and
memory accesses. It also estimates cycles.

It uses [`valgrind`], which officially doesn’t run on macOS (though
there is a [port]), and `setarch`, a Linux-only command they use to
disable address space layout randomization (ASLR). See [iai #25] for
more information about running on macOS.

This includes a Dockerfile and a docker.sh script to provide an
environment to run `valgrind`.

Note that iai hasn’t been updated since February 2021. Some folks are
working on [calliper], but it doesn’t seem to be ready yet.

To do:

  * [x] Look for a maintained alternative.
  * [ ] Write macros to remove duplication in benchmarks.
  * [x] Document how to run iai benchmarks.
  * [ ] Add CI report from iai run?

[iai]: https://github.com/bheisler/iai
[`valgrind`]: https://valgrind.org
[port]: https://github.com/LouisBrunner/valgrind-macos
[iai #25]: bheisler/iai#25
[calliper]: https://github.com/osiewicz/calliper
danielparks added a commit to danielparks/htmlize that referenced this issue Jan 12, 2023
[iai] “benchmarks” functions by counting instructions, cache hits, and
memory accesses. It also estimates cycles.

It uses [`valgrind`], which officially doesn’t run on macOS (though
there is a [port]), and `setarch`, a Linux-only command they use to
disable address space layout randomization (ASLR). See [iai #25] for
more information about running on macOS.

This includes a Dockerfile and a docker.sh script to provide an
environment to run `valgrind`.

Note that iai hasn’t been updated since February 2021. Some folks are
working on [calliper], but it doesn’t seem to be ready yet.

To do:

  * [x] Look for a maintained alternative.
  * [ ] Write macros to remove duplication in benchmarks.
  * [x] Document how to run iai benchmarks.
  * [ ] Add CI report from iai run?

[iai]: https://github.com/bheisler/iai
[`valgrind`]: https://valgrind.org
[port]: https://github.com/LouisBrunner/valgrind-macos
[iai #25]: bheisler/iai#25
[calliper]: https://github.com/osiewicz/calliper
danielparks added a commit to danielparks/htmlize that referenced this issue Jan 12, 2023
[iai] “benchmarks” functions by counting instructions, cache hits, and
memory accesses. It also estimates cycles.

It uses [`valgrind`], which officially doesn’t run on macOS (though
there is a [port]), and `setarch`, a Linux-only command they use to
disable address space layout randomization (ASLR). See [iai #25] for
more information about running on macOS.

This includes a Dockerfile and a docker.sh script to provide an
environment to run `valgrind`.

Note that iai hasn’t been updated since February 2021. Some folks are
working on [calliper], but it doesn’t seem to be ready yet.

[iai]: https://crates.io/crates/iai
[`valgrind`]: https://valgrind.org
[port]: https://github.com/LouisBrunner/valgrind-macos
[iai #25]: bheisler/iai#25
[calliper]: https://crates.io/crates/calliper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants