Skip to content

perf(sessions): transfer changed fields for warm entry patches - #183276

Merged
steipete merged 1 commit into
mainfrom
perf/lane1714-session-entry-patch-transfer
Oct 25, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/lane1714-session-entry-patch-transfer

Conversation

@steipete

@steipete steipete commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Performance decision: land the measured patch-owner allocation reduction with passing untraced costs. Candidate promotion remains unproven because identical-source calibration is unstable; it is not reported as passed.

The repeatable benefit is 12.2–24.3% less main-thread allocation per patch and 86.0% fewer transferred bytes per patch. Two twenty-minute concurrent, CPU-swapped Gateway comparisons followed four successful matching untraced controls: mean main CPU +0.109 percentage points, GC −10.636 ms/min, event-loop p99 −0.197 ms, and sessions.list p99 +0.598 ms. No valid-control rejection threshold was triggered. This is an owner-local allocation improvement, not a claim of a whole-Gateway speedup.

Promotion attribution is a limitation: four ten-minute identical-source controls were inconclusive; the first two longer controls still varied +62.552% and +7.777%. After the first longer result, before the second result, the campaign was explicitly bounded to finish control 2 and stop at two of four planned longer controls. No candidate promotion comparison ran. All completed observations are retained below. The landing decision relies on the repeatable scoped allocation benefit, proven correctness, and valid untraced comparisons; unreliable promotion attribution remains an explicit limitation rather than evidence of a candidate regression. Exact-head CI is green.

What Problem This Solves

Warm session metadata patches repeatedly transfer and decode unchanged session-entry snapshots on the Gateway thread.

User Impact

Internal allocation reduction with the existing session contents, write ordering, authority checks, and mutable return-value contract preserved.

Why This Change Was Made

The writer validates the existing resident entry’s scoped revision before returning changed fields and removals. The receiver restores the complete publication before admission, reuses unchanged frozen fields, and copies only mutable JSON containers for caller results. Cold or superseded preimages still require a complete postimage.

Production code grows by 131 lines to preserve revision validation, bounded publication, and independently mutable results. The change uses the existing replica and invalidation owner.

Evidence

The wire-size regression fails on the pinned baseline (133,553 bytes for a synthetic 128 KiB snapshot). All 35 focused patch/operation/settlement tests pass on the final candidate, including newer writes, field removal, and nested object/array result isolation. Changed-file formatting/lint pass. Production/test typechecks and the full applicable PR CI passed on exact head b23f329e21a03edc15f92eac49cc5ab5cf6284e8. Independent subagent review (autoreview route unavailable) has no remaining actionable findings.

Fixed-work native-worker measurements use 256 patches after cold setup and 32 warmups, a 60 KiB retained snapshot, fresh isolated state, and counterbalanced launch order. Timing and allocation sampling are separate. Whole-main allocation includes reconstruction and mutable-result copying:

Return mode Baseline bytes/patch Candidate bytes/patch Paired allocation change Mean main CPU change
No result 395,124 347,034 −12.2% −0.101 ms/patch
Mutable entry 462,055 349,674 −24.3% +0.046 ms/patch

CPU differences vary between runs; the repeatable claim is reduced allocation in the patch owner, not a whole-Gateway speedup. The unchanged no-result path reuses its prior paired measurement.

Sustained local proof used separate base and candidate dev Gateways with 10,000 synthetic sessions, 8,000 settled runs, 40 plugins, 65 WebSocket clients, four concurrent mock-provider turns with tool calls, and sidebar/list/search plus metadata churn. Each untraced timing run and separate allocation run completed 40 cohorts and at least ten minutes. Normal resets and maintenance stayed enabled. Both timing runs completed 160 turns, 160 tool calls/results, and 40 metadata patches.

Local untraced metric Baseline Candidate
Duration 651.8 s 712.4 s
Main-thread CPU 30.41% 29.46%
GC 1.425 s/min 2.122 s/min
Event-loop p99 98.37 ms (25,277 samples) 124.26 ms (25,164 samples)
sessions.list p95 / p99 172.60 / 468.30 ms (4,312 calls) 216.33 / 534.25 ms (4,743 calls)
Maximum GC pause 305.89 ms 296.66 ms
Final RSS / heap 3.795 GB / 693.9 MB 3.898 GB / 703.6 MB
Peak RSS / heap 4.296 GB / 758.5 MB 4.417 GB / 896.1 MB

These sequential runs on a heavily shared Mac retain adverse GC/latency signals and differing background-work counts; they do not establish a Gateway-wide speedup or regression. The subsequent twenty-minute controlled protocol passed four A/A controls and two CPU-swapped candidate comparisons, reported below. Promotion remains separately unresolved. Local measurements are pinned to 728cdc0; the paired application builds use a939b1d.

Separate long allocation captures lasted 646.8 / 792.3 seconds. Sampled allocation rates were 94.81 / 87.42 MiB/s, but total allocation was 64.30 / 72.63 GB with 4,262 / 5,245 list calls and 21 / 26 cron runs. The lower rate is not a net-workload reduction claim. Patch replies carried 91,947,641 bytes over 1,379 transfers versus 13,357,729 over 1,428: 66,677 → 9,354 bytes per patch (−86.0%). Whole-main owner sampling above includes reconstruction and result-container copying.

The benchmark command shape is in the script header. The latest conflict integration incorporates main 4d13deccf923c9e5470a787a885e6736c62f9b7f. All three production files remain byte-identical to measured V2. Upstream now owns list-filter scheduling, metadata churn, request timestamps and whole-run CPU reporting; this PR removes its duplicate harness code and retains filter-coverage counters plus nonmixed-soak admission. Independent integration review is clean. All 35 focused tests passed after the harness conflict integration (190 seconds), and changed-script lint/format passed. A subsequent conflict-free rebase adds a private JSON title-refinement record and unrelated changes; independent review confirmed compatibility with the existing delta and mutable-copy contract. CI run 40175480685 passed on exact head b23f329e21a03edc15f92eac49cc5ab5cf6284e8: 41 successful jobs, 26 skipped, no failures. No schema or public configuration change.

Original 10-minute controlled Linux comparisons used synchronized post-warm starts, 16 interleaved CPUs per arm, reversed launch order and CPU assignment in pair 2, and fresh identical fixtures. Every arm completed 160 turns/tool calls/results, 40 metadata patches, and 20 successful cron runs in 600 seconds. No guard failure occurred. A port-preflight setup attempt before pair 2 was stopped before measurement; both fixtures were regenerated and new ports selected.

Untraced metric Pair 1 baseline → candidate Pair 2 baseline → candidate Mean absolute change
Main CPU 21.56 → 22.42 23.27 → 22.90 +0.24 pp
GC s/min 0.59055 → 0.62015 0.64754 → 0.62893 +0.00549
Event-loop p99 (ms) 43.975 → 45.056 (n=28,281/28,173) 45.482 → 45.548 (n=28,139/28,187) +0.573 ms
List p95 (ms) 46.227 → 48.411 (n=3,516/3,508) 47.450 → 47.492 (n=3,630/3,606) +1.113 ms
List p99 (ms) 65.557 → 71.628 (n=3,516/3,508) 74.896 → 72.418 (n=3,630/3,606) +1.797 ms
Final RSS 4.138 → 4.193 GB 4.317 → 4.189 GB -36.4 MB
Final heap 724.193 → 759.681 MB 774.215 → 722.535 MB -8.1 MB
Maximum GC pause (ms) 57.185 → 60.719 59.443 → 53.438 −1.235 ms

Paired mean relative deltas are main CPU +1.19%, GC +1.07%, loop p99 +1.30%, and list p99 +2.98%. CPU, GC, and list-p99 deltas have mixed signs. No candidate rejection threshold is triggered by these A/B pairs, but identical-source controls subsequently produced a false latency rejection signal. These remain valid observations under an inconclusive protocol, not landing evidence. The repeatable benefit remains owner allocation and wire size.

Per-kind GC and workload counts for the two untraced pairs
Pair / arm / kind Collections Total ms p95 / p99 ms Maximum ms
1 / base / minor 1935 4401.157 3.438 / 4.862 7.782
1 / base / incremental 46 58.583 1.606 / 1.990 1.990
1 / base / major 46 1445.795 54.270 / 57.342 57.185
1 / candidate / minor 2005 4493.359 3.278 / 4.990 9.446
1 / candidate / incremental 53 62.666 1.550 / 1.734 1.794
1 / candidate / major 53 1645.525 49.406 / 51.966 60.719
2 / base / minor 2038 4843.288 3.630 / 5.246 50.804
2 / base / incremental 51 66.903 1.734 / 1.998 2.008
2 / base / major 51 1565.229 51.454 / 52.990 59.443
2 / candidate / minor 2027 4760.878 3.566 / 5.278 7.765
2 / candidate / incremental 48 64.301 2.062 / 3.358 3.349
2 / candidate / major 48 1464.111 47.102 / 53.502 53.438

Major/incremental tails have fewer than 200 samples and are context only. Filter counts follow the script’s seven fixed shapes; index 3 is search.

  • Pair 1: baseline [503, 491, 516, 513, 506, 514, 473]; candidate [498, 493, 515, 509, 505, 515, 473].
  • Pair 2: baseline [519, 508, 533, 530, 528, 526, 486]; candidate [513, 505, 530, 524, 524, 525, 485].

The original identical-source controls exposed list-p99 instability: control 2 measured 93.773 versus 193.482 ms with unchanged code. Its largest delays cluster in one cohort around 108–112 seconds on both arms; cohort GC maxima were only 31.992/24.134 ms. The single shared-guard warning did not interrupt the run, so the full window and every slow request are retained. This is protocol noise, not candidate rejection.

Before collecting any revised result, the untraced protocol was fixed at 80 cohorts / minimum 1,200 seconds, with all other source, fixture, workload, pacing, warmup, maintenance, instrumentation, CPU-placement and start-barrier settings unchanged. Four new A/A controls preceded two new swapped A/B pairs. The separate initial trace-only promotion protocol planned four matching A/A controls and two A/B pairs at 40 cohorts/600 seconds; its controls proved inconclusive, so no traced candidate comparisons ran. Timing is never compared across modes.

Original identical-source controls, retained without exclusions
Metric Control 1 A → B Control 2 A → B
Main CPU % 22.051 → 22.056 24.652 → 25.027
GC s/min 0.61911 → 0.60882 0.66132 → 0.70006
Loop p99 ms 44.007 → 44.663 (n=28,286/28,256) 47.055 → 46.563 (n=28,004/27,856)
List p99 ms 69.201 → 74.498 (n=3,533/3,534) 93.773 → 193.482 (n=3,552/3,555)
List maximum ms 337.586 → 274.674 (n=3,533/3,534) 1532.531 → 3584.676 (n=3,552/3,555)

Each arm completed 160 primary turns/tool calls/results, 40 metadata patches, and 20 successful cron runs. Both sides of control 2 also recorded 560 total model-stream requests, including 240 utility requests.

Control / arm / GC kind Collections Total ms p95 / p99 ms Maximum ms
1 / A / minor 2011 4485.393 3.310 / 5.182 8.407
1 / A / incremental 53 64.520 1.558 / 1.630 1.763
1 / A / major 53 1641.222 51.710 / 54.014 60.083
1 / B / minor 2019 4537.103 3.342 / 4.862 7.135
1 / B / incremental 46 58.243 1.734 / 1.846 1.839
1 / B / major 46 1492.928 52.222 / 59.390 59.371
2 / A / minor 2034 4962.568 3.646 / 5.406 10.887
2 / A / incremental 51 67.727 1.750 / 1.830 2.578
2 / A / major 51 1586.063 49.406 / 55.550 59.133
2 / B / minor 2124 5616.514 4.014 / 6.206 24.134
2 / B / incremental 39 59.463 2.478 / 2.846 2.831
2 / B / major 39 1329.660 56.830 / 67.070 66.675

Major/incremental tails remain context only because their counts are below 200; major-GC comparisons are contextual where either side has fewer than 50 collections. All aggregate GC remains included.

Prior-head CI attribution: CI run 40164788599 on head f9641d4912992ff8070affaec5f4c8d30ff83958 had an inherited failure in checks-node-compact-small-2: test/scripts/check-deadcode-exports.test.ts → “models exact generated and module-hook named consumers.” The expected Doctor import is absent from the audit's generated consumer text. Running that single file reproduces the identical assertion on the PR head and CI's unchanged main parent 86a37d7f443601011923069fbc0edd5bdb5c45b7 (16 passed / 1 failed on each). The failing parser/test/Doctor producer are unchanged by this PR; the cached optional-module import form came from #183208. The inherited audit issue was subsequently fixed on main in #183272 (418c2ba3b39200ba38e14da0c28b2e1e2cb1abe0), verified merged; no fix was copied into this branch. The CI run completed with 39 successful jobs, 26 skipped jobs, this inherited failed job, and its downstream CI gate. All three PostgreSQL conformance shards passed. Security-sensitive review and security-fast passed; no CI rerun was requested.

Prior-head CI attribution: run 40170808009, head 9b0a2f948cfb6ea6c984035597f367a732ca20c9, has an unrelated intermittent failure in test/scripts/gateway-bench-profile.test.ts: “separates discarded allocation churn from retained objects and cleans up failed captures” expected zero retained bytes under an allocation function and observed 32,832. The single file passed five times on the PR head and five times on CI’s exact unchanged main parent 6a628215b3607629cbc68885d7e307259eff6a5a, 15 tests per run, locally on Node 26.12.1/macOS; CI used Node 24.22.1/Linux. These replays establish same-host consistency, not an exact CI-environment reproduction. The test, profile helper/preload, worker profiler and diagnostics are byte-identical. Its standalone Node fixture creates no worker, imports no session-patch implementation, and cannot use the added message label. This meets the campaign’s unrelated-flake attribution rule; passing replays do not claim to fix the intermittent assertion. The failed profile was not retained by CI, so the exact retained object remains unknown. No assertion was weakened and no CI rerun was requested.

Run 40170808009 finished with 39 successful jobs, 26 skipped jobs, the profiling-test failure, and its downstream CI gate. All PostgreSQL conformance shards and security checks passed. The automated failure table marks the job “new” because the matching scheduled-main job passed and selected scope was not compared; the explicit source-path inspection and five-per-side replays above supply the unrelated-flake attribution.

Four completed 20-minute control pairs and eligibility

Longer-window identical-source controls

Both arms used application base a939b1d4e0f26c827dd17028d2cb899a1ea20247, Node 26.12.1, and the identical reviewed harness (415dae8c18e853e0e8c7fd0bd03f49866b6916d5777e99ed147e8e1b9c4a1388). These are four fresh A/A controls, not candidate measurements. Each ran 80 fixed cohorts with a minimum 1,200-second natural-GC window after 60-second warmup, a common start barrier, and counterbalanced launch order and interleaved 16-CPU placements. Normal maintenance stayed enabled; all samples and maxima are retained. The earlier 40-cohort controls remain separately reported as inconclusive.

Within each cell, values are first arm / second arm. Percentile counts are shown alongside tails.

Pair Measured seconds Main CPU % GC s/min Loop p99 ms (n) List p95 / p99 ms (n) Max GC / loop / list ms
1 1200.000 / 1200.001 21.547 / 21.552 0.630549 / 0.611930 44.138 (56,474) / 44.040 (56,498) 45.413, 67.611 (7,043) / 46.737, 67.383 (7,041) 54.213, 118.096, 286.790 / 65.409, 127.992, 336.501
2 1200.001 / 1200.002 22.287 / 22.213 0.666298 / 0.661263 44.302 (56,402) / 45.416 (56,400) 46.933, 68.724 (7,085) / 47.352, 72.626 (7,050) 66.348, 109.380, 287.408 / 59.322, 128.057, 329.325
3 1200.002 / 1200.001 22.620 / 22.561 0.626256 / 0.637583 45.056 (56,370) / 45.744 (56,322) 48.735, 74.164 (7,060) / 48.341, 77.194 (7,072) 97.757, 180.617, 257.274 / 57.200, 188.350, 307.806
4 1203.448 / 1202.787 23.693 / 23.995 0.635559 / 0.679550 47.677 (56,108) / 47.186 (55,975) 50.574, 79.005 (7,215) / 51.620, 86.858 (7,349) 89.770, 179.962, 371.914 / 79.936, 184.287, 397.700
Window Main CPU delta, pp (%) GC delta, ms/min (%) Pooled GC ms/turn Loop p99 delta, ms (%) List p99 delta, ms (%) List p95 delta, ms (%)
1–2 -0.034086 (-0.153%) -11.826876 (-1.854%) 40.526494 / 39.787337 +0.507904 (+1.146%) +1.836699 (+2.670%) +0.871967 (+1.905%)
3–4 +0.121413 (+0.507%) +27.659103 (+4.365%) 39.488803 / 41.209749 +0.098304 (+0.248%) +5.441255 (+7.012%) +0.326408 (+0.631%)
Pair Main CPU delta, pp (%) GC delta, ms/min (%) Loop p99 delta, ms (%) List p99 delta, ms (%) List p95 delta, ms (%)
1 +0.005213 (+0.024%) -18.618767 (-2.953%) -0.098304 (-0.223%) -0.228229 (-0.338%) +1.324277 (+2.916%)
2 -0.073384 (-0.329%) -5.034985 (-0.756%) +1.114112 (+2.515%) +3.901627 (+5.677%) +0.419657 (+0.894%)
3 -0.059276 (-0.262%) +11.327772 (+1.809%) +0.688128 (+1.527%) +3.030118 (+4.086%) -0.393484 (-0.807%)
4 +0.302101 (+1.275%) +43.990434 (+6.922%) -0.491520 (-1.031%) +7.852392 (+9.939%) +1.046300 (+2.069%)

Both control windows remain below the declared paired rejection thresholds. All four pairs completed without shared-guard warnings. No maximum GC pause exceeded max(50 ms, twice the first-arm maximum). This screen does not establish absence of regression; candidate comparisons remain separate. Both GC time/minute and GC/primary-turn are reported; background work is counted separately. The ordinary paired relative thresholds pass, so the absolute-floor distinction does not affect this verdict. No whole-Gateway allocation reduction is inferred from owner microbenchmarks.

Paired deltas are second minus first; percentage values are the mean of the two paired relative deltas, not a ratio chosen after the result. Pooled GC/work is summed untrimmed GC time divided by summed completed turns. Major-GC pause percentiles remain context when their collection counts are below the general tail-sample minima (p95: 200; p99: 1,000). Sub-millisecond pause-tail changes are context under v5.3.

Pair GC kind Count Total ms p95 ms p99 ms Max ms
1 Minor 4064 / 3892 9904.488 / 9089.579 3.630 / 3.374 5.086 / 4.958 8.716 / 7.816
1 Major 84 / 98 2593.201 / 3030.261 45.822 / 52.478 51.966 / 65.278 54.213 / 65.409
1 Incremental 84 / 98 113.285 / 118.771 2.030 / 1.590 2.142 / 1.806 2.563 / 2.021
2 Minor 4075 / 4085 9870.444 / 9881.231 3.694 / 3.774 5.630 / 5.694 28.063 / 10.351
2 Major 104 / 101 3321.074 / 3209.642 49.662 / 52.990 56.574 / 59.390 66.348 / 59.322
2 Incremental 104 / 101 134.464 / 134.412 1.894 / 1.958 2.254 / 2.190 2.311 / 2.240
3 Minor 3877 / 3999 9210.843 / 9510.081 3.566 / 3.726 5.470 / 5.726 32.209 / 9.881
3 Major 108 / 100 3175.520 / 3110.148 48.126 / 47.358 65.278 / 53.758 97.757 / 57.200
3 Incremental 108 / 100 138.765 / 131.447 1.614 / 1.854 1.958 / 1.966 2.211 / 2.103
4 Minor 3884 / 4103 9770.768 / 10774.708 4.014 / 4.318 7.262 / 7.230 54.007 / 79.936
4 Major 83 / 78 2843.075 / 2717.237 50.686 / 56.318 66.046 / 67.582 89.770 / 72.677
4 Incremental 83 / 78 133.864 / 130.618 3.214 / 3.134 5.086 / 3.598 5.384 / 5.155
Pair Primary turns / tool calls / tool results Total model requests Utility model requests Metadata patches Successful cron List filter counts
1 (320, 320, 320) / (320, 320, 320) 1090 / 1086 450 / 446 80 / 80 40 / 40 1009, 983, 1021, 1013, 1008, 1019, 990 / 1005, 986, 1022, 1011, 1003, 1024, 990
2 (320, 320, 320) / (320, 320, 320) 1092 / 1091 452 / 451 80 / 80 40 / 40 1017, 987, 1029, 1016, 1019, 1024, 993 / 1008, 981, 1025, 1013, 1012, 1019, 992
3 (320, 320, 320) / (320, 320, 320) 1092 / 1091 452 / 451 80 / 80 40 / 40 1012, 986, 1020, 1018, 1015, 1018, 991 / 1017, 984, 1025, 1018, 1017, 1022, 989
4 (320, 320, 320) / (320, 320, 320) 1059 / 1072 419 / 432 80 / 80 40 / 40 1042, 1009, 1050, 1028, 1026, 1040, 1020 / 1067, 1027, 1068, 1043, 1053, 1055, 1036

Filter order: unfiltered, active, archived, search, agent, exclude subagents, exclude system/cron. Background request counts are observed rather than assumed equal.

Pair Final RSS MiB Peak RSS MiB Final heap-used MiB Peak heap-used MiB
1 4289.562 / 4089.516 4429.910 / 4358.414 777.383 / 704.678 1291.959 / 811.058
2 4284.445 / 4129.941 4284.445 / 4391.801 984.175 / 803.403 984.175 / 960.903
3 4022.285 / 4046.926 4271.262 / 4278.914 683.244 / 714.397 758.860 / 968.579
4 2799.328 / 2748.730 4317.773 / 4409.000 708.032 / 734.499 835.553 / 1505.550

Measurement provenance: the remote experiment retains the committed harness from f9641d4912992ff8070affaec5f4c8d30ff83958, SHA-256 415dae8c18e853e0e8c7fd0bd03f49866b6916d5777e99ed147e8e1b9c4a1388, on both arms. Later upstream harness changes alter churn scheduling; current-head script runs must not be presented as reproducing those exact work counts. The frozen application base remains a939b1d4e0f26c827dd17028d2cb899a1ea20247; comparisons are prior-base evidence, not a newly built latest-main measurement.

Completed 20-minute candidate comparisons

Longer-window candidate comparisons

Both arms used application base a939b1d4e0f26c827dd17028d2cb899a1ea20247, Node 26.12.1, and the identical reviewed harness (415dae8c18e853e0e8c7fd0bd03f49866b6916d5777e99ed147e8e1b9c4a1388). The second arm contains the reviewed three-file session-entry patch change. Two fresh A/B pairs followed four successful identical-source controls. Each ran 80 fixed cohorts with a minimum 1,200-second natural-GC window after 60-second warmup, a common start barrier, and counterbalanced launch order and interleaved 16-CPU placements. Normal maintenance stayed enabled; all samples and maxima are retained. The earlier 40-cohort protocol remains separate inconclusive evidence. The application and harness were sealed before subsequent rebases; this is measured-source proof, not an exact-current-head build.

Within each cell, values are baseline / candidate. Percentile counts are shown alongside tails.

Pair Measured seconds Main CPU % GC s/min Loop p99 ms (n) List p95 / p99 ms (n) Max GC / loop / list ms
1 1201.977 / 1200.001 21.377 / 21.357 0.617008 / 0.579531 44.040 (56,739) / 44.368 (56,617) 46.033, 70.507 (6,981) / 46.057, 70.432 (6,981) 68.850, 127.468, 359.349 / 60.895, 156.238, 364.677
2 1200.002 / 1200.001 20.952 / 21.190 0.582306 / 0.598512 43.778 (56,546) / 43.057 (56,507) 44.699, 64.561 (7,022) / 45.470, 65.831 (7,027) 59.976, 105.382, 277.885 / 56.535, 126.616, 287.225
Window Main CPU delta, pp (%) GC delta, ms/min (%) Pooled GC ms/turn Loop p99 delta, ms (%) List p99 delta, ms (%) List p95 delta, ms (%)
1–2 +0.108856 (+0.520%) -10.635650 (-1.645%) 37.510354 / 36.813866 -0.196608 (-0.451%) +0.597685 (+0.931%) +0.397422 (+0.888%)
Pair Main CPU delta, pp (%) GC delta, ms/min (%) Loop p99 delta, ms (%) List p99 delta, ms (%) List p95 delta, ms (%)
1 -0.019826 (-0.093%) -37.476895 (-6.074%) +0.327680 (+0.744%) -0.074852 (-0.106%) +0.024168 (+0.053%)
2 +0.237539 (+1.134%) +16.205595 (+2.783%) -0.720896 (-1.647%) +1.270223 (+1.967%) +0.770677 (+1.724%)

The untraced paired cost screen does not trigger a rejection threshold: main CPU is effectively neutral, mean GC time is lower, and both loop/list paired mean tail shifts are below 1 ms. No maximum GC pause exceeds max(50 ms, twice baseline). The ordinary paired latency relative thresholds pass without relying on a whole-Gateway benefit of at least 10%. These are scoped natural-GC timing results; allocation and promotion are separate experiments. Both GC time/minute and GC/primary-turn are reported; background work is counted separately. The ordinary paired relative thresholds pass, so the absolute-floor distinction does not affect this verdict. No whole-Gateway allocation reduction is inferred from owner microbenchmarks.

Pair GC ms/primary-turn, baseline / candidate Signed delta ms/primary-turn (%)
1 38.626532 / 36.220735 -2.405797 (-6.228%)
2 36.394176 / 37.406997 +1.012820 (+2.783%)

With equal primary-turn counts, pooled GC/primary-turn changes by -0.696488 ms (-1.857%), from 37.510354 to 36.813866. This is a cost ratio, not a pooled percentile.

Paired deltas are second minus first; percentage values are the mean of the two paired relative deltas, not a ratio chosen after the result. Pooled GC/work is summed untrimmed GC time divided by summed completed turns. Major-GC pause percentiles remain context when their collection counts are below the general tail-sample minima (p95: 200; p99: 1,000). Sub-millisecond pause-tail changes are context under v5.3.

Pair GC kind Count Total ms p95 ms p99 ms Max ms
1 Minor 3916 / 3861 9247.254 / 8747.432 3.582 / 3.342 5.502 / 5.342 52.838 / 55.433
1 Major 96 / 92 2990.323 / 2728.666 50.174 / 42.494 54.782 / 52.990 68.850 / 60.895
1 Incremental 96 / 92 122.914 / 114.538 1.694 / 1.654 2.022 / 1.766 2.107 / 1.938
2 Minor 3838 / 3853 8626.389 / 8709.685 3.310 / 3.358 4.958 / 5.054 7.408 / 7.809
2 Major 98 / 112 2901.192 / 3131.071 49.662 / 41.726 52.222 / 52.222 59.976 / 56.535
2 Incremental 98 / 112 118.555 / 129.483 1.638 / 1.526 1.790 / 1.814 1.823 / 1.916
Pair Primary turns / tool calls / tool results Total model requests Utility model requests Metadata patches Successful cron List filter counts
1 (320, 320, 320) / (320, 320, 320) 1059 / 1085 419 / 445 80 / 80 40 / 40 989, 980, 1020, 1004, 997, 1009, 982 / 993, 978, 1018, 1002, 1001, 1010, 979
2 (320, 320, 320) / (320, 320, 320) 1089 / 1092 449 / 452 80 / 80 40 / 40 1008, 981, 1014, 1012, 1005, 1018, 984 / 1005, 982, 1017, 1011, 1010, 1016, 986

Filter order: unfiltered, active, archived, search, agent, exclude subagents, exclude system/cron. Background request counts are observed rather than assumed equal.

Pair Final RSS MiB Peak RSS MiB Final heap-used MiB Peak heap-used MiB
1 4065.039 / 4019.711 4278.039 / 4293.617 713.123 / 727.323 976.902 / 816.311
2 4192.086 / 4022.031 4290.047 / 4336.102 733.684 / 691.751 816.978 / 738.380
Promotion calibration and predeclared longer experiment

The separate 40-cohort/minimum-600-second trace-only controls expose unresolved between-process promotion variability. Control 1 promoted 3,861,853,872 / 3,459,495,816 bytes; control 2 promoted 7,231,817,384 / 3,543,770,640 bytes (−51.0%); control 3 promoted 4,494,800,912 / 5,919,450,728 bytes (+31.7%). Every arm completed 160 primary turns/tool calls/results, 560 total model requests, 40 metadata patches, and 20 successful cron runs. Control 4 completed the original declared set; all four results are retained below. These are identical-source controls, not candidate comparisons.

A bounded inspection of control 2 reproduced the canonical main-isolate totals, verified the capture markers, and found no worker contamination or startup spill. Excess spans all ten time bins. Both arms had four warmup cohorts, the same runtime flags and baseline-GC preparation, and barrier releases 1 ms apart. Setup/warmup allocation and promotion were similar. During capture, scavenge allocation was 58.476 / 53.973 GB, scavenge promotion 6.162 / 2.896 GB, and major-collection promotion 1.069 / 0.648 GB. Nursery capacity was predominantly 32 MiB on both sides. Survival behavior differed persistently; its cause remains unproven. No sample was removed or normalized by GC count.

Before any result from a longer traced experiment, freeze 80 cohorts / minimum 1,200 seconds, 320 primary turns/tool calls/results. Keep all other traced-mode inputs, source and harness hashes, Node version, fixtures, pacing, 60-second warmup, maintenance, pre-warm isolate-identification GC, post-warm baseline GC, and common start barrier unchanged. Both preparation collections stay outside capture. Use four fresh A/A controls before two fresh swapped A/B comparisons; no candidate run uses the unstable short protocol. Retain every valid result and all background-work counts, counterbalance launch order/CPU placement, and apply the existing guard and v5–v5.6 thresholds unchanged. Trace parsing follows process exit and stdout drain. Traced timing never replaces the passing untraced cost evidence.

This is the first longer calibration for the separately traced mode under v5.4, not a claim that longer duration will cure the observed variability. If the longer controls remain inconclusive, stop before candidate runs or another redesign and report the unresolved promotion gate. Prior short controls remain separate evidence. Independent review confirmed this protocol before launch.

All four short promotion controls, retained as inconclusive

First trace-only promotion controls — inconclusive

Four fresh identical-source controls used 40 cohorts / minimum 600 seconds with trace-GC only, the same pinned application/harness and preparation/barrier. All completed without guard warnings. Timing and pause metrics from these traced runs are attribution-only. The protocol is inconclusive because substantial identical-source promotion variation remains unresolved regardless of its direction; no candidate comparison used this mode. All data is retained.

Values are first arm / second arm; MB is decimal 1,000,000 bytes.

Pair Promoted bytes MB/primary-turn Signed delta MB/turn (%) Main trace GC count Excluded worker GC count List calls Total / utility model requests
1 3,861,853,872 / 3,459,495,816 24.136587 / 21.621849 -2.514738 (-10.419%) 2,005 / 1,996 5,360 / 5,563 3,527 / 3,533 560 / 240 ; 560 / 240
2 7,231,817,384 / 3,543,770,640 45.198859 / 22.148567 -23.050292 (-50.998%) 2,239 / 1,979 5,506 / 5,468 3,583 / 3,525 560 / 240 ; 560 / 240
3 4,494,800,912 / 5,919,450,728 28.092506 / 36.996567 +8.904061 (+31.696%) 2,053 / 2,130 5,475 / 5,312 3,531 / 3,546 560 / 240 ; 560 / 240
4 4,105,848,304 / 3,536,041,056 25.661552 / 22.100257 -3.561295 (-13.878%) 2,027 / 1,989 5,413 / 5,396 3,550 / 3,544 560 / 240 ; 559 / 239

Every arm completed 160 primary turns, 160 tool calls/results, 40 metadata patches and 20 successful cron runs. Background request counts are observed, not assumed equal.

Window 1–2: mean signed delta −12.782515 MB/turn; mean paired relative delta −30.708%; pooled promotion 34.667723→21.885208 MB/primary-turn. These directional summaries do not make the unresolved control sensitivity valid.
Window 3–4: mean signed delta +2.671383 MB/turn; mean paired relative delta +8.909%; pooled promotion 26.877029→29.548412 MB/primary-turn. These directional summaries do not make the unresolved control sensitivity valid.

A bounded read of control 2 reproduced the canonical main-isolate totals and boundaries. Its excess spans all ten 60-second bins, with no worker contamination or startup spill. Setup/warmup flags, four warmup cohorts, preparation collection and barrier match. During capture, median new-space capacity is 32 MiB on both arms, while allocation and survival differ persistently. The cause is unresolved; a longer window is not a demonstrated cure. The separately declared first longer traced calibration retains this evidence and changes only fixed duration/work; its result and bounded early-stop decision are reported below.

Longer trace-only promotion controls — incomplete and inconclusive

Two of four declared identical-source controls completed before an explicit budget closeout. Each used 80 fixed cohorts and a minimum 1,200-second window with trace-GC only. Controls 3–4 and all candidate promotion comparisons were not started. This is an incomplete calibration, not a completed passing protocol or a candidate rejection. No valid candidate promotion comparison is available. Both completed pairs and every sample remain retained.

The pinned application is a939b1d4e0f26c827dd17028d2cb899a1ea20247; the measured harness SHA-256 is 415dae8c18e853e0e8c7fd0bd03f49866b6916d5777e99ed147e8e1b9c4a1388. Preparation GC, warmup, common barrier, normal maintenance and counterbalanced CPU placement/launch order remained unchanged. No shared-guard warnings occurred. Traced timing and pause metrics are attribution-only.

Values are first arm / second arm; MB is decimal 1,000,000 bytes.

Pair Promoted bytes MB/primary-turn Signed delta MB/turn (%) Main trace GC count Excluded worker GC count List calls Total / utility model requests
1 7,851,012,920 / 12,761,964,000 24.534415 / 39.881138 +15.346722 (+62.552%) 3,979 / 4,318 10,940 / 10,689 7,051 / 7,125 1082 / 442 ; 1094 / 454
2 7,145,468,600 / 7,701,189,944 22.329589 / 24.066219 +1.736629 (+7.777%) 3,913 / 3,991 10,891 / 10,766 7,065 / 7,072 1080 / 440 ; 1081 / 441

Every arm completed 320 primary turns, 320 tool calls/results, 80 metadata patches and 40 successful cron runs. List/filter and utility request counts remain separately recorded; no normalization by GC collection count was performed.

Window 1–2 has a mean signed delta of +8.541676 MB/primary-turn and a mean paired relative delta of +35.165%. Pooled promotion is 23.432002 → 31.973678 MB/primary-turn (+36.453%). These are descriptive results of an incomplete control screen. Substantial identical-source variation remains unresolved, including the first pair’s adverse direction; no claim that promotion passed is made.

Pair Measured seconds List filter counts
1 1200.002 / 1200.002 1002, 988, 1028, 1012, 1010, 1021, 990 / 1022, 997, 1035, 1022, 1020, 1022, 1007
2 1200.001 / 1200.002 1007, 995, 1032, 1012, 1008, 1024, 987 / 1008, 994, 1033, 1016, 1011, 1020, 990

Filter order: unfiltered, active, archived, search, agent, exclude subagents, exclude system/cron. Passing untraced cost measurements, owner allocation measurements, correctness tests and CI remain separate evidence; they are not substituted for a promotion result.

@clawsweeper

clawsweeper Bot commented Oct 25, 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 scripts Repository scripts size: M labels Oct 25, 2026
@steipete
steipete marked this pull request as ready for review October 25, 2026 05:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T08:11:24.852927Z b23f329 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 25, 2026
@clawsweeper

clawsweeper Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR transfers changed session-entry fields instead of complete warm snapshots while preserving publication and mutable return values.

Example: Rename a warm session from “warm” to “changed” while retaining a 60 KiB skills snapshot.

  • Before: The patch reply transfers unchanged snapshot contents.
  • After: The reply transfers changed fields and removals, then reconstructs the complete entry from revision-validated resident facts.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The change has relevant production-path measurements and focused state-contract coverage, but adverse runtime signals leave performance acceptance unresolved.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR records separate real dev Gateways using WebSocket metadata churn and concurrent mock-provider turns, with completed operations and reduced patch-transfer bytes; focused native-worker measurements include reconstruction and mutable-result copying, without establishing a Gateway-wide speedup.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Repeated metadata updates allocate and decode unchanged session snapshots on the Gateway thread.
Reason: The maintainer-authored direction targets measured redundant work without new configuration or storage contracts; runtime acceptance is explicitly deferred in the PR.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR provides a distinct allocation reduction absent from current main, with no definite introduced defect found; performance acceptance remains explicitly pending.

Priority: P2
Reviewed head: f9641d4912992ff8070affaec5f4c8d30ff83958

Before merge

  • Resolve merge risk - Before merge, the author should resolve the reported adverse Gateway GC and latency signals with the pending controlled comparisons, or explicitly accept the measured tradeoff.

Findings

None.

Agent review details

How this fits together

Session metadata callers submit patches to the agent database worker, which commits stored entries and returns publication facts for Gateway replicas, observers, and callers.

flowchart LR
  A[Metadata caller] --> B[Existing patch owner]
  B --> C[Agent database worker]
  C --> D[Session database]
  C --> E[Delta or complete candidate]
  E --> F[Gateway reconstruction]
  F --> G[Commit admission and publication]
  G --> H[Replica and mutable caller result]
Loading

Technical review

Best possible solution:

Retain the existing revision-validated replica and publication owners, and land the delta optimization only after its performance tradeoff is resolved.

Do we have a high-confidence way to reproduce the issue?

Current-main source transfers complete publication entries on changed patches, and the PR reports a baseline-failing wire-size regression; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The approach removes redundant transport through existing owners while preserving cold and superseded-preimage behavior; its net runtime benefit remains subject to performance acceptance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 274a86d02feb.

Merge-risk options

Maintainer options:

  1. Complete the controlled comparison (recommended)
    The author should use the pending comparison to determine whether the allocation savings preserve Gateway GC and latency.
  2. Explicitly accept the tradeoff
    The feature owner may accept the measured runtime cost if the allocation benefit warrants it.
  3. Pause the optimization
    Retain complete replies if controlled measurements do not justify the added reconstruction work.

Provenance checked

  • Worker patch execution and publication keeps the original intent (d6929f8: Move prepared metadata patches into the existing worker while retaining FIFO, transaction predicates, live authority, native receipts, and publication.)
  • Full publication facts and omitted caller results keeps the original intent (1aac796: Omit unused caller results while keeping entry-returning APIs, observers, publication facts, and final authority intact, as documented in perf(sessions): bound cached rows and omit unused patch results #176601.)
  • Sealed publication source keeps the original intent (8656a68: Reuse committed facts through the existing replica while preserving invalidation and caller-owned authorization; sealing must also cover an emptied full-entry map whose entry is reconstructed by the host.)
  • Gateway measurement workload keeps the original intent (9fe8d3e: Separate untraced timing from allocation instrumentation and retain representative mixed workload diagnostics; the added polling counts and whole-soak CPU support this comparison.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +131, Tests +58, Other +38. Total +227 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 210 79 +131
Tests 1 58 0 +58
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 55 17 +38
Total 6 323 96 +227

Review metrics

Metric Value Why it matters
Production versus test growth Runtime production +210/−79, net +131; tests +58/−0. Growth implements revision validation, publication reconstruction, and mutable-result isolation using existing owners; the regression protects distinct transfer and state contracts.

Labels

Label changes:

  • add P2: A useful internal allocation improvement with no established urgent user-facing failure.
  • add merge-risk: 🚨 other: Runtime performance remains unresolved: the supplied Gateway measurements show adverse GC and latency signals despite lower patch allocation.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.

Label justifications:

  • P2: A useful internal allocation improvement with no established urgent user-facing failure.
  • merge-risk: 🚨 other: Runtime performance remains unresolved: the supplied Gateway measurements show adverse GC and latency signals despite lower patch allocation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve the pending controlled Gateway comparison and record whether the allocation savings justify the GC and latency tradeoff.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 25, 2026, 1:30 AM ET / 05:30 UTC.

@steipete
steipete force-pushed the perf/lane1714-session-entry-patch-transfer branch from f9641d4 to 9b0a2f9 Compare October 25, 2026 06:54
Reuse the existing revision-validated session replica for unchanged fields. Restore complete publication facts before admission and keep returned JSON containers independently mutable. Cold and superseded preimages retain complete replies.
@steipete
steipete force-pushed the perf/lane1714-session-entry-patch-transfer branch from 9b0a2f9 to b23f329 Compare October 25, 2026 08:08
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The branch and evidence are current. Exact-head CI and independent review pass. Four twenty-minute untraced controls and two swapped candidate comparisons resolve the earlier GC/latency concern without a rejecting regression. Patch-owner allocation improves 12.2–24.3%, and transfer bytes per patch fall 86.0%.

The body retains the separate promotion limitation: identical-source trace controls are unstable, the longer screen stopped explicitly at two of four planned controls, and no valid candidate promotion comparison is claimed. Landing relies on the scoped allocation benefit, correctness, and valid untraced cost evidence.

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 36190da into main Oct 25, 2026
184 of 185 checks passed
@steipete
steipete deleted the perf/lane1714-session-entry-patch-transfer branch October 25, 2026 10:26
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…law#183276)

Reuse the existing revision-validated session replica for unchanged fields. Restore complete publication facts before admission and keep returned JSON containers independently mutable. Cold and superseded preimages retain complete replies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant