Skip to content

feat(diagnostics): attribute session actor authority payload bytes - #199767

Merged
steipete merged 3 commits into
mainfrom
steipete/diag-actor-authority-bytes-20261115
Nov 15, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/diag-actor-authority-bytes-20261115

Conversation

@steipete

@steipete steipete commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

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_entry removes the full snapshot entry; receipt_entry removes the postimage entry and complete entry-metadata receipts, including their small envelopes; receipt_events then 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_total series 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 original recordWorkerMessage call, returning false for sampling. The measured counter source is unchanged by the final rebase.

Workload / metric per append Base Candidate Change
Resident main boundary CPU, µs 28.275 28.760 +0.485 (+1.72%)
Resident sender CPU, µs 17.285 17.136 -0.149 (-0.86%)
Resident sampled heap allocation, bytes 19,873.654 19,571.834 -301.820 (-1.52%)
Evicted main boundary CPU, µs 147.305 146.872 -0.433 (-0.29%)
Evicted sender CPU, µs 85.061 82.702 -2.359 (-2.77%)
Evicted sampled heap allocation, bytes 346,961.860 347,535.728 +573.868 (+0.17%)

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.

Component bytes per sampled append Resident Evicted
admission_entry 0.00 263,191.78
admission_other 2,564.00 2,559.33
receipt_entry 20.00 20.00
receipt_events 1,622.06 1,715.03
receipt_other 3,314.00 3,317.44

There 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
Shape / arm Main CPU µs/append Sender CPU µs/append Host load, 1 minute
resident 1: base 30.204 18.635 35.32
resident 2: candidate 29.196 17.579 33.93
resident 3: candidate 28.866 17.251 32.58
resident 4: base 27.641 17.111 31.49
resident 5: base 27.515 17.102 30.49
resident 6: base 27.441 16.952 30.49
resident 7: base 26.980 16.110 20.86
resident 8: candidate 28.218 16.578 20.15
evicted 1: base 144.032 85.165 27.30
evicted 2: candidate 154.093 86.051 25.84
evicted 3: candidate 145.103 81.147 27.29
evicted 4: base 162.655 91.132 22.88
evicted 5: base 178.053 99.088 33.81
evicted 6: base 171.877 95.452 42.54
evicted 7: base 135.226 78.885 19.71
evicted 8: candidate 141.420 80.909 17.49

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.ts with --authority --compare-metrics-file <saved-baseline> --rows 4 --text-repeats 4, --sessions 2 --rounds 4 for resident or --sessions 100 --rounds 2 for evicted. Timing uses --mode timing --iterations 131072 (and --extra-pair for the declared third pair); separate allocation uses --mode allocation --iterations 16384 (resident) or 8192 (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:

sum by (component) (
  rate(openclaw_worker_authority_component_sampled_bytes_total{request_class="session.actor.appendTranscriptEvent"}[15m])
)
/
scalar(sum(rate(openclaw_worker_authority_component_samples_total{request_class="session.actor.appendTranscriptEvent",component="receipt_other",result="measured"}[15m])))

Check coverage alongside it:

sum by (component, result) (
  increase(openclaw_worker_authority_component_samples_total{request_class="session.actor.appendTranscriptEvent"}[15m])
)

Baseline preparation for this pre-counter revision:

git show 987c04a0086963d301cb4e440c758acc7178c7b6:src/infra/worker-message-metrics.ts > .local/base-worker-message-metrics.ts
cat >> .local/base-worker-message-metrics.ts <<'JS'
export function recordWorkerAuthorityMessage(message, requestClass) {
  recordWorkerMessage(
    message?.kind === "sqlite-database-admissions" ? "admission" : "authority",
    "from_worker",
    typeof message?.payloadBytes === "number" ? message.payloadBytes : undefined,
    requestClass,
  );
  return false;
}
JS

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts extensions: diagnostics-prometheus labels Nov 15, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T21:54:20.595558Z f3d7f7f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete marked this pull request as draft November 15, 2026 21:18
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 15, 2026
@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 050f64d8e1ccb8de2609a3f7b71e9d832c3cfe00, but the PR head is now e608a06b8edf8454095bbbbc416dced08eb63b08. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-15T21:34:15.653Z sha 050f64d :: needs changes before merge. :: [P2] Update the Gateway profiler instrumentation for the new call shape

@steipete
steipete force-pushed the steipete/diag-actor-authority-bytes-20261115 branch from 050f64d to e608a06 Compare November 15, 2026 21:37
@steipete
steipete marked this pull request as ready for review November 15, 2026 21:38
@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 15, 2026
@steipete
steipete force-pushed the steipete/diag-actor-authority-bytes-20261115 branch from e608a06 to f3d7f7f Compare November 15, 2026 21:51
@steipete
steipete merged commit f541dcc into main Nov 15, 2026
157 of 159 checks passed
@steipete
steipete deleted the steipete/diag-actor-authority-bytes-20261115 branch November 15, 2026 22:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…penclaw#199767)

* feat(diagnostics): attribute session actor authority payload bytes

* feat(diagnostics): sample actor operations independently

* feat(diagnostics): preserve metric budgets and profiling hooks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: diagnostics-prometheus gateway Gateway runtime P2 Normal backlog priority with limited blast radius. scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant