3 ms·
I always hear about how use of mutexes is costly but i never actually encountered a significant performance hit from using synchronization. Unless, of course, y
by bitkrieg 13y ago
I always hear about how use of mutexes is costly but i never actually encountered a significant performance hit from using synchronization. Unless, of course, you have like 10 threads frequently accessing the same memory, which is more a design issue.
- pkolaczk 13y agoUncontended interlocked operation is typically about 100-300 CPU cycles. Uncontended mutex is about 30x-50x that. If there is contention, multiply everything by another 100x. Additionally these instructions impact not only the calling thread but also other threads by forcing cache synchronization. Therefore a relatively simple operation like pointer assignment can be one cycle when using GC and a hundred to several thousands cycles when using refcounting. Sometimes you can ignore this overhead, sometimes not - depends on how often you do that. http://software.intel.com/en-us/articles/choosing-between-synchronization-primitives http://software.intel.com/en-us/articles/choosing-between-sy...
- Ono-Sendai 13y agoOn what CPU? on my i7s it's much faster. on the order of 50 cycles for a uncontended mutex lock and release i think. I can dig out the values if anyone cares.