Repository navigation
perf(agents): reduce descendant-count allocation - #184566
Merged
steipete merged 1 commit intoOct 26, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
steipete
marked this pull request as ready for review
October 26, 2026 11:26
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
steipete
deleted the
steipete/perf-subagent-descendant-run-count-20261026
branch
October 26, 2026 11:46
This was referenced Oct 26, 2026
steipete
added a commit
that referenced
this pull request
Oct 26, 2026
…184698) Row presentation resolved each child session's controller by iterating that child's runs through the registry (iterator, closure and owner tuples per call), and countActiveDescendantRuns walked descendant runs on every list. On Team these were among the top selection-side allocation families (getSubagentRunsForChildSession, resolveSessionChildController, countDescendantRuns). The incremental registry run index (#183531) now keeps the latest matching controller per child session current through its existing update path, so presentation reads it directly. Descendant reads iterate the prepared buckets without per-call allocation, rebased on #184566, which already passes prepared descendants into countDescendantRuns. Results are identical; property tests cover status transitions, replacement runs and agent mismatches. Evidence, 11 interleaved pairs on AWS c7i.4xlarge: owner-resolution allocation 8.551 -> 1.645 MB/pass (-80.8%, 11/11), descendant reads 292.1 -> 72.8 KB (-75.1%, 11/11), whole-list allocation 4.446 -> 4.299 MB (-3.3%, 10/11); CPU inconclusive. Team-shape harness (20 measured minutes): handler mean 16.67 -> 16.88 ms, main CPU 12.49% -> 12.55%, GC flat, 40/40 turns, zero RPC errors; no regression under the rule. 174 tests pass. Runtime +45 LOC.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 27, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 27, 2026
…penclaw#184698) Row presentation resolved each child session's controller by iterating that child's runs through the registry (iterator, closure and owner tuples per call), and countActiveDescendantRuns walked descendant runs on every list. On Team these were among the top selection-side allocation families (getSubagentRunsForChildSession, resolveSessionChildController, countDescendantRuns). The incremental registry run index (openclaw#183531) now keeps the latest matching controller per child session current through its existing update path, so presentation reads it directly. Descendant reads iterate the prepared buckets without per-call allocation, rebased on openclaw#184566, which already passes prepared descendants into countDescendantRuns. Results are identical; property tests cover status transitions, replacement runs and agent mismatches. Evidence, 11 interleaved pairs on AWS c7i.4xlarge: owner-resolution allocation 8.551 -> 1.645 MB/pass (-80.8%, 11/11), descendant reads 292.1 -> 72.8 KB (-75.1%, 11/11), whole-list allocation 4.446 -> 4.299 MB (-3.3%, 10/11); CPU inconclusive. Team-shape harness (20 measured minutes): handler mean 16.67 -> 16.88 ms, main CPU 12.49% -> 12.55%, GC flat, 40/40 turns, zero RPC errors; no regression under the rule. 174 tests pass. Runtime +45 LOC.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Repeated session-list presentation allocates temporary iterator records and options while counting already-indexed subagent descendants. Each query window counts every requester candidate; overlapping display/filter consumers reuse that window's existing count map, but fresh windows repeat the allocations.
User Impact
Lower allocation and CPU in descendant-count reads, with unchanged active/pending counts, traversal order, generation selection, live-owner checks, and requester-settlement behavior. No protocol, configuration, schema, or recovery changes.
Why This Change Was Made
Read the frozen descendant-key array by index, carry its existing lookup result into the counter, and share the fixed active-only options. Keep one counting implementation and the existing per-window memoization. No incremental counters or new invalidation responsibility.
Related: #184152, closed unmerged as an experiment because its final hardware-dependent proof was unavailable. This is a narrow descendant-only change, excluding its controller-selection changes and settled-tree fast path. The current-main residual was reproduced; this is not an already-fixed claim.
Runtime delta: +7 LOC in one module. The small growth expresses direct indexed traversal and shared fixed options while preserving the common settlement-filter path; no new cache or lifecycle machinery. The benchmark is separate from runtime code. No shared perf README edits.
Evidence
Acceptance declared in the committed probe before comparison: lower sampled bytes/query, identical fixed checksums, and no consistent CPU regression. Synthetic in-memory owner workload: 10,000 retained runs, 2,000 requester roots, five children per root, 100 unended children. Each arm runs 3,000 fresh query windows / 6,000,000 count calls. Five alternating AB/BA pairs per mode; timing is untraced, collected-object allocation is a separate pass. Fixture construction and warmup are excluded; all bytes in the measured region are counted, including caller/window overhead. No frame-name attribution or allocation subtraction.
Base owner:
05a0dd8ee67f1896886198f81d25188f0304d18b, verified byte-identical to the measured baseline module. Same dependency tree and benchmark on both arms; baseline materialized with imports resolved to the same unchanged dependencies. Local single-process runs each take less than 30 seconds.Allocation ranges: base 425.81–427.94 B/query, candidate 138.53–141.73. CPU ranges: base 0.2405–0.2783 µs/query, candidate 0.1952–0.2345. Each mode measures 30 million queries per arm in total. Host one-minute load: 42.95–45.99 during timing and 38.95–43.49 during allocation; recorded per arm in JSON.
Reproduce on each revision:
The new work-count regression fails on main with
expected 2 to be 0; all other tests in that file pass. The iterator instrumentation is restored synchronously infinally. The focused query, read-context, and liveness-owner files pass 32 tests, including status/generation/move/removal churn, cycles, stale-time boundaries, and released-owner reads. Export collision guard and both closure guard files pass (26 tests). Focused run wall time: 95.57 s across two shards; query file execution is under one second. Closure guards: 62.24 s. Final query regression rerun: 19/19 tests, 46.95 s wall time. Changed-file formatting and lint pass. The standalone probe is registered as an exact Knip command entry; the repository-wide unused-file scan was not run under the local-compute restriction. Exact-head CI run 40315045711 completed successfully on68dd8daa0247ec9e238ee73204a3e93416720df9, including production/test typechecks, lint, affected tests, architecture guards, and baseline checks. GitHub Codex review also completed on that head with no findings.Review: independent subagent review (autoreview route unavailable). The Codex helper refused the requested route because it does not match operator configuration; configuration was left unchanged. The fresh independent P0–P2 review is clean with no actionable findings.
Scope of evidence: owner microbenchmark only. This removes temporary work while retaining ownership and liveness semantics; no multi-pair Gateway stress campaign was run. Whole-Gateway CPU, GC, RSS/heap, server-handler and client latency improvements are not claimed. No production load or runtime changes.