diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-29 23:14:10 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-29 23:59:54 -0300 |
| commit | bce88593014a4078dc9259855944f9ddbc19fe54 (patch) | |
| tree | 9be0950d36a63cec15552dccec3cd29550b2f26c /src/locations.zig | |
| parent | c02ab55482c055c57146b9ea9a5a78c20bcdf122 (diff) | |
| download | pardes-bce88593014a4078dc9259855944f9ddbc19fe54.tar.gz pardes-bce88593014a4078dc9259855944f9ddbc19fe54.zip | |
views and the rollback copy: a live view's slot keeps no pointer into what the live core owns; a register's texts and a file's location rows are pinned, not copied
views.zig: when a view goes live (to, close, drawOthers putting the live one back, only), its parked share is emptied (`emptied`): it was left holding copies of the pointers it handed the live fields (a column tag's text, a chord's argument, the presentation's), stale until it parked again. The rollback copy walks every slot: a stale pointer whose memory the live view had freed and another taken saved that other's bytes and put them back. A pane's share holds no pointer but its selections, which `unpark` already hands over. The test fails without it: a tag's text freed under view 0's stale slot, its memory taken by an allocation the copy has no business with, written under a held copy, and the copy put back.
Registers.zig, locations.zig, rollback.zig: a register's values and joined text, and a file's location rows (the dropped ones, a query's saved), are replaced whole and never written, so the copy pins them as it does a file's text, freed raw (a safe build's free would write over one a copy still holds); rows pin whole with what each owns (`pinnedDeep`). In the harness at 30 ms the big copies were a file's location rows, 5-6 MB after the flood, not the register. ReleaseFast, 20 seeds, three clients, p99: copy 5.1 -> 0.22 ms at 30 ms (0.19-0.20 at 80 and 207); rollback 14.9 -> 9.5 ms at 30 ms (1.3-1.4 at 80 and 207), what is left being the replay's digests (half the harness's CPU is Wyhash over the whole core per replayed unit). Tests: a 2 MB register and 500 location rows pinned, not saved, and whole after a speculation drops them and the copy is put back. docs/next-daemon.md: the follow-ups.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/locations.zig')
| -rw-r--r-- | src/locations.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/locations.zig b/src/locations.zig index cdb228a6..40f22f85 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const freeRaw = @import("memory.zig").freeRaw; const pardes = @import("pardes.zig"); const look = @import("look.zig"); const syntax = @import("syntax.zig"); @@ -25,12 +26,14 @@ pub const Row = struct { colors: []u8 = &.{}, }; +/// Raw (no safe build's overwrite): a replica's rollback copy pins a row +/// blob and what its rows own (src/rollback.zig `pinnedDeep`). pub fn freeRows(gpa: std.mem.Allocator, rows: []Row) void { for (rows) |row| { - gpa.free(row.path); - gpa.free(row.colors); + freeRaw(gpa, row.path); + freeRaw(gpa, row.colors); } - gpa.free(rows); + freeRaw(gpa, rows); } /// A list of rows being built, given up: each row's own bytes, then the list. |
