Skip to content

perf(native-chat): one save rule (growth or 400 ms) for every agent's streamed text - #28984

Closed
brennanb2025 wants to merge 20 commits into
brennanb2025/native-chat-text-piecesfrom
brennanb2025/nc-perf-growth
Closed

brennanb2025 wants to merge 20 commits into
brennanb2025/native-chat-text-piecesfrom
brennanb2025/nc-perf-growth

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​138 $\color{#cf222e}{\Huge{\mathbf{−}}}$​42 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​96
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​177 $\color{#cf222e}{\Huge{\mathbf{−}}}$​156 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21

ELI5

Long replies can appear unchanged for seconds because Claude and Codex save only after substantial growth. Other agents save full text much more often. This change gives streamed text one growth rule and schedules a save after 400 milliseconds when changed text is still waiting.

What Changed

Streamed text is saved when it grows by at least 32 characters or one eighth of the previous saved length, or when 400 milliseconds have passed since its last save. Skipped text stays pending. Completion and other ordering barriers still flush preceding text, and refused saves remain eligible for retry.

The deadline retains its original absolute time, including fractional clock readings. This avoids rounding a scheduled save past the cap or moving the deadline between clock reads.

This PR depends on #29132, which shares unchanged text in private database storage while preserving complete logical history and existing client messages. Its schema-5 migration follows the existing newer-database refusal contract for unchanged older binaries. Mixed paired and SSH peers continue receiving complete values. Connected clients receive committed updates from the host’s in-memory state; damage to saved text is discovered by the next saved-history read or reopen.

Why

A growth-only rule increases the wait as replies grow. A deadline keeps progress regular, while the growth threshold reduces unnecessary intermediate saves. Shared storage is required because more frequent full-prefix copies caused the original implementation's measured storage regression.

The 400-millisecond value is a scheduled maximum under a responsive event loop and an accepting journal. It does not guarantee renderer or network latency when the host is blocked or a save is refused. The active maximum interval and complete existing wire messages are intended differences from the common pattern, required by Orca's progress and compatibility contracts.

Measurements

Two current-production Windows fixture runs at 50,000 source characters and 300 characters per second pass the unchanged 400.001-millisecond scheduled-gap tolerance, final provider-translation equality and restart equality. Claude retains the exact 50,000-character final reply; Codex retains its existing bounded translated final value of 16,452 bytes. Physical retained text payload is 289,052 bytes and 255,765 bytes respectively, excluding integer/index/file overhead.

These are historical single fixture observations at c3b9759. They do not validate the newer live-publication path. They are not matched performance acceptance, real-agent UI measurements or wall-time latency guarantees. Direct publication probes still returned 90,101 Claude and 51,506 Codex piece records, with aggregate instrumented publication wall times of about 4.9 and 2.7 seconds. Those sums are not a single freeze; actual subscriber and matched main/storage/cadence measurements remain pending.

The original table measured an earlier representation and does not establish this head's performance. Replacement comparisons cover 300/1,000 characters per second and 2,000/10,000/50,000-character replies, with retained payload, file sizes, publication/replay CPU, memory and scheduled gaps separated. Existing Codex and timeline completion can bound authoritative text to an inline head plus truncation marker on main too; this PR does not change those bounds or claim full-source fidelity for those completions.

Linked Issue

Maintainer change. Storage prerequisite: #29132.

Visual Proof

Real signed-in-agent hidden Electron main/branch comparison on M4Air is pending capacity. No current screenshots or rendered acceptance are claimed.

Testing

  • Cumulative source review through round six, including absolute-deadline and fractional-clock coverage. The latest activity-only allocation correction still awaits targeted and runtime verification.
  • Earlier focused native run: 284 tests in eight files passed; current test amendment still needs final validation.
  • Twelve native retained-copy migration, unchanged-old refusal and current continuation phases passed with complete values, cursor, snapshot, restart and original hashes checked independently.
  • Two current-production strict scheduled-gap/provider/restart fixture cases passed.
  • Matched repeated provider matrix and actual one/three-subscriber measurements.
  • Real remote Electron comparison and screenshots.
  • Final integration and full PR workflow green on the resulting exact head.

Current head is 72d9a3b. Its full workflow, pr.yml run 38957889641, is being watched; older green runs are not current evidence. This checkout lacks dependencies and installed hook wrappers, so the pre-commit hook could not execute; no bypass flag was used. CI supplies the static-analysis gate.

AI Disclosure

Review

The review found repeated full-prefix storage, then corrected traversal of obsolete text dependencies. The runtime panel blocked the experimental compatibility view and timer rounding. First-hand released-source inspection confirmed that unchanged older binaries already refuse newer saved schemas before replay; the decider adopted private schema-5 pieces and the timer now retains its exact deadline. The amended plan was independently checked. The latest review found unnecessary full-history allocation for activity-only updates; that narrow correction is pushed and awaits targeted verification. The unchanged subscriber wall-time and CPU gates, real QA, final conflict integration and exact-head CI remain required, so the PR stays a draft.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer source is copied or translated.

Notes

No new wire operation, capability requirement, setting or renderer notice is introduced. Local, SSH and paired clients retain complete existing item messages. Unmeasured platforms, transport and responsiveness cases remain explicit limits.

Checklist

  • Save timing remains separate from its storage prerequisite.
  • Problem, user-facing change, mechanism and tradeoffs explained.
  • Runtime validation and real remote screenshots complete.
  • No conflicts, unresolved threads or failed/missing required checks on the final head.

Author: @BrennanKB5

Current verification checkpoint: a focused Windows run on the preceding head collected 122 tests and found one extra history reduction during reconnect. The current head restores lazy reconnect work reads; that unchanged test, the subscriber performance gates, real signed-in-agent Electron comparison and final CI are pending. No current readiness claim.

The growth rule alone left long replies without a visible update for up to
16 s at 50k characters, for every agent. A window that skips a stream now
closes again at that stream's time cap, so owed text is written within
400 ms of the last write, which the desktop's 350 ms reveal turns into
continuous text. The UTF-8 bound helpers move to their own file to keep the
coalescer under the line limit.
@brennanb2025 brennanb2025 changed the title perf(native-chat): one save-on-growth rule for every agent's streamed text perf(native-chat): one save rule (growth or 400 ms) for every agent's streamed text Oct 15, 2026
@brennanb2025
brennanb2025 changed the base branch from main to brennanb2025/native-chat-text-pieces October 15, 2026 10:03
@brennanb2025

brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Long streamed replies repeatedly saved complete text. The storage prerequisite #29132 now stores shared text pieces, and #28984 saves growing output with an absolute 400 ms deadline, but the stack remains blocked and in draft because publishing saved updates is still materially slower than main.

The resumed review established that existing Orca releases refuse a newer saved schema before replay and preserve the database. Paired and SSH clients receive complete values from the owning host rather than opening its database. The earlier claim that the 6.6-second unchanged-old-binary reopen was a supported path was incorrect: it measured the discarded same-schema compatibility view. The new private schema migrates existing journals atomically and preserves the established old-binary refusal and mixed-peer values. Three retained database families passed migration, refusal, continuation and restart checks.

The timer now retains the original absolute deadline and schedules the unrounded remaining duration. Fractional-clock coverage passes the unchanged 400.001 ms scheduled-gap gate; this does not claim arbitrary-load wall-clock responsiveness.

Cumulative source review round 5 is clean after the earlier fixes. The latest bounded correction reuses only the pure decoding and boundary calculation for freshly fetched exact suffix values; every required saved-row and ancestry check remains. Its 99 targeted tests pass, including all six shared-database host tests. That correctness result does not clear the performance gate:

Actual subscriber publication, 10,000 checkpoints, one subscriber Main Previous storage Current storage
Wall time 1466.9591 ms 3131.1255 ms 3202.0212 ms
CPU time 96 ms 559 ms 830 ms
Complete frames 10000 10000 10000
Full publication JSON bytes 171288922 171288922 171288922

The current result remains 2.18 times main wall time and 8.65 times CPU. Whole-workload wall time was 46.78 seconds versus 23.38 seconds for the previous storage run. These single shared-host observations do not attribute every increase to the correction, but they do not demonstrate acceptance. The fixture, launch limits and assertions were unchanged. The sampled whole-process memory includes the new cache and operation state; it does not isolate exact cache occupancy or every synchronous transient. The existing bounded provider translation matches exactly; no full-source-text claim is made.

The design settlement allowed one finite equivalent-computation correction. That attempt is now BLOCKED; no further optimization, additional diagnostic or performance allowance is being inferred. Current reviewed heads are storage 0c7ca6e672ded8219121cd90e8d7a68ba18b78d8 and cadence 7e0e336b88940156588b31f75056da8ea6f6fd36. Final conflict resolution, the complete remaining provider/repetition/replay/subscriber matrix, current-head remote real-agent Electron comparison with screenshots, and both final-head full PR workflows remain outstanding. Successful real-Claude flows on the previous cadence head are supporting evidence only. Neither PR is ready, merged or closed.

The existing cadence PR workflow is also blocked on the exact current head: its cross-version wire job failed because newest release v1.4.227 uses daemon protocol 47 while this branch still declares 46. The complete failed-job log was inspected. The fail-fast watcher exited; four unit shards were still pending in its handoff snapshot, so this is not a completed or green workflow. No protocol patch, workflow rerun or main integration was made under the hold.

For Brennan’s review: the unresolved choice is how to remove the publication cost while preserving the existing complete saved-read authority and damaged-history behavior. A different delivery policy has not been approved or implemented. Current-head screenshots and a completed readiness claim are unavailable because the runtime gate remains blocked.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 16, 2026 21:05
@nwparker

Copy link
Copy Markdown
Contributor

Closing: bounding the Claude/Codex unsaved tail to 400 ms is a real fix, but it slows ACP/Pi/JSONL-RPC streaming from ~60 ms to ~400 ms steps, which is visible, and it depends on the schema-5 migration. Consider a Claude/Codex-only time cap on today's storage.

@nwparker nwparker closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants