February 26th, 2013

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.

Topics
Other

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.