[PR #1264] [MERGED] perf(snapshot): avoid redundant result copies and serialization #2749

Closed
opened 2026-10-17 21:09:48 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: perf/snapshot-materialization


📝 Commits (1)

  • 569d2bc perf(snapshot): avoid redundant result copies and serialization

📊 Changes

4 files changed (+183 additions, -17 deletions)

View changed files

📝 src/application/binary/AnalysisSnapshotCache.test.ts (+84 -0)
📝 src/application/binary/AnalysisSnapshotCache.ts (+11 -6)
📝 src/domain/analysisSnapshot.test.ts (+66 -0)
📝 src/domain/analysisSnapshot.ts (+22 -11)

📄 Description

Snapshot export copied complete query/workflow/Evidence payloads before the parser created another independent copy. Canonical order and target-scope checks also serialized complete payloads only to compare ordering or filtered membership. Remove those redundant passes while retaining JSON validation, Evidence integrity checks, exact target/profile bindings and atomic persistence. The snapshot format and serialized bytes are unchanged.

Validation:

  • Focused cache/domain, filesystem, composed replay and SDK MCP suites: 5 files, 39 tests passed. Added nested export independence, canonical-order and foreign-target regression coverage.
  • npm run check passed.
  • Real compiled CLI and stdio MCP reopened the existing Ghidra 12.1.4 investigation, retained all original Evidence and 3 primitive/1 workflow bindings, and saved successfully. Primitive/function reads reused retained results; the MCP batch workflow still launched Ghidra. No new replay eligibility claim is made. Real Hopper was not rerun.

Two-CPU measurements, Node 768 MiB heap, three samples per phase (milliseconds, medians):

Workload JSON bytes Validate before/after Export before/after
Generated large records 13,620,553 474 / 400 496 / 384
Generated many records 4,937,497 228 / 205 237 / 205
Real native investigation 7,584,032 645 / 577 722 / 588

Canonical output hashes matched in all cases. Sampled process-family RSS was 527/531 MB for the benchmark lanes: no peak-memory improvement is claimed. Real-native serialization was 909/970 ms in this run; this change does not claim an overall save/open speedup, streaming storage, or removal of the remaining eager parsing.

Closes #1249. Related to #1065 and #1211.


🔄 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/1264 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `perf/snapshot-materialization` --- ### 📝 Commits (1) - [`569d2bc`](https://github.com/morluto/rea/commit/569d2bc6b9f600114267a4c69f8400393ea1bc2f) perf(snapshot): avoid redundant result copies and serialization ### 📊 Changes **4 files changed** (+183 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src/application/binary/AnalysisSnapshotCache.test.ts` (+84 -0) 📝 `src/application/binary/AnalysisSnapshotCache.ts` (+11 -6) 📝 `src/domain/analysisSnapshot.test.ts` (+66 -0) 📝 `src/domain/analysisSnapshot.ts` (+22 -11) </details> ### 📄 Description Snapshot export copied complete query/workflow/Evidence payloads before the parser created another independent copy. Canonical order and target-scope checks also serialized complete payloads only to compare ordering or filtered membership. Remove those redundant passes while retaining JSON validation, Evidence integrity checks, exact target/profile bindings and atomic persistence. The snapshot format and serialized bytes are unchanged. Validation: - Focused cache/domain, filesystem, composed replay and SDK MCP suites: 5 files, 39 tests passed. Added nested export independence, canonical-order and foreign-target regression coverage. - `npm run check` passed. - Real compiled CLI and stdio MCP reopened the existing Ghidra 12.1.4 investigation, retained all original Evidence and 3 primitive/1 workflow bindings, and saved successfully. Primitive/function reads reused retained results; the MCP batch workflow still launched Ghidra. No new replay eligibility claim is made. Real Hopper was not rerun. Two-CPU measurements, Node 768 MiB heap, three samples per phase (milliseconds, medians): | Workload | JSON bytes | Validate before/after | Export before/after | | --- | ---: | ---: | ---: | | Generated large records | 13,620,553 | 474 / 400 | 496 / 384 | | Generated many records | 4,937,497 | 228 / 205 | 237 / 205 | | Real native investigation | 7,584,032 | 645 / 577 | 722 / 588 | Canonical output hashes matched in all cases. Sampled process-family RSS was 527/531 MB for the benchmark lanes: no peak-memory improvement is claimed. Real-native serialization was 909/970 ms in this run; this change does not claim an overall save/open speedup, streaming storage, or removal of the remaining eager parsing. Closes #1249. Related to #1065 and #1211. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:09:48 +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#2749
No description provided.