[x] Check branch prediction success rate with perf before/after
[x] LLVM Comparison
[x] GCC Comparison
Conclusion
Simply marking the happy path [[likely]] and error branches [[unlikely]] resulted in 10% fewer missed branches on a full collection parse (which includes hitting a few unlikely branches e.g. special handling of MTGO ID == 1).
Full parse of a collection of around 3k unique cards on an 8 year old ThinkPad (3rd gen) running Lubuntu 22.04.
LLVM Before 73-85 ms
The branch misses were consistently above 310k. The range was approx. 310-325k misses (~0.33%)
LLVM After 70-73 ms
The branch misses are consistent below 310k in the same scenario as above. The range is now 300-310k misses (~0.32%).
perf
before/afterConclusion
Simply marking the happy path
[[likely]]
and error branches[[unlikely]]
resulted in 10% fewer missed branches on a full collection parse (which includes hitting a few unlikely branches e.g. special handling of MTGO ID == 1).Full parse of a collection of around 3k unique cards on an 8 year old ThinkPad (3rd gen) running Lubuntu 22.04.
LLVM Before
73-85
msThe branch misses were consistently above 310k. The range was approx.
310-325k
misses (~0.33%)LLVM After
70-73
msThe branch misses are consistent below 310k in the same scenario as above. The range is now
300-310k
misses (~0.32%).GCC Before
65-70
msApprox.
330-350k
misses (~0.44%)GCC After
65-66
msApprox.
290-300k
misses (~0.40%)