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!

135 Upvotes

185 comments sorted by

View all comments

Show parent comment

10

u/thisismyfavoritename Feb 16 '26

ok. What are the specific strategies to optimize for a specific machine. Just looking for actual examples.

1

u/BrianChampBrickRon Feb 17 '26

One example is only some cpus can take advantage of aquire release semantics. You only care about that optimization if its supported.

1

u/thisismyfavoritename Feb 17 '26

i've never seen code where relaxed was used everywhere on purpose because it was meant to run on a CPU with strict memory guarantees

1

u/BrianChampBrickRon Feb 17 '26

Another example: if you have numa nodes you have to pay attention to what cores are in communication. Because syncing across nodes takes more time.

1

u/BrianChampBrickRon Feb 17 '26

Know what instructions your cpu supports. Can you use SIMD?