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

Randomize layouts #92

Open
FilipAndersson245 opened this issue Oct 1, 2024 · 2 comments
Open

Randomize layouts #92

FilipAndersson245 opened this issue Oct 1, 2024 · 2 comments

Comments

@FilipAndersson245
Copy link

FilipAndersson245 commented Oct 1, 2024

Is your feature request related to a problem? Please describe.
In his talk "Performance Matters", Emery Berger talk about the importance of randomness when doing benchmarks, as a lot of small layout changes may produce large impacts its hard to find when it is an actual improvement. He proposes that if done repeatedly, a complete random layout cannot bias the result. He compares that doing multiple samples over the same layout can be seen as asking 1 person a question 30 times instead of asking 30 people 1 question.

Describe the solution you'd like
Emery Berger brings up these main points of where layout can be randomized to help remove biases.

  • function addresses
  • stack frame sizes
  • heap allocations

I do not know how possible all these are in zig, but implementing some of them may help improve benchmark accuracy.

Describe alternatives you've considered
We do not do this and ignore layout optimizations in the code.

Additional context
https://youtu.be/r-TLSBdHe1A?t=950
https://people.cs.umass.edu/%7Eemery/pubs/stabilizer-asplos13.pdf

@FilipAndersson245
Copy link
Author

FilipAndersson245 commented Oct 4, 2024

The simplest first approach if this seem interesting would be to implement something that randomize the heap allocations. Emery describe a simple approch to that in their paper linked above.

image

there is also this implementation of it in rust, but it should probably be simpler to do in zig. This could probably be added next to TrackingAllocator

@hendriknielaender
Copy link
Owner

@FilipAndersson245 thank you for suggesting this. I need to dig a little bit into it. I will have a look 👍

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

2 participants