Files
prometeu-runtime/docs/vm-arch/string-provenance-qualification.md
bquarkz a2275932a5
Intrepid/Prometeu/Runtime/pipeline/pr-master There was a failure building this commit
Keep PBX at v0 and simplify Jenkins quality gate
2026-10-14 14:35:44 +01:00

127 lines
6.9 KiB
Markdown

# String provenance qualification
Measured on 2026-10-14, macOS arm64, Rust 1.98.1, release profile. The workload
uses 1,024, 16,384 and 65,536 independently allocated equal-text owners in each
image/session domain. Setup is outside query timing. Each query row executes
1,000 operations. The native import and mixed snapshot cases call the actual VM
boundary methods; a separate diagnostics feature exposes only the fixture.
Reproduce with:
```sh
cargo run --release -p prometeu-vm --features resource-diagnostics --example string_provenance_benchmark
cargo test -p prometeu-vm --test execution_allocations --all-features
```
## Structure and ownership
Image Weak records are sorted once by allocation data address and UTF-8 length.
An in-place heap sort precharges LoadBudget work before each record comparison
(four field reads plus comparison) and swap (two reads plus two writes). The
existing scratch/retained payload accounting includes the record capacity;
sorting adds no auxiliary allocation. Constant-pool and export order, including
lease indices, are unchanged. Binary search performs at most floor(log2(N))+1
record comparisons for a nonempty table. In-place dead-record retention preserves
sorted order.
Session records use an open-addressed BudgetVec table with no strong content
owner, at most 50% live occupancy, geometric growth and tombstones. Full identity
is checked after hashing; equal text in another allocation is a miss. Growth and
same-capacity rebuild reserve the retained capacity delta in AuxiliaryBytes and
the old allocation in TemporaryBytes before allocating or moving records.
Publication reserves content and table space before constructing an Arc. Lookup
neither reserves nor resizes. Reconciliation removes a key before releasing its
Weak and content charges, preventing recycled addresses from matching stale keys.
Dead content is still reclaimed at the existing safepoints/pressure pass.
## Query work and allocator calls
| Owners per domain | Image hit comparisons before → after | Image miss comparisons before → after | Session hit probes before → after | Session miss probes before → after |
| ---: | ---: | ---: | ---: | ---: |
| 1,024 | 1024 → 10 | 1024 → 10 | 1024 → 1 | 1024 → 1 |
| 16,384 | 16384 → 14 | 16384 → 15 | 16384 → 1 | 16384 → 1 |
| 65,536 | 65536 → 16 | 65536 → 17 | 65536 → 2 | 65536 → 1 |
The hit is the last-created owner, which was last in the original linear ledger.
The miss has equal text in a distinct allocation. Hash probe observations depend
on allocator-selected addresses and are not worst-case constant-time guarantees.
A separate fixed synthetic-key collision fixture verifies chains, full keys and
tombstones. Integration tests bound image comparisons and assert zero allocations,
reallocations and deallocations for image/session hits/misses and tracked imports
at all three sizes. Ordinary string reads still access Arc directly.
All direct queries and tracked imports reported `[0, 0, 0]` allocator calls
before and after. Mixed two-value snapshots reported `[1000, 0, 1000]`, for their
Value-vector storage. Untracked imports reported `[1001, 0, 1]`: 1,000 new Arcs
plus one table growth; dead content remains Weak-tracked until reconciliation.
The benchmark asserts zero calls in the lookup regions; setup, reporting and
fixture teardown are excluded. The CI allocator oracle is thread-local.
## Supporting timings
Elapsed milliseconds for 1,000 operations; a single local run per implementation,
not a percentile estimate or a CI threshold. Warmup, allocator layout, scheduling
and CPU frequency can affect these values.
| Owners | Workload | Linear (ms) | Indexed (ms) |
| ---: | --- | ---: | ---: |
| 1,024 | `image_hit` | 1.602 | 0.058 |
| 1,024 | `image_miss` | 1.511 | 0.046 |
| 1,024 | `session_hit` | 1.160 | 0.030 |
| 1,024 | `session_miss` | 0.684 | 0.025 |
| 1,024 | `import_hit` | 1.513 | 0.101 |
| 1,024 | `snapshot_mixed` | 2.031 | 0.216 |
| 1,024 | `import_miss` | 2.233 | 0.376 |
| 16,384 | `image_hit` | 10.658 | 0.026 |
| 16,384 | `image_miss` | 11.847 | 0.023 |
| 16,384 | `session_hit` | 10.890 | 0.009 |
| 16,384 | `session_miss` | 11.412 | 0.009 |
| 16,384 | `import_hit` | 21.726 | 0.035 |
| 16,384 | `snapshot_mixed` | 33.012 | 0.083 |
| 16,384 | `import_miss` | 22.832 | 0.887 |
| 65,536 | `image_hit` | 44.191 | 0.029 |
| 65,536 | `image_miss` | 43.959 | 0.025 |
| 65,536 | `session_hit` | 47.441 | 0.010 |
| 65,536 | `session_miss` | 45.249 | 0.009 |
| 65,536 | `import_hit` | 88.518 | 0.038 |
| 65,536 | `snapshot_mixed` | 132.199 | 0.094 |
| 65,536 | `import_miss` | 90.935 | 3.137 |
## Creation and memory cost
The `image_load_ns` diagnostic includes fixture assembly/serialization and sealed
loading, not just the sort. Session setup includes the VM, ledger and retained
owners. Auxiliary measurements include that fixture's small VM/domain state;
image payload measurements include the complete immutable payload, not only its
index. These are charged native capacities, not process RSS.
| Owners | Image fixture before → after (ms) | Session setup before → after (ms) | Session AuxiliaryBytes before → after | Image payload bytes (unchanged) | Session setup allocations before → after |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 1,024 | 0.600 → 1.128 | 0.236 → 0.348 | 65,696 → 164,016 | 74,072 | 1046 → 1044 |
| 16,384 | 1.702 → 4.067 | 1.298 → 2.889 | 1,048,736 → 2,621,616 | 1,179,992 | 16410 → 16408 |
| 65,536 | 6.248 → 14.130 | 5.230 → 9.885 | 4,194,464 → 10,485,936 | 4,718,936 | 65564 → 65562 |
At 65,536 session owners the charged auxiliary footprint rises from roughly 4 MiB
to 10 MiB. The 50% occupancy policy costs capacity and increases setup work, while
removing whole-ledger traversals at native boundaries. Existing quotas are
unchanged; this metadata can reduce available headroom for other session owners.
No extra strong Arc owner, guest handle, content interning or new GC schedule was
introduced.
## Refusal and scope of evidence
Tests force initial allocation, growth and tombstone rebuild failure, auxiliary
and coexistence limits, and image sort work exhaustion. They verify no partial
entry/content publication, retained live identities and refunded provisional
charges. Allocator failures are injected at the fallible allocation seam; stable
Arc allocation can still abort on physical allocator exhaustion, as before.
Cross-session copies, native lease/snapshot survival and typed storage/root tests
remain part of the regression suite. Address ordering can change between loads;
the sort refusal fixture is bounded for either order, not tied to a prior address
layout.
These synthetic boundary measurements establish lookup work and ownership
behavior. They do not establish gameplay/frame speedups, long-run memory stability,
other-platform timings or hardware-independent latency limits. The normative
ownership contract is in [Registry and PBX](../specs/runtime/02c-program-registry-and-pbx-v0.md#memory-ownership-and-quotas).