diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:55:49 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 09:54:56 -0300 |
| commit | e32f749c80468b9e2fc79eb068f7088527a9c504 (patch) | |
| tree | 07c77ecd04a282efa301a04d1a0b8b718111dc6a /src/replica.zig | |
| parent | dcb5fede7b5b2ceda0d7015bb8088fa343728378 (diff) | |
| download | pardes-e32f749c80468b9e2fc79eb068f7088527a9c504.tar.gz pardes-e32f749c80468b9e2fc79eb068f7088527a9c504.zip | |
benches out of the binary: screen_state's corpus soak, encode bench and floods (PARDES_SCREEN_STATE=<dir>, which nothing sets) are `zig build replicas -- --screen-state <dir>`, 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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/replica.zig')
| -rw-r--r-- | src/replica.zig | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/replica.zig b/src/replica.zig index 5c46f5c2..fa309648 100644 --- a/src/replica.zig +++ b/src/replica.zig @@ -3532,57 +3532,6 @@ test "pardes's own keys over a terminal's history apply at once: its view moves try std.testing.expectEqual(terminal.viewOf(a.core.panes[shell].?), terminal.viewOf(r.core().panes[shell].?)); } -/// p50 and p99 of `samples`, sorted in place. -fn spread(samples: []u64) [2]u64 { - std.mem.sort(u64, samples, {}, std.sort.asc(u64)); - return .{ samples[samples.len / 2], samples[@min(samples.len - 1, samples.len * 99 / 100)] }; -} - -test "the authority's units with a big file open: its blobs hashed once (PARDES_DIGEST_BENCH=<MB>)" { - const arg = std.c.getenv("PARDES_DIGEST_BENCH") orelse return error.SkipZigTest; - const mb = std.fmt.parseInt(usize, std.mem.span(arg), 10) catch 100; - const gpa = std.heap.c_allocator; - const tmp = std.mem.span(std.c.getenv("TMPDIR") orelse "/tmp"); - var path_buf: [256]u8 = undefined; - const path = try std.fmt.bufPrintSentinel(&path_buf, "{s}/pardes-digest-bench.txt", .{tmp}, 0); - { - const fd = std.c.open(path, .{ .ACCMODE = .WRONLY, .CREAT = true, .TRUNC = true }, @as(std.c.mode_t, 0o644)); - if (fd < 0) return error.OpenFailed; - defer _ = std.c.close(fd); - var line: [80]u8 = undefined; - var n: usize = 0; - var i: usize = 0; - while (n < mb << 20) : (i += 1) { - const text = try std.fmt.bufPrint(&line, "line {d:0>9} of a big file, as a log or a dump is\n", .{i}); - if (std.c.write(fd, text.ptr, text.len) != @as(isize, @intCast(text.len))) return error.WriteFailed; - n += text.len; - } - } - defer _ = std.c.unlink(path); - const a = try Authority.init(gpa, .{ .cols = 120, .rows = 40, .file = path }, TestHost.host(), true); - defer a.deinit(); - _ = try a.unit(0, 0); - var unit_ns: [40]u64 = undefined; - var digest_ns: [40]u64 = undefined; - for ([_]bool{ false, true }) |on| { - walk.blob_words_on = on; - defer walk.blob_words_on = true; - walk.forgetAll(); - for (&unit_ns, &digest_ns, 0..) |*u, *d, k| { - // A key into the file: a unit as a replica is sent it. - const t0 = nowNs(); - _ = try a.local(.{ .key = .{ .cp = if (k % 2 == 0) 'j' else 'k', .text = if (k % 2 == 0) "j" else "k" } }); - u.* = nowNs() - t0; - const t1 = nowNs(); - _ = digestOf(a); - d.* = nowNs() - t1; - } - const us = spread(&unit_ns); - const ds = spread(&digest_ns); - std.debug.print("{d} MB file, blobs {s}: a unit p50 {d} us p99 {d} us; a digest p50 {d} us p99 {d} us\n", .{ mb, if (on) "hashed once" else "hashed whole", us[0] / 1000, us[1] / 1000, ds[0] / 1000, ds[1] / 1000 }); - } -} - test "a replica joined from the session's dump replays the units after it" { const gpa = std.testing.allocator; const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false); |
