Add an option to always instrument function entry BB (default off)
Add an options to do atomic update the first counter in each instrumented function.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
ok. Why atomic update just for first entry? are they particularly more contended than other counters?
Thanks for the patch! I guess atomic update is to reduce the cost of the entry counter for application with many threads. How much difference there is w/wo enabling -atomic-first-counter?
I tried it on an internal benchmark.
base: head of trunk
exp: pgo-instrument-entry=true, atomic-first-counter=false
qps of Instrumented binary run: 344.63 vs 340.56
optimized binary run: qps had no significant change in 6 runs. latency had ~0.1% regression in 3 runs and no regression in other 3 runs.
base: head of trunk
exp: pgo-instrument-entry=true, atomic-first-counter=true
qps of Instrumented binary run: 342.53 vs 265.58
optimized binary run: qps had no significant change in 2 runs, and had ~0.11% improvement in 4 runs. latency had ~0.35% improvement in 6 runs.
The test showed always inserting counter in the entry block had minor impact on instrumented binary and optimized binary runs. Using atomic entry counter could improve profile quality but significantly slowdown instrument binary.
Does this guarantee entry be instrumented?