From 2536110e142a3cb548a43235767ac7ae6efa357c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 02:43:58 -0300 Subject: walk: the tape's shape appends each piece whole: `out = out ++ name ++ ":" ++ shapeOf(F) ++ ","` is ((out ++ name) ++ ":") ++ ..., so the shape so far (up to 11 KB, every union arm and struct field of the tape's types) was copied at comptime once a piece, four times a field, and a comptime copy is costly (32 KB built of 4,000 appends: 226e9 of the compiler's instructions); the piece is put together first and appended once, in shape (each type's line), an enum's values, a struct's and a union's fields; the shape is the same 10,960 bytes and wire.semantics the same 05b2cba8834b1d7c; core-test's forced full recompile (Debug, one filter) 103.41e9 to 101.37e9 instructions (-1.7 % of the base's 120.12e9; all five changes together -15.6 %, 15.5-16.1 s of CPU to 13.6-14.4 s, and 9.0-9.2 s wall against 10.2-11.0 s, both noisy), the Debug test's text unchanged; a session's byte dump, its image and a closed pane's save the same bytes (but the clock's) and each build loads the other's; the changelog says so --- src/CHANGELOG.md | 9 +++++---- src/walk.zig | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index ce98a862..b12fc2c5 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -41,15 +41,16 @@ A column resizes by its box, left of its tag; a pane by its own box, or in a window by the rule above it. -- An edit to the core recompiles it about 1.5 s sooner again (`core-test`, - 14 % fewer of the compiler's instructions, 4.4 MB less code in a Debug +- An edit to the core recompiles it about 2 s sooner again (`core-test`, + 16 % fewer of the compiler's instructions, 4.4 MB less code in a Debug test): a load's note on a field (another build's dump) is written from the type's and the field's names at run time, where every type and field had its own copy of the code that writes one; one byte dump's reader serves a session, a pane and the rest, where each had its own; and what tells a replica's build from another's (`wire.semantics`) - joins its two long parts on, and writes the tape's numbers itself, - where it formatted them, at every compile. + joins its two long parts on, and the tape's shape writes its numbers + itself and copies each line it builds once, where it formatted them + and copied the line again for each piece, at every compile. - An edit to the core recompiles it about 3 s sooner (`core-test`, 13 s to 10 s): the build keeps each grammar's highlight patterns that pardes diff --git a/src/walk.zig b/src/walk.zig index 8747937d..0f181cfa 100644 --- a/src/walk.zig +++ b/src/walk.zig @@ -367,7 +367,7 @@ pub fn shape(comptime types: []const type) []const u8 { comptime { @setEvalBranchQuota(10_000_000); var out: []const u8 = ""; - for (types) |T| out = out ++ shapeOf(T, 0) ++ "\n"; + for (types) |T| out = out ++ (shapeOf(T, 0) ++ "\n"); return out; } } @@ -382,7 +382,7 @@ fn shapeOf(comptime T: type, comptime depth: u8) []const u8 { .float => |f| "f" ++ decimal(f.bits), .@"enum" => |e| blk: { var out: []const u8 = shapeOf(e.tag_type, depth + 1) ++ "{"; - for (e.field_names, e.field_values) |n, v| out = out ++ n ++ "=" ++ decimal(v) ++ ","; + for (e.field_names, e.field_values) |n, v| out = out ++ (n ++ "=" ++ decimal(v) ++ ","); break :blk out ++ "}"; }, .optional => |o| if (machinery(o.child)) "0" else "?" ++ shapeOf(o.child, depth + 1), @@ -397,13 +397,13 @@ fn shapeOf(comptime T: type, comptime depth: u8) []const u8 { var out: []const u8 = if (s.layout == .@"packed") "p{" else "{"; for (s.field_names, s.field_types, s.field_attrs) |name, F, attr| { if (attr.@"comptime" or excluded(T, name)) continue; - out = out ++ name ++ ":" ++ shapeOf(F, depth + 1) ++ ","; + out = out ++ (name ++ ":" ++ shapeOf(F, depth + 1) ++ ","); } break :blk out ++ "}"; }, .@"union" => |u| blk: { var out: []const u8 = shapeOf(u.tag_type.?, depth + 1) ++ "("; - for (u.field_names, u.field_types) |name, F| out = out ++ name ++ ":" ++ shapeOf(F, depth + 1) ++ ","; + for (u.field_names, u.field_types) |name, F| out = out ++ (name ++ ":" ++ shapeOf(F, depth + 1) ++ ","); break :blk out ++ ")"; }, .error_set => "error", -- cgit v1.3