Reuse preallocated import identities and stable recovery document views

This commit is contained in:
2026-11-10 00:59:12 +08:00
parent 5590d55bb1
commit 40f3c97bbd
8 changed files with 116 additions and 10 deletions
+25
View File
@@ -751,3 +751,28 @@ The 10000-child copy probe still exceeded its 240-second completion window after
this change. The exact hashed-input browser test proves removal of whole-image
hashing for ordinary adjacent delta writes; this is not a passed end-to-end copy
budget or a claim that encoding, rendering and dispatch costs are all resolved.
Import identity capture now reuses a frozen, own-data string dictionary when no
new ID is reserved. One active runner retains its last ID-table reference and a
reverse Set; only the first actual allocation copies both. Mutable dictionaries
and frozen getters are captured defensively, and a late reserve callback cannot
mutate an already published result. The index is cleared when the pump ends,
including pause/cancel/close/restart; the durable `stableIds` remains on ImportJob.
Allocation keeps the caller port method receiver. No task or recovery version
changes, and first-item publication/durability barriers remain in place.
Recovery also reuses frozen plain document views across metadata-only Roots.
`isFactoryDocument` identifies an envelope with fixed table membership produced
by core constructors; it is not a content-validation or deep-immutability test.
A WeakMap owns only a derived plain view. Its array/tuple containers are frozen
without freezing caller-owned records. The codec still independently checks deep
immutability, so mutable values inherited through `applyChanges` are reevaluated.
Unowned envelopes reread mutable map membership. A test prohibits document-record
enumeration during a metadata-only encode after the initial view is built.
The 1000-child copy probe completes with these paths, but the 10000-child copy
still exceeds 240 seconds. Removing ID-table copies and metadata-only document
scans is directly verified; a general throughput improvement at 10000 nodes is
not established. Per-record commit, ACK and remaining table traversal costs remain
part of the larger implementation goal.