feat: a skewed-cost benchmark of the worker pool #169
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/6-skewed-cost-benchmark"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Task
Issue #6: the skewed-cost benchmark of the worker pool and the three measurements of CONCURRENCY.md section 9, which close the gate of slice H.
What and why
feat(runtime): measure the pool's queues, thefts and start latencyruntime/task.cbehind the compile-time macroTORB_POOL_MEASURE. For each ring worker it holds the length of the worker's own queue at every take (as a power-of-two histogram), its thefts and its first runs. It also holds the time from a task's first queueing to its first take.torb_pool_measurement_take(copy and reset), next totorb_pool_statistics_nowintorb_task.h, declared for the tests and the benchmark only.torb_pool_measure_stealing(false). It adds one guarded condition intorb_enqueue_locked: no task enters a steal list, sostealablestays 0 and idle workers sleep.torb_task, no branch on any path.runtime/tests/pool_test.chas three new tests under the macro:feat(benchmarks): a skewed-cost benchmark of the worker poolbenchmarks/pool-skew.cplusbenchmarks/pool.sh, shaped likeparallel.sh. The script compiles the sourcesruntime/build.shlists, read from that file, with the macro.GATE=1. It exits 2 on a wrong sum, a theft with one worker, or a task or block left behind.tools/gates.sh,.forgejo/workflows/or the site.benchmarks/README.mdgets a "worker pool" section listingpool.sh(andparallel.sh) as measurements.skills/is unaffected: neither file is a skill source. The tier A--checkconfirms this.Measurement
There is no C compiler on the machine I work from. So
sh benchmarks/pool.shran twice in a one-off job on a throwaway branch with a temporary workflow. That branch is deleted, and the workflow is not part of this PR.Machine: AMD EPYC-Genoa, 16 logical processors (KVM guest), Linux 6.8.0 x86_64, Ubuntu 24.04, gcc 13.3, load average about 1.1. Date: 2026-10-08.
WORKERS=1gave ratio 0.999 and 1.000, zero thefts, and 0 live blocks.The median is within 1.5, so section 9 states 1.5 (with 2.0 as the hard bound), per decision 4. The issue says a shared forge runner is not the reference. The record therefore names this machine and says the maintainer's machine has not run it yet; a re-run there with
sh benchmarks/pool.shcan replace the numbers.Test
CFLAGS=-DTORB_POOL_MEASURE sh runtime/build.shwith gcc and with clang: 222 tests, 0 failed, both times. This is the macro path, the three new tests included.sh tools/gates.sh aand tier B, which includessh runtime/build.shwith gcc and clang). The default CI does not compile the macro path; wiring it into a workflow is a separate change (decision 5).sh tools/check-commits.sh origin/main HEAD: clean.Closes #6
3b59cf505f6023207874Approved at
6023207. Checklist:runtime/tests/pool_test.c(first runs/thefts counted on four workers, stealing off keeps everything on the main worker, one worker steals nothing). CI is green for this head, with the macro unset. The macro path was run once in a throwaway job with gcc and clang (222 tests, 0 failed), as the PR documents.dropped.takeandmeasure_stealingrefuse to run while the pool is running. WithoutTORB_POOL_MEASUREno field or branch is compiled in. The benchmark's cost, pool and control runs, the ideal splitmax(total/W, longest)and the exit codes (1 only withGATE=1, 2 on a wrong sum, a theft with one worker, or a leftover task or block) match issue #6, decisions 3-5.tools/gates.sh, the workflows or the site. No public surface.Non-blocking:
CFLAGS=-DTORB_POOL_MEASURE sh runtime/build.shwould close it.Checklist (head
6023207, CI green, pdisc green):pool_test.c(first runs and thefts counted, no-stealing control, one worker steals nothing); the PR body documents a gcc and clang run with-DTORB_POOL_MEASURE(222 tests, 0 failed). The default build is covered by CI.first_runs/stolenslot; latency slots are taken by an atomic index;measure_queuedis zero-initialised bytorb_allocate_zeroed; the reader refuses to run while the pool is up. Steal path counts the first run after the unlock, as intorb_take_local.torb_enqueue_lockedand the other paths.Non-blocking: none.