Skip to content

tracking(perf): bound storage and protocol read/write amplification #5038

Closed as not planned

Description

@Astro-Han

Problem

Some Storage and Runtime Host operations process substantially more data than the requested result or the new change requires. Repeated page serialization, full-record output updates, full-store metadata reads, and historical Usage materialization can spend CPU, memory, and I/O on unchanged or unrelated data.

This tracker owns the remaining delivery and measurement work identified by Discussion #4876. It is scoped to read/write amplification in Storage and the Host protocol, rather than every performance issue in Maka.

Scope and relationship to existing work

Use existing issues and PRs for their concrete work. Links here record dependencies and acceptance; they do not create a second implementation or a second owner.

Current evidence

Source inspection baseline: 87797378c. The observations below are code-path evidence, not new production latency measurements.

Repeated encoding and page assembly

Several page builders append one item, serialize the entire candidate page, and discard that encoding after checking its byte length. Examples:

For similarly sized items, cumulative serialization work grows quadratically with the number of items admitted to a page. Existing count/byte caps limit several of these paths; this is not a claim of unbounded whole-history work or a measured user-visible regression in every page builder.

Byte-limit helpers also retain private copies alongside protocol/codec.ts. Consolidation alone is not performance acceptance: measure actual repeated serialization along producer/consumer paths. The transport already accepts EncodedProtocolMessage; extend that seam where applicable rather than adding a parallel encoding path. Raw frame bytes, normalized values, and nested-object budgets are distinct and must not be substituted for one another.

Shell output persistence

ShellRunManager.queuePersist compares the output snapshot with the current record and calls updateShellRun. Storage reads the stored record and serializes the complete next record into record_json.

The full-record operation is confirmed. Its practical amplification remains to be measured against retained-output bounds, flush frequency, and SQLite write/WAL bytes before selecting a representation change.

Existing delivery paths

Work Existing issue / PR Remaining acceptance
Artifact point reads and revisions #4037 / #4874 Verify bounded materialization when unrelated Sessions grow and when the target Session grows; preserve revision consistency and cross-process visibility.
Batch artifact cleanup during Session retirement #4038 / #4984 Verify batch work avoids repeated whole-store guard scans while preserving physical deletion safeguards and retryability.
Revision-consistent bounded Usage reads #4058, #5019 / #5023; related UI work #4531 / #4539 #5023 is currently a design-only draft. Resolve its Storage/query boundaries, then measure SQL scan/sort work as well as application decoding and transfer. UI pagination alone is insufficient.

Delivery checklist

Already changed; do not reopen from the old inventory

Deferred questions

  • Owner-lock/control-directory cleanup requires proof that removal preserves mutual exclusion; coordinate with fix(runtime-host): reap stale Runtime Host control directories #4712. Do not treat unlinking lock files as an ordinary cleanup optimization.
  • Usage retention after Session deletion is a product-policy decision, not permission to delete historical records as part of a performance fix.
  • Other tables without retirement paths are not automatically implementation tasks. Add work only when growth or an operational obligation is established.
  • A repository-wide CI ratchet or mandatory exception ledger is not a prerequisite for the first fix and is not approved by this tracker.

Acceptance

For each delivered path:

  1. Name the real producer, authority, and downstream consumer. Measure through that path rather than only benchmarking a helper.
  2. Compare the same workload on explicit before/after commits. Vary the relevant dimension: page size, target history, unrelated records, retained output, or retired Session count. Include a cold/warm distinction where relevant.
  3. Report applicable rows scanned/decoded, serialization work, retained memory, write/WAL bytes, and elapsed time. For timing comparisons, use repeated runs and report median/p95; distinguish synthetic measurements from production observations.
  4. Preserve UTF-8 byte budgets, completeness/cursor semantics, revision consistency, atomic durable facts, and retry/restart behavior relevant to the changed path. Retain focused behavioral tests that fail on the replaced behavior.
  5. Do not accept moving a full scan from reads to every write, materializing everything behind a paginated API, or adding a second durable authority as a reduction in amplification.

Completion means each delivery item has a verified result or a documented, evidence-backed scope decision. It does not mean every read is constant-time, every historical row is deleted, or the separate user-experience budgets in #4677 have been met.

AI assistance: Codex helped inspect current source and draft this tracker under maintainer direction.

Activity

  1. chinawch007 commented on Sep 8, 2026

    @chinawch007
    Contributor

    I’d like to take on the first delivery checklist item: encoding and page-assembly optimization.

    My initial scope is the five page-building paths identified here: Memory entries, Artifact pages, Plan pages, Session catalog pages, and Runtime resource pages. I’ll verify these against current main and check for overlapping work before making changes.

    My proposed approach is:

    1. Trace the existing paths and establish a baseline.
      Follow page construction through protocol validation, outbound encoding, transport, and the downstream consumer. Identify repeated serialization and array copying, and measure the work performed by the actual request paths rather than only benchmarking a helper.

    2. Replace repeated candidate-page serialization with incremental byte accounting.
      Evaluate a shared implementation that measures normalized items once and accounts for the page envelope, separators, and changing cursor fields. Reuse encoding results or byte measurements where they describe the same representation, through the existing protocol interfaces and EncodedProtocolMessage seam.

    3. Apply the change consistently and remove superseded implementations.
      Cover the identified page builders in one PR unless a concrete dependency blocks part of the work. The PR will explicitly document the paths covered and remove the implementations it replaces.

    4. Verify behavior and attach reproducible performance evidence.
      Add focused tests for UTF-8 and JSON escaping, exact byte boundaries, oversized items, empty/final pages, and cursor transitions. Check pagination completeness and revision consistency. Compare explicit before/after commits under the same workloads, varying page size and item size, and report serialization work, memory, and repeated-run median/p95 timings, with cold/warm distinctions where relevant.

    The key constraints I’ll preserve are the existing count/byte limits and validation behavior. Raw frame bytes, normalized result values, and nested-object budgets will remain distinct; reusing an encoding measurement must not bypass a different validation boundary. Performance claims will be limited to the measured paths.

  2. liuxiaocs7 commented on Sep 8, 2026

    @liuxiaocs7
    Member

    Thanks @Astro-Han for pulling these performance points together into a well-scoped tracker — the clear boundaries around scope, the acceptance criteria, and the "already changed; do not reopen" section make this a genuinely useful read.

    I'd like to pick up the second checklist item: Shell output persistence measurement. I'll confirm the paths against current main first.

    As the tracker frames it, this is a measure-first task, not a predetermined representation change. My plan follows the Acceptance criteria:

    1. Path (producer → authority → consumer).

    • Producer: ShellRunManager.queuePersist — takes a full output snapshot, deep-compares the candidate record, and on any diff calls updateShellRun with the complete output.
    • Authority: SqliteShellRunStore.updateShellRun — reads the current record, merges, and JSON.stringifys the whole next record into the record_json column (one atomic UPDATE).
    • Consumer: readShellRun / listSessionShellRuns on restart, plus the live shell-run views. Recovery reconstructs the retained tail and truncation flags from that single blob.

    2. What I expect to find, and want to quantify. The retained output is already bounded (BASH_MAX_RETAINED_CHARS, ~1MB/stream), so per-flush cost is bounded. The amplification is in the flush count: with a ~1s / 64KB flush cadence, a long-running command that produces far more than the retained cap rewrites the full (capped) record on every flush. So cumulative write/WAL work scales roughly as (total_produced_output / flush_bytes) × retained_record_size, even though only a tail is ever kept. I want to measure whether that is material at representative sizes rather than assume it.

    3. Measurement. Same-workload before/after on explicit commits, varying:

    • retained-output size (up to the cap) and total produced output (drives flush count),
    • flush cadence (interval vs byte trigger).

    Reporting per-flush JSON.stringify bytes, isDeepStrictEqual cost, SQLite/WAL bytes written, retained memory, and repeated-run median/p95 elapsed, with a cold/warm distinction.

    4. Deliverable. Per the checklist, one of: (a) a justified follow-up with an explicit recovery contract — preserving the atomic durable fact, exact reconstruction of the retained tail and truncation flags, and retry/restart behavior — or (b) an explicit, evidence-backed decision that the bounded cost is acceptable. I will not move a full scan onto every write, add a second durable authority, or weaken atomicity/recovery as a "reduction."

    I'll keep performance claims limited to the measured paths. Happy to align if a maintainer prefers I fold this into existing shell-run work instead.

  3. liuxiaocs7 commented on Sep 8, 2026

    @liuxiaocs7
    Member

    Shell output persistence baseline

    I measured the current Shell persistence path before selecting a representation change.

    Scope and environment

    • Commit: 9cb5cc93c03f8d07550e739164d5e33168892563
    • Apple M4 Pro, macOS arm64
    • Node.js v24.14.0
    • Store measurements exercised the real SqliteShellRunStore.updateShellRun() path with the operational runtime.sqlite schema, WAL mode, and synchronous=FULL.
    • Each Store scenario performed 30 updates and was repeated in three fresh temporary workspaces. The table reports the middle result across the three rounds.
    • The Runtime measurements exercised the real ShellRunProcessManager -> ShellRunStore -> SQLite path with real child processes and the default 1-second / 64-KiB flush policy.
    • WAL auto-checkpointing was disabled during each measured interval so WAL growth remained observable.

    Isolated Store results

    Retained record / change per update Update p50 Update p95 JSON serialization amplification WAL amplification
    64 KiB retained / 64 KiB changed 0.32 ms 0.58 ms 1.0x 1.1x
    1 MiB retained / 64 KiB changed 3.90 ms 4.86 ms 16.0x 12.5x
    1 MiB retained / 4 KiB changed 1.74 ms 3.88 ms 256.1x 26.9x
    2 MiB across stdout/stderr / 4 KiB changed 3.77 ms 6.70 ms 512.1x 28.1x

    The amplification ratios compare the sum of complete encoded ShellRunRecord sizes, or WAL growth, with the amount of newly changed output.

    Metadata-only updates still process the complete output-bearing record:

    Retained record Update p50 Update p95 WAL growth over 30 updates
    1 MiB, metadata-only update 1.41 ms 4.25 ms 1.25 MiB
    2 MiB, metadata-only update 3.48 ms 6.02 ms 2.26 MiB

    End-to-end Runtime path

    Workload Durable output Store updates after entering running state Sum of resulting record sizes WAL growth
    Burst 2 MiB stdout ~1,020 KiB retained tail 2 1.99 MiB 2.03 MiB
    4 KiB every 250 ms for 3 seconds 48 KiB 4 0.13 MiB 0.18 MiB
    Fill ~1 MiB, then 4 KiB every 1.1 seconds ~1,008 KiB retained tail 6 5.94 MiB 6.06 MiB

    For the saturated-tail workload, the Store update p50 was 4.38 ms and p95 was 6.90 ms. Approximately 16 KiB of output arrived after saturation, while the persistence path processed about 6 MiB of complete records and produced about 6 MiB of WAL traffic.

    Interpretation

    The amplification is real but bounded by the existing retained-output limits and flush coalescing:

    • A short burst is relatively well coalesced. The 2 MiB burst caused one main output/final-state write plus one later observation write.
    • The expensive case is a long-running command whose retained tail is already near its limit and then changes slowly. A few KiB of new output repeatedly causes a roughly 1 MiB record to be read, parsed, compared, serialized, and updated.
    • Small metadata changes such as observedAt also retain the full JSON processing cost because output and lifecycle metadata share one record_json.
    • WAL amplification is lower than JSON serialization amplification because SQLite writes changed pages rather than an abstract full JSON byte stream, but the measured 4-KiB cases still produced approximately 27-28x WAL amplification.

    This is a local synthetic Storage/Runtime measurement, not a production latency claim. Disabling auto-checkpointing makes cumulative WAL writes visible; the numbers should not be interpreted as steady-state WAL file size.

    The results justify a follow-up, particularly around separating small lifecycle metadata updates from the large output payload and reducing saturated-tail rewrites. They do not yet demonstrate that a more complex append-log or checkpoint-plus-delta representation is necessary.

  4. liuxiaocs7 commented on Sep 9, 2026

    @liuxiaocs7
    Member

    Proposed Shell output persistence plan

    Updated 2026-09-14 after a SQLite physical-layout diagnostic. My earlier claim that same-row metadata_json / output_json separation guarantees unchanged output pages was incorrect. Avoiding an SQL assignment to output_json does not guarantee avoiding WAL writes for the large record's overflow pages. The plan below corrects that claim, makes the layout choice conditional on real-path measurements, and distinguishes flush scheduling defaults from a hard recovery guarantee. No implementation or durability-policy decision is implied by this revision.

    The measurements support treating two costs separately:

    1. Metadata-only mutations currently read, parse, compare, serialize, and update a record containing the full output payload.
    2. Once the retained output tail is near its limit, small continuing output changes still cause repeated complete output checkpoints.

    The first problem can be addressed without changing flush behavior or recovery semantics. Neither a two-column nor a two-table split eliminates the main saturated-tail checkpoint cost when output actually changes. Changing automatic flush behavior requires an explicit recovery-contract decision.

    Invariants

    • ShellRunStore remains the sole ShellRun state-machine authority; nextShellRunRecord() retains the transition, revision, no-op, and terminal-outcome rules.
    • Revisions remain monotonic and advance only for real durable changes.
    • Final status, final output, and revision are committed atomically.
    • Live Read/inspect continues to establish and persist a current snapshot cut before returning.
    • Terminal outcomes remain immutable; observedAt remains terminal-only and first-write-only.
    • Cross-process visibility, consistent reads, and restart/orphan recovery behavior remain unchanged.
    • PTY output remains a complete screen checkpoint unless separate evidence justifies a different representation.

    New evidence: column isolation is not page isolation

    A scoped diagnostic used Node v24.14.0 / SQLite 3.51.2, 4 KiB pages, WAL, and synchronous=FULL. Each case used a fresh database with the composite ShellRun primary key and Session ordering index, retained 1 MiB of stdout, and kept output unchanged. Setup WAL was checkpointed/truncated before one metadata-only transaction. Automatic checkpointing was disabled only to make WAL-frame accounting visible.

    The comparison covered combined record_json, same-row split columns in both orders, and separate metadata/output tables. It used both repeated-character and deterministic varied ASCII output. All 32 combinations were repeated in a fresh process/directory with matching reported results.

    Metadata-only mutation Combined JSON: WAL bytes Same-row two columns: WAL bytes Separate tables: WAL bytes
    Same-length metadata change 8,272 8,272 8,272
    Revision 9 → 10 (+1 metadata byte) 1,071,232 1,071,232 8,272
    First observedAt on a completed run (+27 bytes) 1,071,232 1,071,232 8,272
    Transition to completed with terminal fields (+43 bytes) 1,071,232 1,071,232 8,272

    Both output patterns and both split-column orders produced the same WAL totals. The large cases had 260 WAL frames, including 257 overflow-page frames with changed page images. Separate-table metadata updates touched no pages belonging to the output table. Output equality and PRAGMA integrity_check passed in every case.

    These updates assigned started_at as well as the changed JSON column, matching the current Store's SQL; the small total includes an additional ordering-index frame. WAL bytes are not total filesystem/device write amplification.

    The counterexample is the important result: a metadata-length change can rebuild the large SQLite record and rewrite its overflow chain even without assigning output_json. This is a physical-layout diagnostic, not an end-to-end CPU/latency benchmark, a production speedup claim, or sufficient evidence to select a production schema.

    Phase 1: isolate metadata/output work, then choose the physical layout

    This phase addresses metadata/output coupling only. Select the layout before committing to a schema migration.

    Layout alternatives

    metadata_json contains ShellRun identity, command, lifecycle state, timestamps, revision, and sandbox fields. output_json contains only PipeShellOutput or PtyShellOutput. started_at remains the scalar projection for Session ordering.

    Layout Benefit Limitation / obligation
    Same row, metadata_json + output_json Metadata-only updates can avoid JavaScript serialization of unchanged output and avoid assigning the output column. Existing single-row structure is retained. No guarantee of output-page or WAL isolation. Metadata-length changes can still rewrite the large row.
    Separate metadata and output tables Metadata-only updates can avoid the large output record's physical rewrite; the diagnostic demonstrates a real isolation benefit. Maintain row existence, creation/deletion/migration, atomic multi-row writes, and consistent read snapshots.

    I retract the earlier statement that a second table provides no relevant benefit. Two tables do not weaken SQLite transaction atomicity; they add invariants the adapter must enforce.

    If the scoped objective is reduced JavaScript encoding work, same-row columns remain a candidate. If it includes preventing metadata-only mutations from rewriting the large output record, separate tables should be evaluated directly. Do not choose solely from the micro-diagnostic: compare both through the real Store/Manager paths with representative workloads.

    Interface and ownership

    Keep the existing complete-record ShellRunStore interface:

    createShellRun(record): Promise<ShellRunRecord>
    updateShellRun(sessionId, shellRunId, patch): Promise<ShellRunRecord>
    readShellRun(sessionId, shellRunId): Promise<ShellRunRecord>
    listSessionShellRuns(sessionId): Promise<ShellRunRecord[]>

    The SQLite adapter owns the physical split, reconstruction, transactions, and migration. Runtime should not learn about the layout or duplicate the state machine. An internal Storage codec should be shared by migration and normal reads/writes.

    Within the existing write transaction:

    1. Read and reconstruct the current complete record.
    2. Apply nextShellRunRecord(current, patch).
    3. Return unchanged on a no-op.
    4. Encode changed metadata.
    5. Encode and assign output only when the normalized output actually changed.
    6. Commit metadata, output, and revision together: one statement for the same-row layout, or one transaction for the two-table layout.

    For two tables, complete-record reads must use one joined statement or an explicit read transaction so they cannot mix metadata from one commit with output from another. Missing/inconsistent rows must be rejected rather than silently reconstructed.

    Keeping the complete-record return type means metadata-only updates still read/parse output in this design. Splitting the schema also does not automatically remove the existing equality checks; unchanged strings have fast paths, so a full MiB scan on every metadata mutation should not be assumed. Measure the remaining work rather than claiming output CPU cost is eliminated. Removing the remaining parse is a separate interface/ownership decision.

    Migration

    Only after selecting and validating the layout:

    • Bump SQLITE_CORE_EXECUTION_SCHEMA_VERSION to the next version; current inspected schema is v9, so v9 → v10 if no intervening migration lands.
    • Build the selected replacement table(s), including required indexes and constraints.
    • Parse and normalize every old record_json, then encode both parts using the production codec.
    • Validate all converted rows before retiring the old representation; preserve identities, ordering, revisions, and output.
    • For two tables, verify one output row per metadata row and the intended deletion behavior.
    • Recreate core_shell_runs_session_order, update the operational schema registry, and require assertCurrentOperationalTargetSchema() to accept the exact final shape.
    • Perform the entire migration in the existing operational-state migration transaction. Malformed rows or migration failures must roll back to the unchanged old database.

    Report representative existing-row count, migration elapsed time, peak temporary disk use, and DB/WAL growth.

    Phase 1 acceptance and measurements

    Behavioral coverage should include:

    • Pipes and PTY create/read/list/update round-trips.
    • Metadata-only mutations leave output content unchanged and do not assign/re-encode output.
    • Output-only and combined mutations preserve revision semantics; no-ops do not advance revision.
    • Immutable output mode, immutable terminal outcomes, and terminal-only/first-write-only observedAt.
    • Malformed payloads, identity disagreement, and (for two tables) missing counterpart rows are rejected.
    • Cross-process visibility and coherent metadata/output reads during concurrent updates.
    • Migration of pipes, PTY, multiple Sessions and ordering; malformed-row rollback, reopen, and idempotent current-schema startup.
    • Atomic creation, terminalization, and applicable deletion/retirement paths for the selected layout.

    Performance comparisons must identify before/after commits and include 1 MiB and 2 MiB output with:

    • Same-length metadata changes.
    • Revision digit growth, such as 9 → 10.
    • First observation of a completed run.
    • Terminalization with and without new output.
    • Actual output-changing checkpoints.

    Measure JavaScript encoding/decoding work separately from SQL assignments and physical WAL/page writes; report transaction median/p95, CPU, and applicable allocation/memory metrics. Use the default checkpoint configuration for representative runs; disabled-checkpoint runs are a separate accounting diagnostic. Include realistic table sizes and mutation mixes, not only repeated equal-length timestamps.

    A test showing that UPDATE omits output_json is not evidence that output pages were not written.

    Decision gate: specify recovery requirements before changing flush behavior

    Maintainer question:

    What age/amount of uncommitted output is acceptable after abrupt Runtime Host termination? Is the current 1,000 ms scheduling interval only an implementation default, or is a stronger recovery guarantee required? What scheduling, write-latency, and failure assumptions should that guarantee include?

    Until answered, preserve the existing automatic flush behavior and defaults:

    DEFAULT_SHELL_RUN_FLUSH_INTERVAL_MS = 1_000
    DEFAULT_SHELL_RUN_FLUSH_BYTES = 64 * 1024

    Two implementation details matter:

    • The 1,000 ms value is a scheduling interval, not a hard maximum crash-loss window. Event-loop delay, queued work, and storage latency can delay the commit.
    • Despite its name, the pipes threshold currently accumulates data.length in pendingFlushChars (JavaScript string code units), not UTF-8 bytes. scheduleAutomaticFlush() also returns early when a timer or automatic flush is already pending. It is therefore not an unconditional “persist immediately at 64 KiB” contract.

    Do not silently change those semantics inside the storage-layout PR.

    Live Read/inspect already goes through persistObservation(live): it cancels a pending timer and persists a current snapshot cut. Preserve and strengthen tests for this path, along with stop, finalization, foreground return, normal shutdown, and PTY operations requiring a durable cut.

    If a looser checkpoint/recovery target is explicitly accepted

    Evaluate adaptive full-checkpoint coalescing before introducing a new log format:

    • Define the threshold unit explicitly: preserve the current code-unit measure or deliberately specify a byte measure. If using bytes, define where they are counted relative to decoding, redaction, and retention.
    • Allow a reached threshold to replace a pending age timer and request a flush, while retaining serialized writes and tracking output arriving during an in-flight write.
    • Track the oldest still-unpersisted output and use an explicit scheduling-age target, for example five seconds if approved. Do not reset that age merely because new output arrived.
    • Preserve forced snapshot cuts on observation and normal termination/control paths.
    • Commit final output, status, exit code, completion time, and revision atomically.

    A timer schedules work; it does not guarantee that a commit completes within that age under overload or I/O failure. A strict time/byte loss bound would need explicit enforcement and failure/backpressure behavior, not just a larger timer.

    Recovery must remain “the last committed checkpoint after abrupt Host loss.” For normal paths, specify the admitted-output snapshot cut that must be committed before successful return.

    Tests should cover threshold crossing while a timer exists, Unicode/unit semantics, oldest-pending age, delayed/in-flight writes, output arriving during persistence, Read replacing a timer, final atomic settlement, persistence failure, and restart from the last committed checkpoint.

    If existing cadence must be retained, or a strict loss bound is required

    Do not infer a strict one-second guarantee from the current implementation, and do not weaken the agreed contract just by increasing a timer.

    Extend real-path measurements before deciding whether complete checkpoints are acceptable or need a different representation:

    • At least 60 seconds after a 1 MiB tail has saturated.
    • 4 KiB/s and 64 KiB/s output rates.
    • stdout-only and stdout/stderr workloads.
    • 1, 8, and 32 concurrent ShellRuns.
    • Default WAL auto-checkpoint behavior.
    • CPU, RSS, WAL/checkpoint work, transaction median/p95, and shared-database write-lock wait.
    • Impact on unrelated operations sharing runtime.sqlite.

    The earlier short baseline does not establish acceptable cost for long-running or concurrent ShellRuns. Its approximately 6 MiB manager trace included the initial fill checkpoint and final observation; it should not all be attributed to the subsequent small increments. The bounded tail limits snapshot size, not cumulative writes over the run's lifetime.

    If measured interference is acceptable, an evidence-backed scope decision remains a valid deliverable. If it is unacceptable and permitted coalescing is insufficient, consider pipes-only checkpoint plus bounded deltas. That design needs explicit recovery/compaction rules for stdout/stderr ordering, retained-tail prefix removal, redaction across chunks, oversized-line safety, atomic revision publication, and interrupted compaction. PTY should remain on full screen checkpoints.

    Revised delivery sequence

    1. Compare same-row and separate-table isolation on real Store/Manager workloads; select the layout against explicit CPU and WAL objectives.
    2. Implement the selected layout and transactional migration without changing flush/recovery behavior.
    3. Obtain the maintainer recovery-contract decision and complete sustained/concurrent measurements. These investigations can proceed in parallel with Phase 1.
    4. Only with an approved looser target, evaluate adaptive full-checkpoint coalescing and its scheduling/failure tests.
    5. Consider pipes-only deltas only if the measured interference remains unacceptable under the permitted checkpoint policy.

    The guiding rule remains: remove avoidable metadata/output coupling, then let measured interference and the recovery contract determine the next step. SQL column separation must not be presented as guaranteed page isolation, and timer settings must not be presented as hard durability bounds.

  5. added
    tracking
    on Sep 17, 2026
  6. ggbdpq commented on Sep 28, 2026

    @ggbdpq
    Contributor

    Status of delivery checklist item 5 - "Accept the Storage/protocol portion of Usage bounded reads through #4058 / #5023, including the All-range scenario in #5019": every anchor is closed, only the checkbox is waiting.

    Anchor chain, all verified closed:

    anchor how it settled
    #4058 (revision-consistent Usage reads) implemented by #5387 (c980b93a3): single read transaction + revision fence + keyset cursor; the wire contract from the closed #5023 design (screen_response_too_large section/entry/message caps) landed there too, with coverage in usage-screen.test.ts
    #5019 (All-range hang) closed 09-18 - the original reporter re-verified on an existing 6,544-record profile: All range returns a bounded 50-row first page (the original bug was unbounded renderer materialization: 4.4GB footprint, pegged core, unresponsive Cmd+Q)
    #5515 (SQL-layer successor: page queries still scanning the residual time range) fixed by #5514: per-source indexed seek taking <=51 candidates into a global merge, no-filter counts reusing full statistics, zero-count short-circuit
    #5517 (filter changes recompute range statistics) merged 09-25: statistics projection cached by revision+range, repeated aggregation 5 -> 0

    Against this tracker's acceptance wording for the item ("measure SQL scan/sort work as well as application decoding and transfer"):

    • SQL scan/sort: measured - perf(storage): bound Usage page queries and avoid redundant counts #5514 recorded EXPLAIN QUERY PLAN (index seeks on (ts, storage_key)), outer temp B-tree input bounded at <=153 candidates, and function-evaluation counts (50k-record paging: 99,900 -> 51 lowercase evaluations), plus deterministic work regressions that fail on the baseline.
    • Application decode: measured (via the real readUsageScreen facade including row decode) - 50k-record paging median 53.5ms -> 0.8ms, independent of history depth.
    • Transfer: bounded by construction, not separately measured - the fix(usage): read revision-consistent screens and activity pages #5387 wire caps and the screen_response_too_large rejection path are tested, so transfer cannot grow unboundedly with history; raw wire bytes were however never recorded as a number (perf(storage): bound Usage page queries and avoid redundant counts #5514 explicitly excluded wire serialization). If the literal number is wanted, extending scripts/perf/usage-pages.mjs to serialize readUsageScreen results through protocol/codec.ts and report bytes per page/screen is a small addition - happy to do it.

    Unless the maintainers want that last number, this item looks ready to tick. Source inspection on current main confirms the shape: per-source ORDER BY ts DESC ... LIMIT 51 subqueries merged globally, statistics reuse, cursor trimmed for two-column index seeks; the remaining range-level scans (full statistics, exact filtered counts, sparse substring search) are the explicitly exempted ones.

  7. Astro-Han commented on Nov 5, 2026

    @Astro-Han
    ContributorAuthor

    Closing: this targets the TypeScript implementation on main, which is superseded by rust-preview (#6366). If it still applies to rust-preview, please open a new issue against it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

tracking

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions