Repository navigation
feat(diagnostics): attribute session actor authority payload bytes - #199767
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis 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. |
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
050f64d to
e608a06
Compare
e608a06 to
f3d7f7f
Compare
…penclaw#199767) * feat(diagnostics): attribute session actor authority payload bytes * feat(diagnostics): sample actor operations independently * feat(diagnostics): preserve metric budgets and profiling hooks
What Problem This Solves
Large session-actor worker→main authority payloads cannot currently be attributed to entries, transcript events, or other facts. Native admission graphs have no
payloadBytes, so the existing byte counter also omits them.User Impact
Operators get five fixed, numbers-only component labels for
session.actor.*operations. There are no new settings, identifiers in labels, wire changes, authority changes, stored-state changes, or model-request changes.Why This Change Was Made
The main-side admission owner independently samples complete operations with probability 1/128, retaining each decision across its admission and receipt frames. Independent sampling avoids aliasing alternating user/assistant appends; the regression supplies deterministic draws to verify the sampling boundary. Component sizing runs only for selected operations; nothing is added to worker-side capture or serialization. The existing memory snapshot carries cumulative numeric counters to two budgeted Prometheus families (64 byte-series and 128 sample-series slots). The aggregate cap grows by exactly those 192 reservations, to 16,576, preserving the existing shared allowance and golden scrape bytes.
Components use marginal V8 serialization sizes.
admission_entryremoves the full snapshot entry;receipt_entryremoves the postimage entry and complete entry-metadata receipts, including their small envelopes;receipt_eventsthen removes appended events and transcript authority receipts. The remaining facts, including append values and model-prompt projections, belong to*_other. Shared values belong to the last component still referencing them. Components sum exactly to sampled fact-payload sizes; transport framing and decision cells are excluded. Unsupported graphs increment unmeasured sample counts without affecting admission.The old
openclaw_worker_message_payload_bytes_totalseries is unchanged for comparisons with earlier builds. Admission facts now contribute to the new sampled family, not to that old total. Do not add the old and new series. Inspect sample counts and use longer windows when traffic is sparse. Rejected admissions may contribute bytes without receipts; oversized transferred outcomes remain admission-other.Runtime production delta: +157 lines. The requested non-test/non-doc diff totals +302 lines: +157 runtime, +143 existing benchmark/profiling tooling, and +2 test-budget allocation lines. This is the requested diagnostic addition, not an optimization. The existing append rig is extended rather than adding a benchmark framework. Independent review and merge are delegated to the coordinating maintainer as requested.
Evidence
Exact-head CI passed on
f3d7f7fb2af0dbe043a1af3f4ff8396fd238ba6a: 61 successful jobs, 25 skipped, no failures. The previously failing profiling and exporter shards both passed. Independent review and merge remain with the coordinating maintainer.Real synthetic SessionManager appends generated resident (2 sessions) and evicted (100 sessions, 486 observed byte-capacity evictions) frames. Both have four initial transcript rows, large skill/tool metadata, and user/assistant/tool-result appends. Native Worker replay uses the same captured frames for AB/BA and A/A arms within one process, with 8,192 warmup appends before every arm. Both workloads had mixed-sign CPU deltas, so one predeclared extra AB pair was retained for each; all three pairs contribute to the signed absolute mean. No production Gateway or Team load was started; no whole-Gateway load result is claimed.
Baseline counter source:
987c04a0086963d301cb4e440c758acc7178c7b6. The baseline adds only a measurement bridge invoking its originalrecordWorkerMessagecall, returningfalsefor sampling. The measured counter source is unchanged by the final rebase.Timing: 131,072 measured appends per arm per pair, 393,216 per revision per workload, plus the separate A/A control. Allocation: 32,768 resident and 16,384 evicted appends per revision in separate traced passes. Allocation means inspector-sampled main-isolate heap allocation, not total native allocation.
The signed main-CPU means are below the ≤3% target, but this is not a speedup claim: evicted timing is inconclusive at that precision. Main CPU A/A differences were −0.27% resident and −3.47% evicted; sender A/A differences were −0.88% and −3.67%. Allocation A/A differences were −1.30% and −0.75%, so the small allocation changes are context. Host load and every timing arm are below. Early short/unwarmed runs moved substantially with host load; an initial systematic sampler also aliased alternating message shapes. Those exploratory runs motivated warmup, independent sampling, and the declared extra-pair protocol rather than a performance rejection.
admission_entryadmission_otherreceipt_entryreceipt_eventsreceipt_otherThere were 3,064 resident and 3,121 evicted sampled append receipts, with no unmeasured component samples. The replay aggregates the mixed append fixtures under the appendTranscriptEvent class; production retains the broker's actual request class. Admissions dominate this evicted fixture; this does not establish the cause of the production receipt average.
Timing arms and host load
Focused validation: 76 tests passed across worker-message metrics, native admission/settlement, and Prometheus memory export; 14 prefix-stability tests passed. Import-closure and export-name-collision guards passed. Changed-file format/lint,
pnpm tsgo:test:root, and the infra test typecheck passed. The native MessagePort regression fails on unchanged main (zero component samples instead of two admission samples), passes with the change, and checks byte-identical received outcomes plus exact component sums for full-entry and reference admissions. The five exporter label sets each have a test; an exact test-line allocation is included. The final metrics, prefix-stability, and exporter run took 54.36 seconds including compiler preparation; the native admission/settlement suite also passed.CI exposed two integration misses, both corrected: the opt-in profiling source hook needed the new metrics signature, and the new family reservations needed matching aggregate capacity to avoid displacing existing series. All 23 exporter store/subscription tests pass with the original golden scrape hash unchanged. The profiling regression passes locally; its full file also hit an unchanged CPU-profile sample-count assertion (43 samples versus >50), recorded as a local proof limitation.
Reproduction uses
scripts/perf/session-append-receipt-measure.tswith--authority --compare-metrics-file <saved-baseline> --rows 4 --text-repeats 4,--sessions 2 --rounds 4for resident or--sessions 100 --rounds 2for evicted. Timing uses--mode timing --iterations 131072(and--extra-pairfor the declared third pair); separate allocation uses--mode allocation --iterations 16384(resident) or8192(evicted). Give each invocation its own--output .local/<run>directory. The script performs warmed AB/BA plus A/A and records frame counts, numeric component snapshots, CPU, GC, memory, allocation, source digests, and host load.Post-deploy bytes per append, by component:
Check coverage alongside it:
Baseline preparation for this pre-counter revision: