From 5b8cf6f66e367192090350c9129fa341edfc9343 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 16 Nov 2026 23:00:19 -0300 Subject: Compute abi.hash's layout half once per abi change, not in every compile The comptime walk over the shared types cost about half a second of every sketch library's compile. abi_hash.zig runs it at build time, once per change of the abi sources (watched like any input), and build.zig hands the number to host and sketches as the module abi_hash; abi.hash folds in the build as before. The value is the walk's own, computed for the build machine in Debug. --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8e4e430..3a4384a 100644 --- a/README.md +++ b/README.md @@ -873,15 +873,19 @@ renderer migration work and the optional addon boundary. ## The boundary Host and sketch are built by the same `zig build`, so ordinary Zig types cross -it (slices, tagged unions, `std.mem.Allocator`). `abi.hash`, a comptime hash -of every shared type's layout and of the zig version, backend and optimize +it (slices, tagged unions, `std.mem.Allocator`). `abi.hash`, a hash of +every shared type's layout and of the zig version, backend and optimize mode, guards against the real hazards: a host refuses a library built against different definitions, or by another compiler or mode (`zig build run` beside `zig build lib --watch -Doptimize=fast`: Zig's own calling -convention differs between them), and says what differs. Everything that outlives -a call lives in host memory, since host code is never unloaded. Only the -recorded `Event` and the reflected `Layout` are `extern`, because they are -written to disk. +convention differs between them), and says what differs. The layout half +costs half a second of comptime, so a small program (`src/abi_hash.zig`) +computes it once per change of the abi sources, at build time, and host and +sketches import the number; it is computed for the build machine in Debug, +so a layout change seen only by another target or mode is not caught. +Everything that outlives a call lives in host memory, since host code is +never unloaded. Only the recorded `Event` and the reflected `Layout` are +`extern`, because they are written to disk. `zig build test` in this directory runs the unit tests, a headless reload through `dlopen`, where a counter sketch changes its layout mid-run and keeps -- cgit v1.3