[PR #1687] [MERGED] perf(domain): reuse canonical JSON key encodings #4754

Closed
opened 2026-10-31 00:54:42 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1687
Author: @N0zoM1z0
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @N0zoM1z0

Base: main ← Head: perf/flameox-hotspots-20261011


📝 Commits (1)

  • 82c6ff6 perf(domain): reuse canonical JSON key encodings

📊 Changes

2 files changed (+52 additions, -13 deletions)

View changed files

📝 src/domain/canonicalJsonDigestSteps.test.ts (+18 -0)
📝 src/domain/canonicalJsonDigestSteps.ts (+34 -13)

📄 Description

Canonical hashing is a measurable REA-owned hotspot in an actual small-target CLI CPU profile. Repeated graph keys were JSON-encoded for every object and each member allocated a temporary value frame. This change reuses exact key encodings within one existing 8,192-code-unit buffer quantum and processes member values directly. Fallback encoding, canonical bytes, cooperative yields and complete results remain available.

It also repairs a reproduced domain error: when a pending property is deleted during a cooperative pause, its object frame was discarded and later properties were omitted from the digest. The iterator now resumes that object. This is a domain-continuation reproduction; normal sealed application graphs are immutable.

Refs #1065. Existing #904/#994 already solved per-fragment crypto-update crossings; this follow-up addresses key encoding and iterator allocation in the newer cooperative digest. No currently open overlapping digest PR was found with gh before publication.

Validation uses pinned Flameox 0.2.9, Node 24.18.0/npm 11.16.0, Linux, CPUs 13/15 and nice 10. One local heavy lane runs at a time, with a 768 MiB outer Node heap, 2 GiB family RSS guard, 2 GiB host reserve and 90-second per-command guard. The target JavaScript is analyzed statically and never executed.

  • Real public CLI CPU and V8 sampling-heap captures: a 29,458-byte owned JavaScript source, complete CLI output. The initial CPU capture contains 2,919 exported samples, including 113 self samples in canonicalJsonDigestSteps. Profiles guide this experiment; they are not speedup percentages or source-analyzer-child attribution.
  • Flameox randomized paired digest experiment: seven blocks, two cases, seed 20261011, 12 digest iterations after two warmups per process, the same complete normalized application result. All 14 semantic oracles pass. Capture-process medians are 1,184.00 ms baseline and 943.54 ms candidate (about 20% lower). Paired median difference is -222.62 ms, bootstrap 95% interval [-250.01, -216.98] ms. This is local digest-workload evidence, not full CLI speedup or model token billing.
  • Structural control of that complete result: JSON encoding calls 339,896 -> 138,335; temporary member value frames 215,137 -> 0; both retain exactly 736 cooperative yields and the same complete canonical SHA-256. Large-key continuations still use their necessary frames.
  • Separate full CLI experiment: five randomized paired blocks, all ten complete-result/Evidence-ID/input/progress-byte oracles pass. Paired median difference -63.07 ms with 95% interval [-1,964.56, +329.03] ms. This does not establish end-to-end acceleration; whole-analysis timing remains noisy.
  • Real compiled public CLI and pinned-SDK stdio MCP: a 6,686-byte source before/after control retains the entire normalized result and Evidence ID, text/structured parity, unchanged source and a subsequent successful ping. The larger target reaches the existing typed MCP receive-buffer constraint; its complete analysis remains retained and the connection still pings. No result truncation or transport-budget change is introduced.
  • 81 related tests across eight files pass, including canonicalization property checks, escaped/long/supplementary Unicode keys, cache overflow, repeated references, cancellation/abandonment, sparse arrays, nonfinite numbers/cycles, complete large literals, prior Evidence retention and subsequent MCP work. All eight static/documentation/architecture/discovery checks pass. Fresh six-step build/metadata and final committed-source public controls pass.

Local target/profile/experiment receipts live in /tmp/rea-flameox-performance-20261011; generated runtime, catalog and temporary tool environment are excluded from the commit. No real Hopper/Ghidra, browser, Electron target runtime, full Notion/Obsidian, or previously failing full Bun-directory behavior is claimed. Final-source CI is pending.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1687 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `perf/flameox-hotspots-20261011` --- ### 📝 Commits (1) - [`82c6ff6`](https://github.com/morluto/rea/commit/82c6ff66e183f2bae3268a38af46360356cce691) perf(domain): reuse canonical JSON key encodings ### 📊 Changes **2 files changed** (+52 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/canonicalJsonDigestSteps.test.ts` (+18 -0) 📝 `src/domain/canonicalJsonDigestSteps.ts` (+34 -13) </details> ### 📄 Description Canonical hashing is a measurable REA-owned hotspot in an actual small-target CLI CPU profile. Repeated graph keys were JSON-encoded for every object and each member allocated a temporary value frame. This change reuses exact key encodings within one existing 8,192-code-unit buffer quantum and processes member values directly. Fallback encoding, canonical bytes, cooperative yields and complete results remain available. It also repairs a reproduced domain error: when a pending property is deleted during a cooperative pause, its object frame was discarded and later properties were omitted from the digest. The iterator now resumes that object. This is a domain-continuation reproduction; normal sealed application graphs are immutable. Refs #1065. Existing #904/#994 already solved per-fragment crypto-update crossings; this follow-up addresses key encoding and iterator allocation in the newer cooperative digest. No currently open overlapping digest PR was found with `gh` before publication. Validation uses pinned Flameox 0.2.9, Node 24.18.0/npm 11.16.0, Linux, CPUs 13/15 and nice 10. One local heavy lane runs at a time, with a 768 MiB outer Node heap, 2 GiB family RSS guard, 2 GiB host reserve and 90-second per-command guard. The target JavaScript is analyzed statically and never executed. - Real public CLI CPU and V8 sampling-heap captures: a 29,458-byte owned JavaScript source, complete CLI output. The initial CPU capture contains 2,919 exported samples, including 113 self samples in `canonicalJsonDigestSteps`. Profiles guide this experiment; they are not speedup percentages or source-analyzer-child attribution. - Flameox randomized paired digest experiment: seven blocks, two cases, seed 20261011, 12 digest iterations after two warmups per process, the same complete normalized application result. All 14 semantic oracles pass. Capture-process medians are 1,184.00 ms baseline and 943.54 ms candidate (about 20% lower). Paired median difference is -222.62 ms, bootstrap 95% interval [-250.01, -216.98] ms. This is local digest-workload evidence, not full CLI speedup or model token billing. - Structural control of that complete result: JSON encoding calls 339,896 -> 138,335; temporary member value frames 215,137 -> 0; both retain exactly 736 cooperative yields and the same complete canonical SHA-256. Large-key continuations still use their necessary frames. - Separate full CLI experiment: five randomized paired blocks, all ten complete-result/Evidence-ID/input/progress-byte oracles pass. Paired median difference -63.07 ms with 95% interval [-1,964.56, +329.03] ms. This does **not** establish end-to-end acceleration; whole-analysis timing remains noisy. - Real compiled public CLI and pinned-SDK stdio MCP: a 6,686-byte source before/after control retains the entire normalized result and Evidence ID, text/structured parity, unchanged source and a subsequent successful ping. The larger target reaches the existing typed MCP receive-buffer constraint; its complete analysis remains retained and the connection still pings. No result truncation or transport-budget change is introduced. - 81 related tests across eight files pass, including canonicalization property checks, escaped/long/supplementary Unicode keys, cache overflow, repeated references, cancellation/abandonment, sparse arrays, nonfinite numbers/cycles, complete large literals, prior Evidence retention and subsequent MCP work. All eight static/documentation/architecture/discovery checks pass. Fresh six-step build/metadata and final committed-source public controls pass. Local target/profile/experiment receipts live in `/tmp/rea-flameox-performance-20261011`; generated runtime, catalog and temporary tool environment are excluded from the commit. No real Hopper/Ghidra, browser, Electron target runtime, full Notion/Obsidian, or previously failing full Bun-directory behavior is claimed. Final-source CI is pending. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:54:42 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4754
No description provided.