Today, there are various uses of volatile variable to make sure the result (and hence the operation itself) doesn't get eliminated through dead code. There is guidance here that describes it. However volatile variables are expensive on ARM64 and should be avoided whenever possible. With volatile variables in place, the measurement could get hidden by just the cost of memory barriers needed to access volatile variable. We should consider eliminating this pattern (specially from BenchStone benchmarks) and instead either
- accumulate result in a private variable which gets returned
- accumulate the result in an array that gets returned
- pass the result to a method that is marked with
[NoInling].
I can do this for some benchmarks when I get time. But just want to listen to what others think about it.
Today, there are various uses of
volatilevariable to make sure the result (and hence the operation itself) doesn't get eliminated through dead code. There is guidance here that describes it. Howevervolatilevariables are expensive on ARM64 and should be avoided whenever possible. Withvolatilevariables in place, the measurement could get hidden by just the cost of memory barriers needed to accessvolatilevariable. We should consider eliminating this pattern (specially from BenchStone benchmarks) and instead either[NoInling].I can do this for some benchmarks when I get time. But just want to listen to what others think about it.