Expand description
Shared runners for the bench harness (benches/bench.rs) and the
sub-VM benches (benches/sub_vm_recurse.rs,
benches/sub_vm_data_recurse.rs).
The bench measures the full per-invocation lifecycle:
Nub::put_cap_with_hashfor each cap the invocation requires (Data blobs the Image references, the Image itself, the empty root cnode, the Instance). Each put is a singleBTreeMap::get + refcount.fetch_add(1)after warm-up — i.e. a few tens of nanoseconds per cap.Nub::invoke_cached(instance_hash, endpoint, args, gas).
run_interpreter—Nub::new_local()drives the byte-PVM interpreter (javm-exec) in-process.run_recompiler— the process-wideNub::hyperlight()singleton drives the in-kernel JIT path through the sameinvoke_cachedAPI.
BuiltCaps holds the pre-built Cap graph + its precomputed
hashes. Construction happens once per workload at bench warm-up via
BuiltCaps::for_image; the iter loop reuses the resulting handles.
Linux x86-64 only — nub pulls the Hyperlight host stack
unconditionally.
Structs§
- Built
Caps - Pre-built
Capgraph for one (image, endpoint) bench cell. - PtCache
Top - Top instance of the page-table-cache bench: a single image whose
endpoint 0 (
A)derive_spawns a child of the same image once and repeatedlyhost_calls its echo endpoint (B). - RawRun
- Raw invocation outcome for differential testing — the four
InvocationResultfields with no clean-halt assertion. - SubVm
Top - Top-of-recursion
Cap::Instancepublished for a sub-VM bench.
Constants§
- ABORT_
SENTINEL exit_reasonreported when a recompiler run aborts the VM — a guest CPU fault delivered as an unhandled IDT vector (e.g.#DEfromidivon INT_MIN/-1) surfaces as a hostErr(GuestAborted), not anInvocationResult. Distinct from every real PVM2 exit reason (0..=7).- INITIAL_
GAS - Default initial-gas budget for the bench.
Functions§
- build_
pt_ cache_ top - Build + publish (once) the page-table-cache image and its top
Instance into
nubfrom the SSZ-encoded Imageblob. Returns the top instance hash so the bench loop can invoke endpoint 0 directly. - build_
sub_ vm_ top - Build + publish (once) the recurse Image, its cnode, and the top
Instance into
nubfrom the SSZ-encoded Imageblob. Returns the top instance hash so the bench loop can invoke it directly. - hex_
short - First 8 bytes of a
CapHashas lowercase hex (bench logging). - invoke
- Bench helper: drive one invocation through an already-locked Nub.
Used inside
iter_batched’s routine closure so the timed body is just the host-call round-trip + JIT path (no mutex acquire, no cap publish, no sandbox rebuild). - invoke_
pt_ cache - One page-table-cache bench iteration: invoke endpoint 0, which
host_calls the residentBntimes. Asserts a clean trampoline halt and that the summed echoes match. Returns(return_value, gas_used). - invoke_
sub_ vm - One sub-VM bench iteration: invoke the top instance with
depthand panic unless it halted cleanly on the trampoline HostCall(0). - invoke_
sub_ vm_ expect - Like
invoke_sub_vmbut also asserts the top-level return value. Used by the data-recurse correctness check to confirm each level reads its pinned RO data + writes its initial RW data correctly (not just that it halts). - invoke_
sub_ vm_ gas - Like
invoke_sub_vmbut returns(return_value, gas_used)after asserting a clean trampoline halt. Used by thesub_vm_gas_paritytest to check the recompiler’s category-#3 charge is identical per recursion level (gas affine in depth — a multi-frame determinism guard). - nub_
hyperlight_ lock - Bench-side accessor for the long-lived Hyperlight Nub. Returned
guard holds the singleton mutex for the duration of one
criterion
iter_batchedstep (setup + routine). - run_
interpreter - Drive
built[endpoint_idx]through the PVM2 (RISC-V) interpreter via a freshNub::new_local()(the Local backend has no per-invocation state, so a fresh Nub each call is fine — and matches the chain’s per-event allocation model). - run_
interpreter_ raw - Interpreter run with no clean-halt assertion (cf.
run_interpreter). The Local backend never aborts the host, soinvoke_cachedreturnsOkin practice; anErris still mapped to the abort sentinel for symmetry with the recompiler. - run_
pt_ cache_ bench - Run the page-table-cache criterion bench: endpoint 0
host_calls the residentBa swept number of times. Publishes the top once (the kernel stays warm), runs an n=1/2 sanity check, then sweeps{10, 100, 1000}CALLs withThroughput::Elements(n)so the reported figure is per-CALL. - run_
recompiler - Drive
built[endpoint_idx]through the in-kernel JIT via the long- lived HyperlightNub. Warm-cache path: subsequent calls with the same Image hit the JIT compile cache. Useful for measuring steady-state execute throughput in isolation. - run_
recompiler_ raw - Recompiler run with no clean-halt assertion (cf.
run_recompiler). - run_
recurse_ bench - Run the full sub-VM recurse criterion bench for
blob, labelledlabel. Publishes the top instance once (the kernel stays warm: the JIT cache holds the compiled image, the cap cache holds the Image/Top-Instance/CNode), runs a depth-0/1 sanity check, then sweeps depths {10, 100, 1000}.
Type Aliases§
- NubGuard
- Cloneable handle to the process-wide Hyperlight Nub.