diff --git a/crates/capi/tests/resource_lifecycle.rs b/crates/capi/tests/resource_lifecycle.rs index 24ff7654b..0e0e35a33 100644 --- a/crates/capi/tests/resource_lifecycle.rs +++ b/crates/capi/tests/resource_lifecycle.rs @@ -130,7 +130,23 @@ fn snapshot() -> Snapshot { } } +/// Initialize the process-lifetime statics that the JSON frontend's dependencies create lazily, +/// so the first observed window is not charged for them. +/// +/// `json-syntax` 0.12.5 indexes every object through `hashbrown` 0.12's `DefaultHashBuilder`, +/// which is `ahash` 0.7's `RandomState`. Its first construction in a process boxes three +/// `once_cell::race::OnceBox` statics (`RAND_SOURCE`, its inner `Box`, and the +/// `SEEDS` array: 8 + 16 + 64 bytes) that live until process exit and belong to no capi owner. +/// ahash's `build.rs` forces `runtime-rng` on every hosted target, so no Cargo feature removes +/// them. They land on whichever thread parses the first object, which under the parallel +/// harness is a race between this file's tests; parsing a trivial object here makes every +/// window start after that initialization on this thread, independent of sibling scheduling. +fn warm_process_lifetime_statics() { + let _ = session::parse_session_json(r#"{"warm":0}"#); +} + fn begin() { + warm_process_lifetime_statics(); // Initialize the thread-local keys before observation is armed. ACTIVE.set(false); ALLOCATIONS.set(0); diff --git a/docs/REALTIME_DEPENDENCY_POLICY.md b/docs/REALTIME_DEPENDENCY_POLICY.md index dc3d173b6..505ca219d 100644 --- a/docs/REALTIME_DEPENDENCY_POLICY.md +++ b/docs/REALTIME_DEPENDENCY_POLICY.md @@ -343,7 +343,12 @@ Parser allocation and diagnostic formatting are expected control-plane behavior. returns typed diagnostics; arithmetic and configured-cap preflight runs before the canonical string, model clone, normalized indexes, or downstream plan work. JSON string and duplicate-key fixtures, the strict unknown-key matrix, target compilation, and parser/compiler fuzz targets are -the compatibility and failure-mode evidence for this dependency choice. +the compatibility and failure-mode evidence for this dependency choice. `json-syntax`'s object +indexing goes through `hashbrown` 0.12's default hasher, `ahash` 0.7's `RandomState`, which on its +first construction in a process lazily allocates 88 bytes of process-lifetime heap and seeds from +OS entropy per process -- harmless to every shipped cap (they are explicit row sums), but relevant +to any exact allocator oracle that arms across the first object parse in a process (see +`crates/capi/tests/resource_lifecycle.rs`). The earlier issue-004 cross-target archive sizes are historical measurements for the retired parser stack and are not projected onto the JSON implementation. Current size and allocation