Files
prometeu-runtime/docs/vm-arch/registry-layout-evidence.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

9.1 KiB

Registry layout, load and GC evidence

This report records bounded technical fixtures for Registry layout, loading and GC. The normative contract is Program Registry and PBX v0; producer obligations and publication status are in the producer handoff. Registry Boundaries and Owned Values explains the published mechanisms.

Measured on 2026-10-07: Darwin arm64, Rust 1.98.1 (48a229cea), host aarch64-apple-darwin, LLVM 22.1.8, optimized Cargo release profile. The code baseline is c6fff08; this report's commit also contains the load high-water instrumentation and measurement fixtures. Wall-clock values are single observations, not thresholds or statistically established throughput. No timing assertion is used.

Reproduction

cargo test -p prometeu-bytecode --release --test registry_v0 reference_map_probe -- --ignored --nocapture
cargo test -p prometeu-vm --release --lib probe -- --ignored --nocapture --test-threads=1
cargo test -p prometeu-vm --release --lib decoded_trait_box_is_the_only_receiver_root_across_frame_sync_gc --quiet
cargo test -p prometeu-vm --lib ownership_tests --quiet

The first probe compares ownership-map traversal with a synthetic bitmap. The second executes complete sealed-image loading, typed-array allocation/access, object tracing and native-owner cleanup. Its tests run sequentially. Fixtures construct internal typed containers; guest collection allocation/read/write operations are outside the measured instruction surface. No new collection instruction or cost is inferred from native helper timings.

Native representation and typed-array access

Native sizes/alignment in bytes on this target:

Carrier or owner Size Alignment
Value 24 8
HeapRef 8 8
StringSlot 16 8
DynamicSlot 32 8
Compact trait slot 16 8
StoredObject 416 8

Value remains the execution carrier. Arrays use resolved storage directly. The fixture allocates 4,096 default-initialized elements per array in a fresh heap, checks the last element, then performs 100,000 checked load_typed reads with black_box. It does not allocate a result Vec per read. Reference/native arrays below contain their null defaults, so these access times do not measure live-handle validation or String cloning throughput.

Element Stride / alignment Guest bytes Auxiliary bytes Allocation ns 100,000 reads ns
int32 4 / 4 16,800 60 45,709 2,439,084
bool 1 / 1 4,512 60 14,792 2,348,666
vec2 16 / 8 65,952 60 18,167 2,220,125
pixel 24 / 8 98,720 60 17,208 2,469,125
Struct reference 8 / 8 33,184 60 21,833 1,990,667
String 16 / 8 65,952 60 15,042 2,069,584
Trait 16 / 8 65,952 60 13,500 2,019,667
Dynamic 32 / 8 131,488 60 17,875 2,330,000

Each case owns one handle. Guest bytes equal one actual StoredObject plus count * stride. Auxiliary bytes are the initial generational-table capacities, separate from element storage and Registry metadata. After marking the array it survives; after an unrooted sweep guest bytes return to zero, and dropping the heap releases retained auxiliary tables. Native header sizes are implementation details, not PBX fields or portable guest ABI promises.

Complete load and scratch ownership

The sealed-image fixture contains one named bool type, one named zero-argument HALT function and 512 distinct 64-byte String constants; no debug records or native calls.

Measurement Value
PBX bytes 35,520
Retained Registry bytes 587
Retained image payload accounting 65,880
Deterministic load work units 204,641
Peak admitted temporary bytes 77,906
Temporary bytes after publication 0
String content bytes / allocations 32,768 / 512
Complete load ns 184,416

LoadBudget::peak_usage measures the highest successfully admitted reservation total in a budget's lifetime. Refunds and failed transactions retain that high-water mark; rejected charges do not increase it. The associated test proves rollback restores current ownership while preserving attempted work and peak history. These are accounted capacities and coexistence reservations, including conservative native owner sizing; they are not allocator telemetry or process RSS. Image payload, constant content and PBX admission are different counters, so this table must not be summed into a physical-memory total. A single fixture does not establish worst-case load work or peak scratch at the 64 MiB PBX ceiling.

Ownership maps and actual object GC

The map-only fixture has 4,096 eight-byte fields, with a reference every period fields. It traverses the resolved ownership list and a synthetic bitmap 10,000 times and checks equal offsets/checksums. Its Registry has only the three types needed for that comparison.

Period Mapped entries Registry bytes List / bitmap bytes Resolve ns List traversal ns Bitmap traversal ns
1 4,096 262,816 65,536 / 512 271,709 8,048,708 62,797,875
16 256 201,376 4,096 / 512 121,083 819,584 4,254,000
256 16 197,536 256 / 512 30,959 89,458 442,791

The actual GC fixture extends the storage test Registry with a 4,096-field Struct. Every mapped reference aliases the same live child; an unrelated child is unrooted. The one holder root retains exactly two objects after mark/sweep. It repeats 1,000 collections, verifies that the unrelated handle is invalid and releases the temporary mark worklist on every collection.

Period Mapped entries Live guest bytes Retained auxiliary bytes Resolve work Resolve peak scratch 1,000 GC rounds ns
1 4,096 33,600 180 16,765 312 15,308,125
16 256 33,600 180 16,765 312 1,039,625
256 16 33,600 180 16,765 312 138,916

Mapped entries are edges, not distinct worklist roots. Repeated aliases enqueue the child once. Retained auxiliary capacity includes the swept object's reusable handle slot. Resolve scratch here measures direct Registry resolution, not complete PBX decoding. The timing shows the expected dependence on mapped edges for these fixtures; it does not establish pause times for a broad object graph or justify changing the accepted map representation.

Dynamic conversion and native ownership

A vec2 pack creates one immutable box with 464 guest bytes: the 416-byte structural owner plus two 24-byte Values. The observed pack took 1,000 ns; 100,000 exact vec2 unpacks took 2,816,583 ns. Storing the Dynamic pair in a typed array, marking that array and sweeping retains the box; removing the root releases its guest charge. Separate conformance tests prove repeated Dynamic copies/repacking preserve the box handle, typed-null traits allocate no box and malformed category/type/width/handle combinations fail.

Decoded guest operations have independently asserted attempt costs: Dynamic pack/unpack/query = 8/4/3, reference exact/implements/cast = 4, reference-to-trait = 5. Each charges once on success or trap. Native timings above do not redefine those costs.

The decoded trait-box test removes the original global receiver owners, then reaches FRAME_SYNC through the sealed image. GC retains the box and receiver solely through the operand-stack Dynamic pair. After unpack and two POPs, the next permitted GC invalidates both handles and retains the entry coroutine. This proves the real interpreter/safepoint path as well as the internal container path.

The native fixture stores one session-imported 13-byte String in both a String field and a direct Dynamic field: two storage owners, one content allocation and one charge. Rooted collection retains it; unrooted collection drops both owners and ledger reconciliation releases content/allocation charges. The focused ownership test additionally removes the String field while the Dynamic alias remains, checks Arc identity and proves only the final owner permits release. Image constants, cross-session imports and retained native snapshots have separate integration tests.

Publication boundary

The sealed v0 image, bounded verifier, typed direct calls, Dynamic/reference execution, metered native strings and structured host diagnostics have executable evidence. Production VirtualMachine::initialize and both example generators now use the validated Registry format with typed callables and mandatory captures. The PBX version remains 0 during development; the producer handoff describes the current schema.

These measurements cover bounded layout/load/access/ownership/GC behavior. Representative-game capacity/headroom and coordinated long-run stress require separate workloads and evidence. No external compiler implementation, cross-host stress acceptance, regenerated production PBX smoke or final production activation is claimed by this report.