Skip to content

Encode short ASCII text directly in SDK CBOR frames - #2040

Merged
callumalpass merged 1 commit into
mainfrom
sdk-hot-path-contract-cursors
Nov 28, 2026
Merged

callumalpass merged 1 commit into
mainfrom
sdk-hot-path-contract-cursors

Conversation

@callumalpass

Copy link
Copy Markdown
Member

Write ASCII strings of up to 23 bytes directly into the SDK CBOR writer. These strings fit both their length and major type in one header byte. Field names, record paths and short values avoid a temporary UTF-8 allocation and copy. Longer strings and Unicode use the existing encoder. The scratch buffer follows the existing wipe path for secret-bearing messages.

Refs #1916

The checked-in contract pagination test failed at the stale-cursor assertion against 865443584 and passed against the sprint base b723b6c4e. Commit 318ddf2ec had already restored the view-version check. The test covers a continuation before a write, a confirmed write outside the result set, rejection with invalid_request/cursor_stale, and successful pagination after restarting.

Browser measurements

Chromium worker workload Base median / p95 (ms) PR median / p95 (ms)
10,000 records · encode 111.55 / 155.40 31.05 / 35.40
10,000 · message delivery 1.70 / 5.40 4.35 / 12.60
10,000 · decode and hydrate 64.70 / 89.20 62.75 / 74.80
10,000 · total 203.30 / 309.80 100.45 / 116.90
100 records · encode 1.21 / 1.31 0.32 / 0.43
100 · message delivery 0.09 / 0.15 0.04 / 0.08
100 · decode and hydrate 0.59 / 0.77 0.50 / 0.72
100 · total 2.12 / 4.49 0.89 / 1.30

Headless Chromium 157.0.8103.38 on Linux. A dedicated worker per revision encoded preconstructed SDK query-response frames with IDs, hashes, paths, status, type and frontmatter (including Unicode tags). Each page transferred its independently owned CBOR buffer via postMessage. The main thread decoded the frame and hydrated the SDK query result. The timer includes request scheduling and delivery. It excludes fixture creation, replica execution and network I/O. Delivery includes browser scheduling and increased in the 10,000-row run.

Three warm-up pairs and 12 measured pairs alternated A/B and B/A. Each 10,000-row read used ten sequential 1,000-row pages. Each small-control sample averaged 20 complete 100-row reads. The table uses the middle two values for the median and nearest-rank p95. Phase percentiles are independent.

Verification

  • Compared candidate and base output over 65,580 text cases covering all UTF-16 code units, lone surrogates, UTF-8 width boundaries, and longer payloads. Each produced identical canonical bytes or the same rejection kind.
  • SDK typecheck, build, Vitest, and Node suites via rpnpm.
  • The path-selected pnpm ci:local passed all gates through build and typecheck. Its workspace test gate reported an Editor focus assertion on Node 22 and an Editor move-notes assertion on Node 24. Both Editor files passed individually on Node 24. A full Node 24 repeat is running with CI's standard per-test retry and eight available CPUs.

@callumalpass
callumalpass added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 8bcafab Nov 28, 2026
45 checks passed
@callumalpass
callumalpass deleted the sdk-hot-path-contract-cursors branch November 28, 2026 13:22
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.

1 participant