summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 19:53:07 -0300
committerGabriel Schneider <[email protected]>2026-11-05 20:49:41 -0300
commit0d07182abfa2cb02c5351231af2f1e1a156a59af (patch)
treecb62d307bda99fa3634749d86aa0092c6f42be5b /test
parent9e504559356ed985999d8625947d9b08ad582792 (diff)
downloadpardes-0d07182abfa2cb02c5351231af2f1e1a156a59af.tar.gz
pardes-0d07182abfa2cb02c5351231af2f1e1a156a59af.zip
digest: a blob of 4 KiB and up (a file's text, a register's text, a file's rows, an undo entry's bytes) is taken as its length, never its bytes, a text's revision saying what it holds, where it was hashed once and kept as a word by its address (walk.zig's blob words, from when no text was written in place): since the journal a session's edit writes its text in place, and since the change before a replica's does too, so the word went at every edit and the next unit's digest hashed the whole text again, 100 MB of it in a big file, on the session's step and the replica's; the words go with what kept them (walk.forget, wordOf, forgetAll, unhashed, makeWords, the bench's blob_words_on, memory.freeRaw's and unpin's forgets, File.edit's and grow's), and so does the join's hashing thread (replica.Peers' held, texts, hasher and rounds, joins, hashTexts, unhashedDone, the `hashed` note), which made the words of the texts a session never digested before a join's digest took them, its pins with it: a client is joined at the boundary its connection comes at; the semantics change, so the wire's version is 20 (a client of the build before is refused at its hello, as any other build's, and test/daemon.py's own hello says 20); a blob under 4 KiB is hashed whole as before, so a small text's bytes stay in the digest, and the replicas harness (test/replicas.zig) compares every file's text byte for byte at quiescence beside the digest; tests: walk.zig's 'a blob is hashed once and folded in as a word; one written in place is not its word, which a Debug build checks; a freed one's word goes' becomes 'a blob of 4 KiB and up is digested by its length, what it holds told by its keeper's revision; a smaller one by its bytes'
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
-rw-r--r--test/daemon.py2
-rw-r--r--test/replicas.zig12
-rw-r--r--test/rollback_bench.zig29
3 files changed, 23 insertions, 20 deletions
diff --git a/test/daemon.py b/test/daemon.py
index b0c02690..f8ef9be4 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -227,7 +227,7 @@ class Replica:
"""A replica's connection (src/wire.zig): length-prefixed
messages, a tag byte and a little-endian u32 length. It is a near
client: its first word after the hello says so."""
- WIRE = 19
+ WIRE = 20
def __init__(self, path, timeout=10):
self.s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
diff --git a/test/replicas.zig b/test/replicas.zig
index 15dc89f1..280b85f4 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -23,7 +23,7 @@
//!
//! Gates, per seed and RTT: no replica diverges (every confirmed unit's
//! digests agree as it is replayed), and at quiescence every replica's
-//! digest is the authority's; every delta a replica applies leaves its
+//! digest and every file's text are the authority's; every delta a replica applies leaves its
//! terminal what the authority's was at that version, and at quiescence it
//! is the authority's, cell for cell. Reported per RTT: how inputs went
//! (applied at once, stopped at a host call, left to the authority), how
@@ -457,6 +457,16 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void {
std.debug.print("seed {d} rtt {d} ms: replica {d}'s terminal {d} at quiescence is not the authority's\n", .{ r.seed, r.rtt_ms, id, pid });
}
}
+ // ...and every file's text the authority's, byte for byte: a digest
+ // takes a text of 4 KiB and up by its length (src/walk.zig).
+ for (a.core.panes, 0..) |slot, pid| {
+ const f = (slot orelse continue).file orelse continue;
+ const mine = if (rp.core().panes[pid]) |pane| pane.file else null;
+ if (mine == null or !std.mem.eql(u8, f.content, mine.?.content)) {
+ totals.unequal += 1;
+ std.debug.print("seed {d} rtt {d} ms: replica {d}'s text {d} at quiescence is not the authority's\n", .{ r.seed, r.rtt_ms, id, pid });
+ }
+ }
}
}
diff --git a/test/rollback_bench.zig b/test/rollback_bench.zig
index 3f8213d2..1260f47e 100644
--- a/test/rollback_bench.zig
+++ b/test/rollback_bench.zig
@@ -3,19 +3,18 @@
//! (open point 5). A typical session and a big one are built in process, on
//! a rollback epoch's allocator as a replica's core is; for each:
//! - the copy taken and let go: its time, the bytes it saves, the bytes
-//! it pins (a file's text, its undo snapshots);
+//! it pins (the journal's entries, a register's texts);
//! - a key that edits a file (`x`) applied on top, as a speculation, and
//! the copy put back: the apply's time and the restore's.
//! Then a fork of the big one, child gone at once, and the authority's
//! copy-on-write after it. Last, a session's authority with a 100 MB file
//! open (src/replica.zig): a key into it, a unit as a replica is sent it,
-//! and a digest, its blobs hashed whole and hashed once (src/walk.zig).
+//! and a digest (src/walk.zig: a big text by its length).
//!
//! zig build rollback-bench -Dplatform=tui -Doptimize=ReleaseFast
const std = @import("std");
const libc = std.c;
const pardes = @import("pardes");
-const walk = pardes.walk;
const gpa = std.heap.c_allocator;
@@ -130,8 +129,7 @@ fn pct(samples: []u64, p: usize) u64 {
return samples[@min(samples.len - 1, samples.len * p / 100)];
}
-/// A unit of a key into a big file, and a digest, with its blobs hashed
-/// whole and hashed once.
+/// A unit of a key into a big file, and a digest.
fn digestBench(dir: []const u8, mb: usize) !void {
var path_buf: [512]u8 = undefined;
const path = try std.fmt.bufPrint(&path_buf, "{s}/big-file.txt", .{dir});
@@ -147,20 +145,15 @@ fn digestBench(dir: []const u8, mb: usize) !void {
_ = 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| {
- 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();
- _ = pardes.replica.digestOf(a);
- d.* = nowNs() - t1;
- }
- 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", pct(&unit_ns, 50) / 1000, pct(&unit_ns, 99) / 1000, pct(&digest_ns, 50) / 1000, pct(&digest_ns, 99) / 1000 });
+ for (&unit_ns, &digest_ns, 0..) |*u, *d, k| {
+ 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();
+ _ = pardes.replica.digestOf(a);
+ d.* = nowNs() - t1;
}
+ std.debug.print("{d} MB file: a unit p50 {d} us p99 {d} us; a digest p50 {d} us p99 {d} us\n", .{ mb, pct(&unit_ns, 50) / 1000, pct(&unit_ns, 99) / 1000, pct(&digest_ns, 50) / 1000, pct(&digest_ns, 99) / 1000 });
}
pub fn main(init: std.process.Init) !void {