vile / bench / native / VECTOR-357.md
66 lines · 54 sloc · 5.86 KB · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw

Native borrowed-vector candidate357

Correctness-qualified foundation; not retained as a standalone performance result. The new vector path helps vector loops, but substantial pure-kernel regressions and small WM gains require further work.

Adds borrowed vector reads, length and journaled writes, nested readonly/mutable handles, live scalar/vector globals, and representable host returns. Each native invocation records the first original value per changed cell in a bounded C stack journal. Failure restores all destinations before interpreter replay. Repeated writes share an entry; capacity exhaustion safely falls back. No new GC dependency or operation-time heap allocation is introduced. Captured binding mutation, constructors and opaque contents still use the VM.

49 cases passed under AddressSanitizer/UndefinedBehaviorSanitizer and 49 under Boehm, plus 2 CLI tests. Coverage includes aliases, live captures/globals, readonly children, late arithmetic errors, private pair escape/pool exhaustion, journal deduplication/capacity/epoch wrap and collection after overwriting a nested payload. The GC-fault fixture needed a correctly typed C adapter; failed logs and subsequent passing evidence are preserved.

All 1,800 comparison samples passed (36 workloads × 5 configurations × 10 fresh processes, nine retained). Both versions use separate populated native cache roots per engine/collector. The 144 initial population observations remain separate; all 1,440 native comparison processes compiled zero sources. Guile 3.0.10 uses the existing guild -O2 wrappers and default JIT. Prepared medians exclude setup/first use; raw first-call and process times are retained. Existing fixtures and every four-seed oracle are unchanged. The 18 fresh scaling groups passed comparisons of 4 versus 400 calls, three repetitions per count, with total-time ratios above20.

Suite GC gain vs356 Arena gain vs356 Guile/candidate GC Guile/candidate arena
wm 1.018× 0.971× 0.170× 0.155×
numeric 1.055× 1.018× 0.373× 0.366×

Ratios above one favor Vile. These results do not establish the requested 1.5× advantage over Guile. Native fallbacks and every loss remain included.

wm

Workload Before GC ms Candidate GC ms Guile ms GC gain Arena gain Guile/candidate GC
wm-callback-chain 7.395 7.307 0.644 1.012× 0.933× 0.088×
wm-event-dispatch 5.301 5.395 0.215 0.982× 0.920× 0.040×
wm-focus-cycle 6.113 5.871 0.377 1.041× 0.961× 0.064×
wm-tiling-layout 3.528 3.386 0.108 1.042× 0.960× 0.032×
wm-workspace-move 1.877 1.698 0.177 1.106× 1.013× 0.104×
wm-keybindings 4.733 4.915 0.283 0.963× 1.007× 0.058×
wm-hooks 3.925 3.714 0.356 1.057× 0.999× 0.096×
wm-lifecycle 1.404 1.369 0.132 1.026× 0.961× 0.096×
wm-macro-config 4.692 4.683 5.290 1.002× 1.001× 1.130×
wm-config-load-tree 5.330 5.298 9.064 1.006× 0.998× 1.711×
wm-reload-live 9.857 9.754 8.148 1.011× 0.945× 0.835×
wm-session-replay 8.963 9.138 8.148 0.981× 0.963× 0.892×

numeric

Workload Before GC ms Candidate GC ms Guile ms GC gain Arena gain Guile/candidate GC
tail-sum-10k 0.006 0.006 0.034 1.000× 0.999× 5.990×
fib-20 0.170 0.147 0.313 1.159× 1.160× 2.131×
closure-5k 0.004 0.004 0.016 0.999× 0.999× 3.686×
list-3k 0.008 0.008 0.060 1.024× 1.024× 7.851×
flonum-sum-2k 0.012 0.015 0.097 0.785× 0.775× 6.299×
bignum-fib-200 0.063 0.062 0.005 1.016× 0.976× 0.088×
rational-harmonic-80 0.097 0.097 0.050 1.003× 0.993× 0.518×
integer-divmod-5k 0.018 0.036 0.168 0.501× 0.496× 4.646×
list-map-1k 0.146 0.155 0.049 0.947× 0.980× 0.316×
list-reverse-2k 0.692 0.676 0.061 1.023× 0.991× 0.090×
vector-update-2k 0.524 0.075 0.016 7.010× 6.412× 0.216×
bytevector-fill-4k 1.081 1.022 0.086 1.058× 0.951× 0.084×
hashtable-count-1k 0.502 0.482 5.994 1.041× 0.979× 12.432×
string-build-1k 0.052 0.050 0.045 1.031× 0.975× 0.887×
string-scan-4k 1.062 1.039 0.044 1.022× 0.972× 0.042×
unicode-scan-1k 0.281 0.275 0.012 1.020× 0.969× 0.043×
datum-read-write-200 1.604 1.587 2.262 1.011× 0.987× 1.425×
closure-mutate-2k 0.464 0.443 0.008 1.047× 0.954× 0.019×
higher-order-2k 0.021 0.026 0.006 0.792× 0.794× 0.242×
callcc-escape-1k 0.133 0.127 0.007 1.046× 0.949× 0.053×
values-consumer-1k 0.761 0.750 0.004 1.015× 0.975× 0.006×
dynamic-wind-200 0.166 0.162 0.013 1.023× 0.976× 0.078×
goops-dispatch-1k 0.801 0.787 0.110 1.018× 0.981× 0.139×
goops-allocate-200 0.116 0.113 0.054 1.025× 0.992× 0.483×

The vector-update kernel gains about 7×, while integer division/modulo takes roughly twice as long and the flonum/higher-order kernels also regress. Preliminary diagnosis: repeated global guards burden short native calls, while adding vector callback dispatch to the shared numeric C runtime affects optimizer decisions even in pure graphs. Follow-up work will cache invariant binding checks with mutation-aware invalidation and isolate vector-aware C code from pure graphs. These are hypotheses until the next full comparison.

Build snapshot: vile-resume.hslgud5a. Measurement data: vile-resume.jgh8_nzn/vector357-measure. Frozen idle-wait controller: vile-resume.ocvxtk41. Full archive: validation/vector357/ in the recovery directory. The final 31-sample gate remains outstanding.