vile / bench / runtime / WIND-389.md
73 lines · 58 sloc · 7.62 KB · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw

Private native dynamic-wind callbacks (389)

The native binding lowerer recognizes the exact existing dynamic-wind bridge and three proven private zero-argument callbacks. It uses the existing lexical-frame lowering to run before, body and after in order, preserves the body result across after, and adds a barrier that prevents private recursion from skipping pending callbacks. Scalar/captured writes and vector mutations retain the existing native transaction validation and rollback. No per-call closure, activation or WindFrame is needed in an admitted graph.

Admission requires that no callback can observe or escape the extent: continuation capture/invocation, host reentry, unsupported protocols and other observable control keep the full VM path. Unsupported arities, result protocols or size limits also decline. Native failure rolls back speculative writes before the original VM operation runs. This is backend eligibility, not a restriction on Scheme/Vile behavior. Future native escape support must preserve this decline or explicitly model wind extents. No native ABI, ordinary runtime, compiler/standard-library source or GC dependency changes.

All 25 new semantic/safety cases pass on unchanged retained 388 and candidate under sanitizer and Boehm. They cover both frontends, callback order, tail/nontail and nested calls, saved vector identity, local reset, fresh capture providers, rebinding/foreign owners/near bridge shapes, journal overflow, exact located errors, step/frame controls, borrowed arenas, 64/65-slot boundaries, and continuation capture/GC replay in all three stages. Two separate admission probes return correct values but fail at native-plan assertions on baseline; both pass on candidate. Full candidate coverage is 261 native cases per mode, two CLI cases and the default-build budget check. Source/log hash proofs carry 72 completed cases per mode into the full gate; they are not rerun. The first baseline recorder path-conversion failure and its carried successful sanitizer group remain preserved.

Both actual production host outputs preserve entry allocation and dynamic-access counts. A separate validation-only compiler wrapper captures the emitted wind kernel C and assembly with correct four-input results and native hits in both collectors. It is absent from the primary preparation/timing environment. The prepared cache kernel has identical machine text to that captured source build in each collector. The generated kernel has no VM application, WindFrame or heap-allocation calls.

The comparison uses all 24 runtime and 12 mock-WM workloads, both collectors, frozen four-input oracles, batches and five warmups, Guile 3.0.10 guild-O2/default-JIT wrappers, and 31 retained samples after excluding sample 0. All 5,760 observations pass. Configurations/hash lists are pinned to the previous verified archive before this run and checked with programs/binaries before and after measurement. The 144 cold preparations run separately; warmup/measured compilation is zero. All 46 scaling groups pass 4 versus 400 calls with three repeats and at least 20x elapsed growth. Of 2,304 paired native counters, only the 64 dynamic-wind pairs gain native hits as intended; all other hit/deopt counters match. Builds, tests, capture, preparation and timings run serially from hash-verified snapshots under the shared Mac lock, with idle checks before timings. R7RS first-use results remain separate.

Only native-gated production files change. The interpreted result remains unchanged. Ratios above one favor candidate or Vile; aggregates are equal-weight geometric means and every loss remains included. This candidate is retained after complete verification and comparison. The full 1.5x goal remains unmet; the all-36 result is below that threshold.

Suite GC gain vs388 Arena gain vs388 Guile/Vile GC Guile/Vile arena
wm 1.009x 0.999x 0.647x 0.640x
runtime 1.275x 1.292x 1.533x 1.575x
all36 1.179x 1.186x 1.150x 1.166x

The private wind workload improves 346.0x with GC (148.997 to 0.431us) and 461.3x with arenas (152.507 to 0.331us). Guile takes 12.833us. These callbacks mutate private numeric state; observable control retains the VM. The aggregate above includes every other workload.

All 36 95% paired-round bootstrap intervals: GC gain 1.176–1.184x; arena gain 1.184–1.192x; Guile/Vile GC 1.147–1.152x; Guile/Vile arena 1.164–1.168x. The analysis uses 2,000 deterministic paired-round resamples within each fixed workload (seed 389031), estimating observed process variation, not unseen-program performance. Primary medians and weights are unchanged.

Regressions above 5%: runtime/bytevector-fill-4k (gc, 1.058x elapsed). All remain included.

wm

Workload 388 GC ms 389 GC ms Guile ms GC gain Arena gain
wm-callback-chain 0.484301 0.476349 0.639500 1.017x 1.005x
wm-event-dispatch 0.821057 0.808206 0.215000 1.016x 0.990x
wm-focus-cycle 0.484928 0.472728 0.377250 1.026x 1.002x
wm-tiling-layout 0.267895 0.258979 0.109250 1.034x 0.995x
wm-workspace-move 0.193337 0.189358 0.174500 1.021x 0.993x
wm-keybindings 0.947733 0.951551 0.281500 0.996x 1.001x
wm-hooks 2.044074 2.046323 0.357000 0.999x 0.996x
wm-lifecycle 0.872456 0.875675 0.126750 0.996x 1.005x
wm-macro-config 4.401324 4.398241 5.283500 1.001x 0.997x
wm-config-load-tree 4.647936 4.671989 8.986250 0.995x 1.003x
wm-reload-live 4.820359 4.810899 8.121750 1.002x 1.002x
wm-session-replay 4.870222 4.867227 8.074750 1.001x 1.000x

runtime

Workload 388 GC ms 389 GC ms Guile ms GC gain Arena gain
tail-sum-10k 0.005606 0.005606 0.033710 1.000x 1.000x
fib-20 0.147307 0.147161 0.310930 1.001x 0.998x
closure-5k 0.002129 0.002127 0.015590 1.001x 1.004x
list-3k 0.007205 0.007204 0.059990 1.000x 1.000x
flonum-sum-2k 0.002374 0.002370 0.096000 1.002x 1.000x
bignum-fib-200 0.043230 0.043008 0.005417 1.005x 0.999x
rational-harmonic-80 0.103785 0.104155 0.050250 0.996x 1.001x
integer-divmod-5k 0.007919 0.007920 0.168083 1.000x 1.000x
list-map-1k 0.125964 0.125509 0.048500 1.004x 0.999x
list-reverse-2k 0.066993 0.066867 0.060750 1.002x 1.005x
vector-update-2k 0.062210 0.059363 0.016250 1.048x 1.001x
bytevector-fill-4k 0.078779 0.083347 0.086167 0.945x 1.013x
hashtable-count-1k 0.462529 0.462592 5.956333 1.000x 1.000x
string-build-1k 0.045234 0.045931 0.043083 0.985x 1.004x
string-scan-4k 0.088886 0.089542 0.043750 0.993x 0.977x
unicode-scan-1k 0.035584 0.035611 0.011750 0.999x 1.019x
datum-read-write-200 1.568380 1.580470 2.262500 0.992x 0.996x
closure-mutate-2k 0.002830 0.002826 0.008417 1.001x 0.999x
higher-order-2k 0.004077 0.004077 0.006333 1.000x 1.000x
callcc-escape-1k 0.095217 0.094454 0.006667 1.008x 0.998x
values-consumer-1k 0.001553 0.001551 0.004417 1.001x 0.999x
dynamic-wind-200 0.148997 0.000431 0.012833 345.968x 461.328x
goops-dispatch-1k 0.779430 0.780559 0.110375 0.999x 1.000x
goops-allocate-200 0.085543 0.085647 0.055000 0.999x 1.001x

Build: vile-resume.1epskmsf. Verification: vile-resume.ikjilm3p. Preparation/measurement: vile-resume.k9w6_y4o. Actual source capture: vile-resume.qllbq75m. Native baseline: vile-resume.igmxkl1a/native-index388/native.