4 ms·
Crazy trick. I'll tell you what a crazy trick is. It's when you are sitting, optimizing some bulk throughput rate in a router firmware, generally minding your
by huhtenberg 10y ago
Crazy trick. I'll tell you what a crazy trick is.
It's when you are sitting, optimizing some bulk throughput rate in a router firmware, generally minding your own business and then a guy pops in and says that he just sped things up by a factor of 10. You get up, follow him to his cubicle and, lo and behold, it is 10x faster when blasted with a SmartBit stream. Ask him how he managed to achieve such a remarkable feat and he says - I just profiled the code, found a bottleneck and worked around it:
// some_random_mutex.lock();
...
// some_random_mutex.unlock();
Now THAT was a crazy trick.
Edit: to clarify - the lock was there for a reason. The whole thing whoopsed in an instant outside that specific test.
- gambiting 10y agoWell to be fair I know of a certain game that was released on PS3, which ran into the hardware limit for locks inside the UI system. Someone thought of just commenting them out, and tested it - the whole UI worked fine, and we went from having thousands of locks in the UI system to having zero - and the game shipped like that.
- MereInterest 10y agoNow I'm curious. Was the mutex actually necessary, or was the performance increase purchased at the cost of race conditions?
- huhtenberg 10y agoYeah, the mutex was necessary and it was pretty bloody obvious from looking at few lines of context around those calls.
- SomeCollegeBro 10y agoUnfortunately, most of the time when you come across a mutex you have to assume it's necessary. It's very hard to regression test code after removing a mutex, chances are you are not going to encounter the race condition which the mutex protects against (unless it's well documented, of course).
- deleted 10y ago[deleted]