You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the lock_sema.go implementation of mutexes, lock handles contention by adding the current M to the front of the linked list of waiting Ms, and then unlock wakes up the M at the front of the list. I.e., waiting Ms are awoken in LIFO order.
Is it worth changing unlock to awake the M at the end of the list to effect a FIFO order?
For comparison, lock_futex.go leaves resolving contention to the OS. On Linux, futex wakeup ordering doesn't seem to be guaranteed, but they do at least currently appear to use FIFO ordering (for threads with the same priority/nice level): http://lists.openwall.net/linux-kernel/2015/01/24/106
The text was updated successfully, but these errors were encountered:
I don't see any obvious reason to change it. FIFO will get you better fairness, LIFO gets you better cache behavior. Unless there's a particular case where you think fairness is important, I'm inclined to leave it as is.
Is there a specific situation in which you noticed this?
I'm not aware of it causing problems. I just happened to notice the LIFO ordering while reviewing the code, and thought I'd file an issue in the spirit of #11506.
In the lock_sema.go implementation of mutexes, lock handles contention by adding the current M to the front of the linked list of waiting Ms, and then unlock wakes up the M at the front of the list. I.e., waiting Ms are awoken in LIFO order.
Is it worth changing unlock to awake the M at the end of the list to effect a FIFO order?
For comparison, lock_futex.go leaves resolving contention to the OS. On Linux, futex wakeup ordering doesn't seem to be guaranteed, but they do at least currently appear to use FIFO ordering (for threads with the same priority/nice level): http://lists.openwall.net/linux-kernel/2015/01/24/106
The text was updated successfully, but these errors were encountered: