r/cpp • u/Polarstrike • Mar 07 '24
What are common mistakes in C++ code that results in huge performance penalties?
As title, list some common mistakes that you have done/seen which lead to performance penalties.
231
Upvotes
View all comments
Show parent comment
1
u/CentralSword Mar 07 '24 edited Mar 07 '24
In my opinion using atomics doesn't require thinking about the most suitable memory order in every operation. It's enough to know what these two words mean and how to use it to optimize your code. I myself have never used half of the memory order types, I know that if I ever want to optimize something with it, I will just open cppreference. Also I was taught that relaxed memory order is an expert friendly thing that isn't that necessary to use, unless you're on a very specific architecture.