vile / bench / native / CAPTURES-361.md
74 lines · 58 sloc · 6.84 KB · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw

Native staged scalar captures (361)

Existing scalar captured bindings can be updated inside native graphs. Tiny straight-line mutator roots stay on the VM path because their entry/commit cost exceeds their work; loops and larger native call graphs retain the helper optimization. Reads and writes that share a lexical cell use one staged value. Read-only captures merge only for identical lexical selectors; they remain independent when providers stop sharing an environment. Each entry checks alias relationships involving writable cells, including same-code closures that change environments or sharing. Plans retain selectors and alias indices; borrowed environment handles are cleared after the synchronous entry.

Captured VM cells remain unchanged during native execution. The finish callback validates every pending scalar and the return value before committing any captured cell. Failure restores journaled vector writes, discards staged captures, and replays the original VM once. Procedure, borrowed-vector and private-pair publication through captured bindings stays on the VM path. No per-operation closure, environment, map or heap allocation, or new GC dependency, was introduced.

Vile bare-name expressions now support their existing scalar-value or implicit zero-argument-call behavior in native graphs. Tail calls keep their context, including implicit calls inside non-tail binding helpers and unbounded zero-argument self loops. The original VM bytecode and shared language semantics remain intact.

All 87 cases passed under AddressSanitizer/UndefinedBehaviorSanitizer and Boehm, with the default-build budget test and both CLI functions. Coverage includes 4,096-iteration captured-counter and Vile implicit-tail loops in one native entry; alias changes between same-code providers; shared cells at different lexical depths; scalar types; errors/overflow after capture and vector writes; unsupported stores; continuation replay; and cleanup of borrowed environment references. All 87 cases ran freshly in each mode after adding the entry cost check and fixing read-only provider alias changes. The initial policy and its earlier verification/reuse records are archived separately in captures361-entry-trial.

All 1,800 comparison results passed on the same idle Intel i3 Mac mini: 36 workloads × 5 configurations × 10 fresh processes, nine retained. Configurations are retained360 and new361, each with arena/Boehm, plus Guile 3.0.10. One locked serial job ran from hash-verified snapshots, separately from builds/tests. The 144 native cache-population observations are separate; all 1,440 native comparison processes compiled zero sources. Setup and first use are excluded from prepared medians; raw first-call and process times remain available. The unchanged Guile guild-O2 wrappers use default JIT. All 36 cases and their seed oracles remain included.

All 22 scaling groups passed 4 versus 400 calls, three repetitions per count, requiring total-time ratios above 20. Recovery journals preserve completed samples in the same source/cache context.

Suite GC gain vs360 Arena gain vs360 Guile/new GC Guile/new arena
wm 1.011× 1.008× 0.335× 0.314×
numeric 1.232× 1.238× 0.555× 0.552×

The initial entry policy and its dynamic-wind regression remain in CAPTURES-361-ENTRY-TRIAL.md. The cost-policy trial restored that workload but exposed a read-only alias bug in subsequent regressions. Both scalar and vector alias cases failed that baseline before the final fix. The final entry policy and alias fix are compared against retained360 across the complete unchanged suite below.

Guile/Vile ratios above one favor Vile. The full requested 1.5× advantage remains unproven; the final 31-sample and full-objective gates are outstanding.

Regressions over 5% against360: none. All losses remain in the tables and aggregates.

wm

Workload 360 GC ms 361 GC ms Guile ms GC gain vs360 Arena gain vs360
wm-callback-chain 0.605 0.605 0.641 1.000× 1.007×
wm-event-dispatch 1.407 1.405 0.215 1.001× 1.003×
wm-focus-cycle 3.474 3.453 0.377 1.006× 1.003×
wm-tiling-layout 0.569 0.566 0.109 1.005× 0.996×
wm-workspace-move 1.220 1.217 0.174 1.003× 1.000×
wm-keybindings 4.439 4.384 0.281 1.012× 0.990×
wm-hooks 2.647 2.396 0.359 1.105× 1.128×
wm-lifecycle 1.261 1.259 0.125 1.002× 1.000×
wm-macro-config 4.545 4.597 5.446 0.989× 0.986×
wm-config-load-tree 5.112 5.077 8.953 1.007× 0.994×
wm-reload-live 5.666 5.634 8.111 1.006× 1.000×
wm-session-replay 5.683 5.666 8.200 1.003× 1.000×

numeric

Workload 360 GC ms 361 GC ms Guile ms GC gain vs360 Arena gain vs360
tail-sum-10k 0.006 0.006 0.034 1.000× 1.000×
fib-20 0.170 0.170 0.314 1.000× 0.999×
closure-5k 0.003 0.003 0.016 1.000× 1.000×
list-3k 0.007 0.007 0.060 0.999× 1.000×
flonum-sum-2k 0.006 0.006 0.096 1.008× 1.007×
bignum-fib-200 0.062 0.062 0.005 1.002× 0.994×
rational-harmonic-80 0.097 0.097 0.050 1.001× 0.996×
integer-divmod-5k 0.012 0.012 0.168 0.999× 0.999×
list-map-1k 0.130 0.134 0.049 0.970× 0.986×
list-reverse-2k 0.673 0.668 0.060 1.008× 1.014×
vector-update-2k 0.071 0.071 0.016 1.002× 1.016×
bytevector-fill-4k 1.025 1.022 0.086 1.003× 1.011×
hashtable-count-1k 0.489 0.484 5.924 1.011× 1.012×
string-build-1k 0.049 0.049 0.043 1.013× 0.997×
string-scan-4k 1.019 1.039 0.044 0.982× 1.001×
unicode-scan-1k 0.270 0.275 0.012 0.979× 0.989×
datum-read-write-200 1.574 1.550 2.271 1.016× 0.981×
closure-mutate-2k 0.449 0.003 0.008 149.683× 170.235×
higher-order-2k 0.004 0.004 0.006 1.002× 0.998×
callcc-escape-1k 0.127 0.125 0.007 1.013× 1.007×
values-consumer-1k 0.725 0.732 0.004 0.991× 0.988×
dynamic-wind-200 0.160 0.159 0.013 1.009× 1.001×
goops-dispatch-1k 0.790 0.784 0.109 1.007× 0.991×
goops-allocate-200 0.113 0.113 0.055 0.997× 0.991×

Build snapshot: vile-resume.x_sxd5nw. Verification snapshot: vile-resume.e3ax5thj. Measurement snapshot: vile-resume.ai4ngc70. Recovery archive: validation/captures361/.

Separate post-benchmark diagnostic profiles passed their checksums. The captured-counter workload spends its native phase in the compiled loop; dynamic-wind stays on the VM path with zero native entries. These profiles confirm the entry policy and are not additional timing comparisons.