vile / bench / native / CACHE-349.md
77 lines · 64 sloc · 7.9 KB · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw

Native compiled-code cache 349

With an already populated disk cache, native GC whole-process time improves 2.381× over native348 across all 24 varying-input workloads. Prepared throughput changes 0.996×. Guile/native GC prepared speed is 0.264×: Guile remains 3.79× faster overall. The 1.5× prepared-speed goal is not achieved.

Whole-process Guile/cached Vile is 1.323×, with Vile faster in 14/24 cases. Process duration includes the complete checked batch, setup and cleanup; it is not standalone startup time. Cached first calls still validate and load code. A new cache still pays compilation cost.

Only generated machine code is persisted. Fresh scopes reconstruct the existing owner/binding/capture guards and load current captured values. Keys cover full generated C, ABI definitions, primitive identifiers, build/sanitizer flags, compiler/version, platform, working directory and relevant environment. Private directories, image hashes, symbol checks and atomic publication reject unusable or incomplete entries. Loaded handles close with their scope; process-local temporary files are removed. No captured environment or VM pointer is serialized.

The default is $XDG_CACHE_HOME/vile/native-v1, otherwise ~/.cache/vile/native-v1; VILE_NATIVE_CACHE=/path selects a private root and VILE_NATIVE_CACHE=off disables persistence. Missing/unusable entries compile normally. Custom CPATH/C_INCLUDE_PATH/CPLUS_INCLUDE_PATH/OBJC_INCLUDE_PATH/SDKROOT settings disable persistent reuse because header contents are opaque dependencies. These measurements remove those overrides from both candidates and the baseline, using the default Apple SDK. The exact removed settings are retained in inputs.json. The cache currently has no automatic eviction.

All 31 focused cases passed in one process with ASan/UBSan (including generated libraries), and again with Boehm. The two CLI cases passed, including two independent processes with exactly one source compilation total, both frontends, limits, stdin/REPL, exit status and temporary-file cleanup. Tests cover fresh captures across VMs, source/flag/compiler key separation, corrupt and missing-symbol images, disabled/unusable caches and header-override fallback. Both production collector configurations built successfully.

Nine measured fresh processes plus one excluded process per configuration/workload: 1,200 checked rows, 1,080 measured. Five configurations are native348 arena/GC, cached native349 arena/GC, and Guile 3.0.10 (-O2, default JIT). All 480 cache-enabled process rows report zero source compilations; observed cache hits and native/fallback activity remain in the raw records. All 24 workloads and losses are included. Forty-eight separate first-cache process observations are saved in cold.json; these single observations are not nine-sample medians.

Twelve scaling groups, three repeats each, compare 4 with 400 invocations. The 100× larger batch takes 83.0–99.9× longer. Builds/tests finished before idle measurement; scaling was a separate idle job. Every job used verified snapshots, one shared Mac lock, VJOBS=1, VFLAGS=-no-parallel and MAKEFLAGS=-j1.

Prepared microseconds per checked invocation:

Workload Native348 GC us Cached349 arena us Cached349 GC us [IQR] Guile us Guile/GC
tail-sum-10k 5.617 5.612 5.617 [5.615, 5.618] 33.700 6.000×
fib-20 170.591 170.475 170.687 [170.407, 171.169] 313.460 1.836×
closure-5k 4.228 4.201 4.222 [4.221, 4.224] 15.590 3.693×
list-3k 8.581 7.953 8.541 [8.536, 8.563] 60.220 7.050×
flonum-sum-2k 556.809 557.078 568.262 [566.485, 569.504] 95.833 0.169×
bignum-fib-200 59.011 61.525 61.203 [61.102, 61.233] 5.417 0.089×
rational-harmonic-80 97.764 109.152 98.138 [98.003, 98.715] 48.625 0.495×
integer-divmod-5k 18.089 17.822 18.080 [18.067, 18.112] 168.000 9.292×
list-map-1k 138.243 134.948 137.703 [137.225, 137.946] 48.667 0.353×
list-reverse-2k 663.039 660.799 687.148 [684.714, 688.932] 60.833 0.089×
vector-update-2k 873.669 883.480 889.273 [888.888, 889.939] 16.250 0.018×
bytevector-fill-4k 1406.631 1421.794 1439.722 [1437.912, 1460.187] 86.083 0.060×
hashtable-count-1k 597.544 612.348 611.607 [603.254, 612.990] 5947.417 9.724×
string-build-1k 46.399 57.772 47.440 [46.781, 47.556] 42.917 0.905×
string-scan-4k 1099.787 1102.959 1131.086 [1130.863, 1131.922] 43.750 0.039×
unicode-scan-1k 2323.574 2273.465 1796.002 [1795.648, 1801.438] 11.750 0.007×
datum-read-write-200 1549.721 1332.535 1571.896 [1558.560, 1616.232] 2283.875 1.453×
closure-mutate-2k 476.618 492.315 508.826 [508.560, 509.518] 8.417 0.017×
higher-order-2k 21.498 21.799 21.590 [21.258, 21.719] 6.333 0.293×
callcc-escape-1k 140.187 142.401 143.400 [142.925, 143.804] 6.667 0.046×
values-consumer-1k 770.681 696.817 770.188 [758.221, 781.424] 4.417 0.006×
dynamic-wind-200 165.702 171.112 170.529 [170.290, 170.667] 12.667 0.074×
goops-dispatch-1k 792.151 783.893 806.678 [805.982, 854.865] 109.250 0.135×
goops-allocate-200 115.371 126.592 116.486 [116.304, 116.642] 54.875 0.471×

Median first-call and whole-process milliseconds:

Workload Before first Cached first Guile first Before process Cached process Guile process
tail-sum-10k 403.525 37.934 0.045 416.511 50.804 39.515
fib-20 403.196 37.625 0.146 433.382 67.700 68.806
closure-5k 405.636 37.956 0.027 418.918 50.406 37.540
list-3k 421.386 37.575 0.068 813.853 51.264 42.641
flonum-sum-2k 0.647 0.658 0.141 21.264 21.513 37.194
bignum-fib-200 395.634 37.486 0.030 408.973 50.423 36.482
rational-harmonic-80 0.228 0.229 0.098 13.212 13.279 36.349
integer-divmod-5k 398.681 38.097 0.196 411.340 50.607 38.935
list-map-1k 358.603 38.245 0.136 374.148 53.021 36.979
list-reverse-2k 403.615 38.489 0.107 427.572 62.523 37.360
vector-update-2k 0.981 0.993 0.048 26.648 27.049 35.804
bytevector-fill-4k 1.511 1.544 0.130 35.833 36.666 36.806
hashtable-count-1k 0.730 0.743 6.129 22.388 22.704 150.611
string-build-1k 0.190 0.192 0.119 12.747 12.823 36.394
string-scan-4k 1.178 1.209 0.080 30.641 31.140 36.946
unicode-scan-1k 2.395 1.880 0.048 51.282 42.609 35.661
datum-read-write-200 2.095 2.106 3.652 33.336 33.985 69.564
closure-mutate-2k 0.548 0.583 0.034 19.922 20.533 36.371
higher-order-2k 397.505 37.828 0.028 410.824 50.244 36.086
callcc-escape-1k 0.220 0.228 0.042 14.140 14.326 35.516
values-consumer-1k 361.838 38.605 0.033 386.521 63.425 36.091
dynamic-wind-200 0.272 0.279 0.038 14.822 14.984 35.819
goops-dispatch-1k 1.413 1.425 0.194 23.875 24.168 50.479
goops-allocate-200 0.221 0.222 0.107 14.784 14.826 50.230

Prepared regressions above 5% are retained: unicode-scan-1k (arena: 1.166× prior time), closure-mutate-2k (gc: 1.068× prior time), values-consumer-1k (arena: 1.061× prior time). These observations need profiling; they are not discarded from the aggregate. The code-cache change targets compilation latency, and the prepared-speed goal remains open.

Qualification/build: vile-resume.iyvtmcd1. Measurement: vile-resume.vt4zp2_g. Scaling: vile-resume.0b93kmz3. Source/compiler/tool/binary/image hashes, exact commands, raw records, idle evidence, logs and a focused patch are retained in recovery validation/performance349. This is a nine-sample iteration; the broad final comparison and the performance goal remain outstanding.