[PR #2174] [CLOSED] pool: STRATA_POOL_UMWAIT - parked workers sleep with UMONITOR/UMWAIT instead of spinning (opt-in, -3.1% ms/window on a 12 GB laptop, bitwise) #3901

Closed
opened 2026-11-07 15:31:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2174
Author: @zsariboga
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: pr-pool-umwait


📝 Commits (1)

  • b4f9112 pool: STRATA_POOL_UMWAIT= - parked workers wait with UMONITOR/UMWAIT instead of spinning (opt-in, x86 WAITPKG, MSVC x64)

📊 Changes

1 file changed (+57 additions, -2 deletions)

View changed files

📝 src/kernels/cpu/pool.cpp (+57 -2)

📄 Description

What

STRATA_POOL_UMWAIT=<TSC cycles> (opt-in, x86 with WAITPKG, MSVC x64 builds): a parked CPU pool worker no longer spins on
_mm_pause. It arms UMONITOR on the epoch's cache line and sleeps in UMWAIT (C0.1) until the host publishes the next
phase (the write to that line wakes it in hardware) or the cycles run out; then it checks the clock and the sleep rule as
before.

  • STRATA_POOL_UMWAIT_C02=1: the deeper C0.2 state instead of C0.1.
  • STRATA_POOL_UMWAIT_ESC=<cycles>: C0.1 for the first cycles of a park, C0.2 after (a long park is a GPU phase).
  • Unset, 0, a CPU without WAITPKG (CPUID.7.0:ECX[5], one line says so) or a non-MSVC build: the spin, unchanged.

Why

On a laptop the CPU and the GPU share one power and thermal budget. During the GPU's part of a decode window the parked
workers spin, and that power is taken from the GPU (here sw_power_cap was active in ~100% of the samples). Sleeping in
UMWAIT gives it back; the wake on the publish is a hardware monitor, so a worker still starts the next phase at once.

Measured

RTX 5070 Ti Laptop 12 GB, Core Ultra 7 255HX (16 P+E cores, WAITPKG), 64 GB DDR5-5600, Windows 11, Swift 1.5 IQ3_XXS
(GSQ-RCO), the same config in every arm, mirrored order, engine ms per decode window, GPU power from nvidia-smi every 500 ms:

arm ms/window (two runs) mean vs spin GPU power SM clock
13 workers, spin (before) 29.42 / 29.79 29.61 - 122.0 / 122.7 W 2400 / 2361 MHz
13 workers, STRATA_POOL_UMWAIT=100000 29.02 / 29.04 29.03 -2.0% 128.2 / 125.3 W 2416 / 2400 MHz
16 workers, STRATA_POOL_UMWAIT=100000 28.96 / 28.44 28.70 -3.1% 128.4 / 128.0 W 2444 / 2422 MHz
19 workers, STRATA_POOL_UMWAIT=100000 31.31 / 31.15 31.23 +5.5% 126.6 / 124.9 W 2365 / 2391 MHz

The sleep hands the GPU ~6 W, and it also lets more workers pay off (16 spinning workers had been slower than 13). C0.2
and the escalating wait were within the noise of C0.1 (28.57 / 28.68 vs 28.90 ms, inconsistent across mirrored pairs), so
C0.1 is the default state. Output is bitwise the same: only how a parked thread waits changes.

Running daily on this laptop since 10 October with STRATA_POOL_UMWAIT=100000 --pool-workers 16. Built and smoke-tested
on today's main (a0116b27): the engine prints STRATA_POOL_UMWAIT: parked workers wait with UMWAIT (100000 cycles),
chat and tool calls answer as before.

Not done

GCC/Clang builds (they need -mwaitpkg or a target attribute on the worker), and TPAUSE for parks without a monitored
line. AMD CPUs have MONITORX/MWAITX instead; not tried.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2174 **Author:** [@zsariboga](https://github.com/zsariboga) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr-pool-umwait` --- ### 📝 Commits (1) - [`b4f9112`](https://github.com/Niko1221/Strata/commit/b4f9112e9f12b5520e0726bd5df267b39626c6fe) pool: STRATA_POOL_UMWAIT=<cycles> - parked workers wait with UMONITOR/UMWAIT instead of spinning (opt-in, x86 WAITPKG, MSVC x64) ### 📊 Changes **1 file changed** (+57 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/kernels/cpu/pool.cpp` (+57 -2) </details> ### 📄 Description ## What `STRATA_POOL_UMWAIT=<TSC cycles>` (opt-in, x86 with WAITPKG, MSVC x64 builds): a parked CPU pool worker no longer spins on `_mm_pause`. It arms `UMONITOR` on the epoch's cache line and sleeps in `UMWAIT` (C0.1) until the host publishes the next phase (the write to that line wakes it in hardware) or the cycles run out; then it checks the clock and the sleep rule as before. - `STRATA_POOL_UMWAIT_C02=1`: the deeper C0.2 state instead of C0.1. - `STRATA_POOL_UMWAIT_ESC=<cycles>`: C0.1 for the first cycles of a park, C0.2 after (a long park is a GPU phase). - Unset, `0`, a CPU without WAITPKG (CPUID.7.0:ECX[5], one line says so) or a non-MSVC build: the spin, unchanged. ## Why On a laptop the CPU and the GPU share one power and thermal budget. During the GPU's part of a decode window the parked workers spin, and that power is taken from the GPU (here `sw_power_cap` was active in ~100% of the samples). Sleeping in UMWAIT gives it back; the wake on the publish is a hardware monitor, so a worker still starts the next phase at once. ## Measured RTX 5070 Ti Laptop 12 GB, Core Ultra 7 255HX (16 P+E cores, WAITPKG), 64 GB DDR5-5600, Windows 11, Swift 1.5 IQ3_XXS (GSQ-RCO), the same config in every arm, mirrored order, engine ms per decode window, GPU power from `nvidia-smi` every 500 ms: | arm | ms/window (two runs) | mean | vs spin | GPU power | SM clock | | --- | --- | --- | --- | --- | --- | | 13 workers, spin (before) | 29.42 / 29.79 | 29.61 | - | 122.0 / 122.7 W | 2400 / 2361 MHz | | 13 workers, `STRATA_POOL_UMWAIT=100000` | 29.02 / 29.04 | 29.03 | -2.0% | 128.2 / 125.3 W | 2416 / 2400 MHz | | 16 workers, `STRATA_POOL_UMWAIT=100000` | 28.96 / 28.44 | 28.70 | **-3.1%** | 128.4 / 128.0 W | 2444 / 2422 MHz | | 19 workers, `STRATA_POOL_UMWAIT=100000` | 31.31 / 31.15 | 31.23 | +5.5% | 126.6 / 124.9 W | 2365 / 2391 MHz | The sleep hands the GPU ~6 W, and it also lets more workers pay off (16 spinning workers had been slower than 13). C0.2 and the escalating wait were within the noise of C0.1 (28.57 / 28.68 vs 28.90 ms, inconsistent across mirrored pairs), so C0.1 is the default state. Output is bitwise the same: only how a parked thread waits changes. Running daily on this laptop since 10 October with `STRATA_POOL_UMWAIT=100000 --pool-workers 16`. Built and smoke-tested on today's `main` (a0116b27): the engine prints `STRATA_POOL_UMWAIT: parked workers wait with UMWAIT (100000 cycles)`, chat and tool calls answer as before. ## Not done GCC/Clang builds (they need `-mwaitpkg` or a target attribute on the worker), and `TPAUSE` for parks without a monitored line. AMD CPUs have `MONITORX/MWAITX` instead; not tried. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:31:32 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3901
No description provided.