Job system: spin before sleeping (measured) #18

Open
UnflavoredMeson/Primal_Plus_Plus
opened 2026-11-24 20:15:53 +00:00 by UnflavoredMeson · 0 comments
Owner

Why

Waking a sleeping worker costs about 37-48 µs, which is why small batches run on the calling thread. A short bounded spin may make small renderer jobs worth splitting. Do this once S6 gives you a renderer to measure.

Decided

  • Only with measurements: the GraphicsTests benchmarks and the transform update, with PRIMAL_JOBS varied, plus the power cost (an idle frame mustn't keep cores busy).
  • Bounded spin with a pause instruction, then sleep.

Read first

Steps

  • 1. Record the baseline numbers.
  • 2. Add the spin; measure the same cases.
  • 3. Keep it only if it helps; write down the numbers either way.

Done when

  • Numbers before and after are in this issue; JobTests pass under TSan.

Claude can help with

  • Running the benchmark matrix.

Learn

  • What _mm_pause does for a spinning core and its sibling hyperthread.
## Why Waking a sleeping worker costs about 37-48 µs, which is why small batches run on the calling thread. A short bounded spin may make small renderer jobs worth splitting. Do this once S6 gives you a renderer to measure. ## Decided - Only with measurements: the GraphicsTests benchmarks and the transform update, with `PRIMAL_JOBS` varied, plus the power cost (an idle frame mustn't keep cores busy). - Bounded spin with a pause instruction, then sleep. ## Read first - `UnflavoredMeson/Primal#73`, [Multithreading](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/Multithreading) section 9 step 5. ## Steps - [ ] 1. Record the baseline numbers. - [ ] 2. Add the spin; measure the same cases. - [ ] 3. Keep it only if it helps; write down the numbers either way. ## Done when - [ ] Numbers before and after are in this issue; JobTests pass under TSan. ## Claude can help with - Running the benchmark matrix. ## Learn - What `_mm_pause` does for a spinning core and its sibling hyperthread.
Sign in to join this conversation.
No assignees
No project
No milestone
Depends on
#16 Job system module primal.jobs
UnflavoredMeson/Primal_Plus_Plus
#35 Parallel preparation and command recording
UnflavoredMeson/Primal_Plus_Plus
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
UnflavoredMeson/Primal_Plus_Plus#18
No description provided.