Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions crates/capi/tests/resource_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn RandomSource>`, 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);
Expand Down
7 changes: 6 additions & 1 deletion docs/REALTIME_DEPENDENCY_POLICY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading