This code would be a lot faster if it weren’t for the synchronization
This is a story from a friend of a friend, which makes it probably untrue, but I still like the story.
One of my colleagues jokingly suggested that we could speed up our code by adding these lines to our project
#define EnterCriticalSection(p) ((void)0) #define LeaveCriticalSection(p) ((void)0)
I replied, “You think you’re joking, but you’re not.”
According to legend, there was a project whose product was running too slow, so they spun off a subteam to see what architectural changes would help them improve their performance. The subteam returned some time later with a fork of the project that they had “tuned”. And it was indeed the case that the performance-tuned version ran a lot faster.
Later, the development team discovered that part of the “tuning” involved simply deleting all the synchronization. They didn’t replace it with lock-free algorithms or anything that clever. They just removed all the critical sections.