Re:Sentinels Can Be Faster
by brandmeyer on Wednesday September 09, 2020 @04:49PM
(#24425751)
In the first two links you sent, the 40% result looks like the baseline case getting slower, not the unit under test getting faster. The core assembly looks look identical in both cases.
Well spotted; great for sild! Looks like the 40% claim was due to a bug in benchmarking (which makes sense, and can happen).
The order in which the tests were run was the first thing I checked in his implementation, but I looked too quickly and thought he was generating the data for each variant, so I assumed that was not the problem. [Actually, you need the same data for both tests, but generated twice]
I was going to just point out that 40% percent difference would mean that the version without the sentinel can be improved... was going to check if there is something that is preventing the branch prediction from actually taking care of that performance drop - memory is only being read and nothing should be invalidated...
https://quick-bench.com/q/314Z81FskTlcDqMCUHFVhWmDz8Q
Update 1: After moving some constants around, I get the 40% result:
https://quick-bench.com/q/lPrpQTAyDQuOoKS9MBWCTBXk1TE
No idea why it made such a big difference to the benchmark.
Update 2: If the test order is reversed, the result goes back to being only slightly faster for the sentinel version:
https://quick-bench.com/q/Ds7aqe5-6md_tTPndOK54ltYZmE