Repository navigation
perf(infra): keep worker reference transitions local - #184282
Merged
steipete merged 2 commits 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. |
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
force-pushed
the
steipete/perf-worker-control-plane-messages-20261026
branch
from
October 26, 2026 06:27
207e737 to
75208de
Compare
steipete
deleted the
steipete/perf-worker-control-plane-messages-20261026
branch
October 26, 2026 06:42
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 27, 2026
* perf(infra): keep worker reference transitions local * test(infra): use retained worker event contracts in proof
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
Retained workers send two unnecessary supervisor messages whenever a worker goes from idle to active and back to idle.
User Impact
No user-visible behavior change. Active work, pending CPU/heap samples, native cleanup, and process exit retain their existing host-owned liveness rules. Worker memory/GC sampling, retirement policy, and authority checks are unchanged.
Why This Change Was Made
The supervisor's control port stays referenced for its whole lifetime. Toggling its child Worker references therefore cannot change supervisor liveness. The host already references the supervisor and host control port from each handle's
needsReference. Remove the private reference command end to end instead of maintaining two reference owners.The prior same-state deduplication in #165230 is already in the measured deployment; these are the remaining actual idle/active transitions. Runtime production delta: −18 lines. The requested diff excluding tests/test-support/docs is +46 lines because the existing benchmark gains 64 net lines for the 42-worker workload and transport counters; runtime code itself is −18 lines. No new runtime state, configuration, or module is added.
Evidence
Acceptance: remove reference-only crossings, preserve local liveness/admission/cleanup, and reduce owner CPU/allocation without a material per-operation regression. Pure-deletion fast-path proof uses the real retained-worker owner; it does not claim a whole-Gateway latency improvement.
node --import ./scripts/tsx.mjs scripts/perf/native-control-port-measure.ts timing referencesRepeat with
allocation referencesfor a separate allocation pass. Both revisions use the same script, 42 actual retained workers, three warmup passes, and five measured passes of 5,000 ref/unref cycles (25,000 cycles per arm). Each pass ends in 42 FIFO echo barriers, so base messages are processed before measurement ends. Startup/retirement are outside the measurement. The final proof-code revision was measured candidate then base, with separate allocation runs; the initial base-then-candidate run likewise reduced CPU/allocation and counted the same eliminated messages.Node 26.12.1, macOS arm64. GC has only one sample per timing arm (no meaningful percentile); its absolute rise is 0.000012 ms/cycle. RSS is an end-of-run snapshot, not a retained-memory improvement claim. Memory polling, handler latency, and event-loop tails were not changed or measured. No production load test or multi-pair Gateway campaign: this scoped deletion uses the requested fast-path exception.
worker-native-task-port.test.tsfails on base0615124872cfbecause the two reference messages are present; passes with the deletion. It also preserves pending-sample retention, repeated fail-closed admission checks, and task-port-loss behavior.node scripts/run-vitest.mjs src/infra/worker-native-task-port.test.ts src/infra/worker-native-handle.test.ts src/infra/worker-native-lifecycle.test.ts src/infra/worker-message-metrics.test.ts --maxWorkers=1— 23 tests passed. Lifecycle file 21.07 s (includes existing 15.7 s late-attachment case); other three files 64.40 s including cold worker compilation, 107.81 s wrapper total.75208de5dc24975c4fb4b2b08e17e8e0a51ee715. Production, script, and test types; lint; Node shards; UI integration; guards; build artifacts; and docs passed. GitHub Codex review on this head also completed with no findings. No Testbox lease allocated. The first CI head exposed unsupported EventEmitter overloads in the new proof code; the fixtures now use the retained worker's documentedoncallbacks.pnpm tsgo:scriptspasses locally; runtime code is unchanged by that repair.