r/cpp • • Feb 16 '26

Favorite optimizations ??

I'd love to hear stories about people's best feats of optimization, or something small you are able to use often!

134 Upvotes

185 comments sorted by

View all comments

Show parent comment

1

u/Alborak2 Feb 17 '26

All our timing stuff now bypasses normal clock sources and work directly off cpu timestamp counter. It gets completely inlined and is maybe 30 cycles on x86 including the shift and or to form the u64. Just have to watch out for cycles going backwards with multi socket systems. We do cache it for short times in some super hot paths.