From e32f749c80468b9e2fc79eb068f7088527a9c504 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:55:49 -0300 Subject: benches out of the binary: screen_state's corpus soak, encode bench and floods (PARDES_SCREEN_STATE=, which nothing sets) are `zig build replicas -- --screen-state `, replica.zig's big-file digest bench (PARDES_DIGEST_BENCH) is the last of rollback-bench, and Store's timings (STORE_TIMES) go, no bench step taking a store Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/Store.zig | 61 ----------------------------------------------------------- 1 file changed, 61 deletions(-) (limited to 'src/Store.zig') diff --git a/src/Store.zig b/src/Store.zig index 2bb9fcf0..547e7bd6 100644 --- a/src/Store.zig +++ b/src/Store.zig @@ -1133,64 +1133,3 @@ test "store: a closed pane comes back where it was, its rows from the pane that } const panes_mod = @import("panes.zig"); - -test "zz store timings on a 90 MiB store (STORE_TIMES=)" { - const dir_z = std.c.getenv("STORE_TIMES") orelse return error.SkipZigTest; - const gpa = testing.allocator; - const path = try std.fs.path.join(gpa, &.{ std.mem.span(dir_z), "store" }); - defer gpa.free(path); - // A store as another running session leaves it: 200 files, then 90 - // closed panes of 1 MiB each (this pid: alive, so a compaction keeps - // what fits). - { - var bytes: std.ArrayList(u8) = .empty; - defer bytes.deinit(gpa); - try frame(gpa, &bytes, 'h', &.{magic ++ " 1"}); - var line: [64]u8 = undefined; - for (0..200) |i| try frame(gpa, &bytes, 'r', &.{std.fmt.bufPrint(&line, "1 1 0 0 /w/file{d}.zig", .{i}) catch unreachable}); - const out = try std.Io.Dir.cwd().createFile(testing.io, path, .{}); - defer out.close(testing.io); - try out.writePositionalAll(testing.io, bytes.items, 0); - var off: u64 = bytes.items.len; - const big = try gpa.alloc(u8, 1 << 20); - defer gpa.free(big); - @memset(big, 'z'); - for (0..90) |i| { - bytes.clearRetainingCapacity(); - var meta: [128]u8 = undefined; - const m = std.fmt.bufPrint(&meta, "{x:0>16} {d} {d} 1 0 0 0 10\t/w/closed{d}\n", .{ @as(u64, 0xfeed), std.c.getpid(), i + 1, i }) catch unreachable; - try frame(gpa, &bytes, 'c', &.{ m, big }); - try out.writePositionalAll(testing.io, bytes.items, off); - off += bytes.items.len; - } - } - const t0 = nowNs(); - const p = try testWindow(path); - defer p.deinit(); - const load_ns = nowNs() - t0; - var t = nowNs(); - for (0..1000) |_| p.store.refresh(p); - const refresh_ns = (nowNs() - t) / 1000; - t = nowNs(); - var name: [32]u8 = undefined; - for (0..100) |i| { - const f = std.fmt.bufPrint(&name, "/w/new{d}.zig", .{i}) catch unreachable; - p.recent.opened(p.recentGpa(), f); - p.recent.closed(p.recentGpa(), f, 1, 1, 0, 0); - p.saveRecent(); - } - const flush_ns = (nowNs() - t) / 100; - const before = fileSize(path); - p.store.garbage = true; - p.recent.opened(p.recentGpa(), "/w/last.zig"); - t = nowNs(); - p.saveRecent(); - const compact_ns = nowNs() - t; - std.debug.print("store timings: load {d} us, refresh (unchanged) {d} ns, flush one record {d} us, compaction {d} -> {d} bytes {d} ms\n", .{ - load_ns / 1000, refresh_ns, flush_ns / 1000, before, fileSize(path), compact_ns / 1_000_000, - }); -} - -fn nowNs() u64 { - return @intCast(clockNs()); -} -- cgit v1.3