Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

mutexes are not that slow.

Uncontested (single thread):

  incrementing using atomics took 0.002011 s (0.2513 ns / increment)
  incrementing using mutex took   0.005515 s (0.6894 ns / increment)
Contested (8 threads trying to increment a single protected integer):

  incrementing using atomics took 0.1069 s (13.36 ns / increment)
  incrementing using mutex took   1.970 s (246.3 ns / increment)
So mutexes are roughly the same speed in the uncontested case, and about 20x slower in this heavily contested case. This is on Windows.


Is that AMD or Intel? Intel ivalidates the other CPU's cache line on write. AMD sends an update to the other CPU's cache line. AMD is supposed to be significantly faster than Intel on a "real" multiprocessor workload.


Don’t know why you were downvoted but yes, AMD uses MOESI and Intel uses MESI.


AMD Ryzen 9.


I guess you have more than 8 physical CPUs?


16 cores




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: