Skip to content

Size SpinLock and Mutex spin time limits to machine capacity. - #2419

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1009321328
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1009321328

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Size SpinLock and Mutex spin time limits to machine capacity.

Fixed spin-loop iteration counts spend 2–4× more wall-clock time on slower CPUs than on faster ones. In fleet experiments, longer fixed-iteration spins improved performance smaller and mid-size machines, but regressed performance on the highest-capacity machines, where packed work appears to scale with machine GCU capacity.

Bound contended SpinLock and exclusive absl::Mutex spinning by a shared process-wide time limit T = min(5 µs, 1.4 µs × 250 / (g × N)), inversely proportional to machine compute capacity. Estimate per-CPU speed g via an integer-latency probe (4 readings per calibration, latching the fastest reading seen by the process) and refresh T on failed lock() slow paths before wait timestamps are recorded, at intervals doubling from 10 ms to 10 s.

@copybara-service
copybara-service Bot force-pushed the test_1009321328 branch 2 times, most recently from 1c418fb to 0c546c3 Compare November 3, 2026 01:49
@copybara-service copybara-service Bot changed the title Size SpinLock and Mutex spin time limits to machine capacity. Internal cleanup Nov 3, 2026
@copybara-service copybara-service Bot changed the title Internal cleanup Size SpinLock and Mutex spin time limits to machine capacity. Nov 3, 2026
@copybara-service
copybara-service Bot force-pushed the test_1009321328 branch 5 times, most recently from fbad92e to 00afd4b Compare November 3, 2026 06:05
Fixed spin-loop iteration counts spend 2–4× more wall-clock time on slower CPUs than on faster ones. In fleet experiments, longer fixed-iteration spins improved performance smaller and mid-size machines, but regressed performance on the highest-capacity machines, where packed work appears to scale with machine GCU capacity.

Bound contended `SpinLock` and exclusive `absl::Mutex` spinning by a shared process-wide time limit T = min(5 µs, 1.4 µs × 250 / (g × N)), inversely proportional to machine compute capacity. Estimate per-CPU speed g via an integer-latency probe (4 readings per calibration, latching the fastest reading seen by the process) and refresh T on failed lock() slow paths before wait timestamps are recorded, at intervals doubling from 10 ms to 10 s.

PiperOrigin-RevId: 1009321328
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant