Track maximum wait duration across all woken waiters in Mutex::UnlockSlow. When waking a batch of readers, `UnlockSlow` resets `contention_start_cycles` on each woken waiter, and any waiter that fails to acquire the lock is requeued in LIFO order at the front of the wait list. Recording `max_wait_cycles` from only the first waiter in `wake_list` therefore captures the shortest recent wait of a requeued reader rather than the longest wait in the woken batch. Compute the maximum across all woken non-condition waiters instead. PiperOrigin-RevId: 1010591185
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc index d5c1a3c..8874db9 100644 --- a/absl/synchronization/mutex.cc +++ b/absl/synchronization/mutex.cc
@@ -2475,7 +2475,7 @@ int64_t cycles_waited = (now - wake_list->waitp->contention_start_cycles); total_wait_cycles += cycles_waited; - if (max_wait_cycles == 0) max_wait_cycles = cycles_waited; + max_wait_cycles = std::max(max_wait_cycles, cycles_waited); wake_list->waitp->contention_start_cycles = now; wake_list->waitp->should_submit_contention_data = true; }