Files
Wang 0b7bf39f49 perf: incremental memory optimization across Maka (#5153)
* perf(desktop): defer unused WorkHub and bot SDK initialization

Create the WorkHub renderer on first use rather than on enable, while retaining drafts after use. Load platform SDKs only when a configured bot starts or Slack credentials are tested.

Generated-by: OpenAI Codex

* fix(ui): release attachment previews when composers unmount

Track Blob URL ownership before decode and stop asynchronous staging after unmount while preserving hidden drafts and StrictMode replay.

Generated-by: OpenAI Codex

* perf(runtime-host): compact completed message replay identities

Retain canonical content digests instead of historical submit and queue edit bodies, without evicting epoch-long outcomes or changing pending operations.

Generated-by: OpenAI Codex

* fix(desktop): cancel completed display frame fallback callbacks

Cancel the losing animation frame or timeout after a stream display batch flush, preventing suspended background frames from retaining completed handlers.

Generated-by: OpenAI Codex

* perf(runtime): release retired graph epoch reconciliation snapshots

Fence old supervisor callbacks and preserve explicit reconcile readers across epoch handover. Retain lightweight driver metadata for historical projection repair and close diagnostics.

Generated-by: OpenAI Codex

* fix(runtime-host): detach transcript preparation close listeners

Replace connection-lifetime Promise races with removable abort listeners so released transcript overlay buffers can be collected while the connection remains open.

Generated-by: OpenAI Codex

* fix(desktop): bound browser release fencing to pending acquires

Drop per-session release epochs when connection attempts settle and avoid retaining tombstones for sessions that never acquired a browser, preserving reentrant teardown and single-flight fences.

Generated-by: OpenAI Codex

* perf(runtime-host): compact historical root admission bodies

Retain canonical content digests and owned identity metadata for historical admissions while keeping full current tips and validated recovery or conflict results.

Generated-by: OpenAI Codex

* test(runtime-host): close admission fixture stores before cleanup

Release the SQLite lease before removing temporary files so root admission tests clean up on Windows and do not retain fixture database owners.

Generated-by: OpenAI Codex

* perf(desktop): release activated subscription preparation roots

Generated-by: OpenAI Codex

* refactor(desktop): move display scheduling into conversation ownership

Keep frame cleanup within the renderer architecture boundary without widening legacy budgets.

Generated-by: OpenAI Codex

* perf: release Zod recursive parse state after completion

Keep cycle memoization scoped to each parse and restore allocation state when parsing throws.

Generated-by: OpenAI Codex

* docs: record Zod patch source license

Generated-by: OpenAI Codex

* perf(runtime): release processed WeChat SSE payloads while idle

Keep iterator result and decoded message lifetimes within each completed read. Preserve reconnect cursors, parser boundaries and iterator cleanup semantics.

Generated-by: OpenAI Codex

* fix(peer): bind WebRTC workers to connection lifetime

Cancel connection-owned channel workers and close the native peer on explicit close, unpolled muxer drop and failed or aborted upgrades. Keep successful connection lifetime separate from signaling-attempt cancellation.

Generated-by: OpenAI Codex

* perf(desktop): release delivery records during retry waits

Keep retry callbacks outside the delivery lexical context so pending or completed attempts do not retain parsed message bodies for the five-second retry interval. Preserve durable intents, timer behavior, and replay identity.

Generated-by: OpenAI Codex

* perf(peer): cancel obsolete reconciliation timers

Own the five-minute timer and abort listener in each reconciliation wait. Early public triggers release both immediately while normal expiry and endpoint shutdown still wake the loop.

Generated-by: OpenAI Codex

* test(desktop): scope POSIX mode assertion to supported platforms

Keep local restart and retry assertions running on Windows without equating stat mode bits with ACL permissions. Production permission handling is unchanged.

Generated-by: OpenAI Codex

* fix(ui): avoid retaining messages through unknown code languages

Generated-by: OpenAI Codex

* fix(cli): release completed event waiters

Generated-by: OpenAI Codex

* fix(cli): share immutable text across editor undo snapshots

Copy mutable editor state and paste maps without deep-cloning each stored paste for every typed word. Preserve all undo steps and cover public editing, paste renumbering, and retained heap growth.

Generated-by: OpenAI Codex

* perf(core): bound Unicode truncation allocations

Collect only the code-point prefix needed for nonnegative budgets while preserving cleaning and numeric slice semantics. Cover transient allocations and Unicode behavior with regression tests.

Generated-by: OpenAI Codex

* perf(core): bound diagnostic truncation allocations

Preserve complete redaction and byte-budget semantics while limiting temporary code-point arrays and UTF-8 encoding to the useful prefix.

Generated-by: OpenAI Codex

* perf(runtime-host): release consumed peer receive buffers

Generated-by: OpenAI Codex

* perf(ui): defer reasoning bodies until first expansion

Generated-by: OpenAI Codex

* perf(runtime): detach truncated web search result text

Generated-by: OpenAI Codex

* perf(desktop): load update attestation dependencies on demand

Keep startup channel metadata free of Sigstore and TUF module graphs. Load the parser and verifier only when an update is actually verified, preserving fail-closed trust checks.

Generated-by: OpenAI Codex

* fix(runtime): preserve cancellation through request customization

Forward the caller's effective AbortSignal instead of a temporary Request's GC-sensitive derived signal. Preserve explicit null, inherited and overriding signals on every body path, and cover prompt native HTTP cancellation after GC.

Generated-by: OpenAI Codex

* perf(runtime): reuse buffered JSON request bodies

Decode the bytes already read for request customization instead of cloning and reading the complete body twice. Preserve the original read boundary, stream error identity, caller locks and cancellation semantics.

Generated-by: OpenAI Codex

* perf(computer-use): scope session cleanup metadata to live work

Avoid allocating unknown-session state during ordinary cleanup. Retain cancellation generations only while queued operations own them, preserving same-turn stop authority and executor-release fencing.

Generated-by: OpenAI Codex

* fix(runtime-host): release uploads rejected after session removal

Release only connection-owned staging in the existing missing-session rejection path. Preserve response and TTL contracts while preventing failed commit and cleanup requests from retaining completed upload buffers.

Generated-by: OpenAI Codex

* perf(runtime-host): release retired Goal token metadata

Scope cached token totals to the existing Goal control lease so late context reads cannot repopulate retired entries or overwrite a new Goal. Delete only after committed retirement and clear during drain, retaining rollback and close fences.

Generated-by: OpenAI Codex

* test(runtime-host): close Goal fixture execution stores

Release SQLite execution-store handles before removing temporary roots. Covers the new lifetime regressions and existing Goal coordinator tests that reproduced the same Windows EBUSY failure on pre-fix production source.

Generated-by: OpenAI Codex

* perf(mcp): release settled request graphs behind blocked sends

Scope cancellation error observers independently and revoke the pending send observer's native rejection reference when the request settles. Preserve queued frames and late error handling in both SDK module formats.

Allow the required unified-diff context prefix before upstream tabs while retaining other patch whitespace checks.

Generated-by: OpenAI Codex

* perf(runtime-host): share identical turn skill inventories

Reuse only fully equal frozen snapshots after each fresh catalog read. Preserve per-turn historical state, the 100-entry FIFO and failed-read retry behavior, and prevent evicted late reads from adding retention.

Generated-by: OpenAI Codex

* perf(runtime-host): share identical completed prompt text

Retain per-turn source revisions and the existing FIFO while sharing equal text only within live cache ownership.

Generated-by: OpenAI Codex

* test(runtime-host): make prompt heap checks portable to Electron

Generated-by: Codex

* perf(ui): detach bounded drafts from oversized input strings

Generated-by: OpenAI Codex

* perf(runtime): reuse private Responses continuation history

Generated-by: OpenAI Codex

* perf(ui): detach capped completed stream text

Generated-by: OpenAI Codex

* perf(ui): simplify bounded draft string copying

Generated-by: OpenAI Codex

* perf(ui): detach oversized stream seed backings

Generated-by: OpenAI Codex

* perf(runtime): detach bounded archive read results

Generated-by: OpenAI Codex

* perf(runtime): release completed tool settlement batches

Generated-by: OpenAI Codex

* perf(ui): detach normalized sent prompt backing

Generated-by: OpenAI Codex

* perf(runtime): release unused plugin isolation labels

Intern named isolation symbols weakly so retired configurations do not retain historical labels. Preserve detached Context and service identity, and guard delayed finalizers against newer same-name symbols.

Generated-by: OpenAI Codex

* perf(runtime): materialize memory split candidates on demand

Preserve split ranking and first-fit semantics while constructing only the candidate currently being tested. Verify complete model context, durable coverage, and bounded event-reference copying through the SQLite-backed Host extraction path.

Generated-by: OpenAI Codex

* perf(runtime): bound memory localization prefix allocation

Generated-by: OpenAI Codex

* perf(storage): bound session catalog preview allocation

Generated-by: OpenAI Codex

* perf(runtime): bound graph handoff prefix allocation

Generated-by: OpenAI Codex

* perf(runtime): bound child result prefix allocation

Generated-by: OpenAI Codex

* perf(runtime): bound workspace instruction prefix allocation

Generated-by: OpenAI Codex

* perf(runtime): bound PTY model tail allocation

Generated-by: OpenAI Codex

* test(runtime): close shell result recovery fixture store

Generated-by: OpenAI Codex

* perf(runtime): consume discarded OAuth error bodies once

Generated-by: OpenAI Codex

* perf(storage): size stable read buffers to admitted files

Generated-by: OpenAI Codex

* perf(runtime-host): release fully consumed frame buffers

Generated-by: OpenAI Codex

* test(runtime-host): isolate consumed buffers from shared pools

Generated-by: OpenAI Codex

* perf(runtime-host): avoid recopying empty frame prefixes

Generated-by: OpenAI Codex

* perf(ui): initialize persisted composer history once per mount

Generated-by: OpenAI Codex

* perf(runtime-host): release consumed peer byte-stream buffers

Generated-by: OpenAI Codex

* perf(runtime): stream live PTY code-point chunks

Avoid full code-point and sliced arrays while preserving exact raw output chunk boundaries, publication sequences, and terminal flush behavior.

Generated-by: Codex

* perf(runtime-host): avoid length-only Base64 decoding

Count validated or generated Base64 bytes without materializing temporary decoded buffers. Preserve canonical checks, artifact bounds and transcript range semantics.

Generated-by: Codex

* perf(runtime): bound research artifact character arrays

Collect only requested code points while preserving full ledger hash validation, total length and sanitized output. Exercise the production Host tool facade against real SQLite and artifact files.

Generated-by: Codex

* perf(runtime): count edit lines without splitting text

Reuse existing occurrence counting for match line positions. Preserve exact and fuzzy edits, trailing newline semantics and descriptor-pinned writes.

Generated-by: Codex

* perf(runtime): collect only localized edit diff windows

Count source lines without full arrays and collect the existing bounded diff windows directly. Preserve valid edit ranges, UTF-8 budgets, hunk formatting and descriptor-pinned writes.

Generated-by: Codex

* perf(runtime): collect only requested file read lines

Preserve split/slice window behavior while avoiding full-file line arrays in local and worker reads. Add real file regressions and allocation checks.

Generated-by: OpenAI Codex

* fix(desktop): scope interaction hydration fences to pending reads

Replace the ever-growing per-session epoch map with one pending read identity. Preserve stale-response guards without keeping metadata for completed sessions; ratchet the architecture token ledger downward.

Generated-by: OpenAI Codex

* perf(runtime): avoid full line arrays in bounded tool output

Count line boundaries and collect only the retained head or tail window. Preserve byte slicing, recovery markers, and removed counts, with old-source negative allocation and real pipe projection coverage.

Generated-by: OpenAI Codex

* perf(runtime): bound oversized tool-line UTF-8 encoding

Encode only a byte-budget-sized UTF-16 window, with one extra unit to preserve surrogate boundaries. Keep legacy Buffer behavior for unusual budgets and verify exact head/tail output against old source.

Generated-by: OpenAI Codex

* perf(runtime): bound WebFetch preview UTF-8 encoding

Encode only the model-visible prefix plus a surrogate guard unit, preserving the byte cap and truncation marker. Cover real Host HTTP fetches, privacy refusal, Unicode boundaries and old-source allocation regression.

Generated-by: OpenAI Codex

* perf(runtime-host): avoid duplicate resource result clones

Clone each runtime resource update once before bounding its state. Preserve source isolation and query revisions, and cover get/list allocation with old-source negative controls.

Generated-by: OpenAI Codex

* chore: trim memory optimization test additions

Remove 65 new test and fixture files plus added allocation probes from existing suites. Keep only minimal existing-test behavior and cleanup adaptations. Preserve production memory fixes and remove stale test references.

Generated-by: OpenAI Codex

* fix: align memory changes with CI metadata gates

Re-pin the compatible byte-count optimization to main's protocol epoch, record the MCP dependency patch license, and correct the renderer token ledger to the checked source.

Generated-by: OpenAI Codex

* ci: include bounded line reader in Windows package inputs

Generated-by: OpenAI Codex

* fix(runtime): keep graph epoch handover independent of teardown

Fence retired drivers synchronously, then release their snapshots after admitted work and cleanup settle without blocking the next turn.

Generated-by: OpenAI Codex

* fix(bots): report lazy SDK initialization failures

Handle module loading and client construction inside each bridge's failure boundary so registry status reflects failed connections.

Generated-by: OpenAI Codex

* fix(desktop): defer cold WorkHub summons until renderer ready

Reuse pending focus to keep the window hidden during initial loading, allow cancellation, and preserve synchronous warm shortcuts.

Generated-by: OpenAI Codex

* perf(memory): finish scoped lifecycle review follow-ups

Initialize composer attachment ownership lazily, avoid empty handshake backing views, clarify line-window and Zod upgrade contracts, and cover CU observer cleanup without restoring allocation probes.

Generated-by: OpenAI Codex

* test(desktop): wait for automatic naming before archive

* test(memory): cover cancellation and recursive lifetime contracts

Generated-by: OpenAI Codex

* test(peer): observe backpressure before testing teardown

Generated-by: OpenAI Codex

* fix(ci): repin compatible allocation change to epoch 142

Revalidated the byte-count-only protocol changes against current main after merging its Skill query epoch bump.

Generated-by: OpenAI Codex
2026-09-11 19:08:40 +08:00
..