Skip to content

Catalog and sequential kernels on WorkMeter; threads come from the execution - #11

Merged
alexy merged 2 commits into
mainfrom
work/catalog-on-workmeter
Sep 20, 2026
Merged

alexy merged 2 commits into
mainfrom
work/catalog-on-workmeter

Conversation

@alexy

@alexy alexy commented Sep 20, 2026

Copy link
Copy Markdown
Member

Step 5 of the order in codex-to-codex.md (2026-09-20T08:15Z). After this there is one accounting layer and one source of thread counts in grust-algorithms.

What changes

The seventeen catalog kernels move onto the surviving layer. Meter and parallel::width() are deleted. Every kernel charges through ExecutionContext::work_meter(), which admits work before it is done, so a budget is never exceeded by work already performed; the old Meter could overshoot by a block per worker.

Threads come from the execution, never from the machine. parallel::concurrency(context, units) is what the execution asked for above the shared floor, otherwise one. map_ranges, ordered_blocks, for_chunks and sort_total take that count. At one worker they run on the calling thread and do not touch rayon; above it they run inside the bounded pool for that count. Before, a kernel called outside an installed pool used rayon's global pool, which is every core of the machine.

Behaviour change: a caller that does not call with_concurrency now runs every catalog kernel single-threaded. Results are unchanged and bit-identical at any worker count. Nutmeg must pass the option through to get parallel kernels.

One meter per block workspace, not per node or per source, because creating a WorkMeter takes the grant registry exclusively.

The sequential kernels charge through a meter too: dijkstra, shortestPaths, bfs, dfs, topologicalSort, scc, wcc, and the MinHeap the path kernels share, instead of one compare-exchange on the shared counter per visited entry.

Tests

175 pass across grust-procedures, grust-algorithms and grust-algorithm-procedures with all features; clippy clean with -D warnings; --no-default-features builds. The determinism tests now ask for 1, 2, 3 and 8 workers through the context rather than installing a pool, and still assert identical bits and identical charged work. The triangle fixture grew from 12,400 to 28,700 work units: below the 16,384-unit floor it would have passed without ever going parallel. The original kernels' exact-work-charge tests pass unchanged.

Numbers, and what they are worth

Sequential kernels, a million nodes and ten million random weighted arcs, no deadline, no concurrency requested, release, best of nine, one laptop. Per-entry was measured before and again after the metered runs and reproduced within 3%.

kernel per-entry charge_work metered change
dijkstra 690 ms 513 ms -26%
bfs 312 ms 203 ms -35%
dfs 358 ms 302 ms -16%
scc 682 ms 563 ms -17%
wcc 310 ms 186 ms -40%

This is a single-host probe on one synthetic graph, not the paired benchmark harness. The harness run has been requested in codex-to-codex.md and is what should be cited.

🤖 Generated with Claude Code

alexy added a commit that referenced this pull request Sep 20, 2026
Documentation only.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
alexy and others added 2 commits September 20, 2026 02:21
Step 5 of the order in codex-to-codex.md. Meter and width() are gone. The
partition helpers take a worker count read from the execution, run on the
calling thread at one worker without touching rayon, and otherwise run inside
the bounded pool for that count. Per-block workspaces own one meter each,
because creating a meter registers it under a lock. The determinism tests ask
for workers through the context instead of installing a pool, and the triangle
fixture grew to clear the sequential floor it would otherwise never leave.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The second half of step 5: item 3 of quegee's 03:05Z follow-ups. dijkstra,
shortestPaths, bfs, dfs, topologicalSort, scc, wcc and the shared MinHeap no
longer pay one compare-exchange on the shared counter per visited entry.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@alexy
alexy force-pushed the work/catalog-on-workmeter branch from 5e2ab8e to 5352909 Compare September 20, 2026 09:21
@alexy
alexy merged commit ad5b22d into main Sep 20, 2026
1 check passed
alexy added a commit that referenced this pull request Sep 20, 2026
…, sweep is sequential-only

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sak2FQcdgs5pkL2ruKrSUZ
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