summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 20:14:31 -0300
committerGabriel Schneider <[email protected]>2026-10-29 21:13:33 -0300
commit22a482a9f1d73472e646b4a83b55bafd9528f5a3 (patch)
tree0144c8eb191bfade8c40de02809ed81d720d6bb3
parentd8e30740463dda5a87fb8a4f6e9755fbb84b7220 (diff)
downloadpardes-22a482a9f1d73472e646b4a83b55bafd9528f5a3.tar.gz
pardes-22a482a9f1d73472e646b4a83b55bafd9528f5a3.zip
dump: savePane puts back only the fields it changes, not a copy of the whole 88 KB pane, and makes its empty undo history only for a slim record; the notes say what the small close after a big one measures
Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--docs/next-daemon.md28
-rw-r--r--src/dump.zig32
2 files changed, 41 insertions, 19 deletions
diff --git a/docs/next-daemon.md b/docs/next-daemon.md
index 0462c445..0f008974 100644
--- a/docs/next-daemon.md
+++ b/docs/next-daemon.md
@@ -1529,16 +1529,26 @@ own spread as the A/A): the perf harness's core cells 0.92-0.99 of base
| Restore of it | 1845 ms | 310 ms | 0% |
| a closed pane kept: the terminal | 131 ms | 143 ms | 4% |
| the 100 MB file | 433 ms | 127 ms | 3% |
-| a small file, the step after that | 9.6 ms | 17 ms | 44% |
+| a small file, after the 100 MB one | 9.6 ms | 17 ms | 44% |
| a small file, alone | 1.0 ms | 1.0 ms | 7% |
A clean file's text is in the dump now (what makes it complete), and an
unsaved one's undo (the 100 MB file's one edit keeps the text before it);
-binary, not base64 in ZON, so the rest is faster. A small pane's close
-costs what it did: the 17 ms is the 100 MB pane's teardown (panes are
-freed two syncs after they close, its undo's text with it) landing in
-the next close's time; three small closes after two others take 1 ms in
-both builds. The type table is made once a process (it was made at
-every store record: 123 µs to 33 µs a small pane's record in Debug). The
-live keystroke cells were not run (perf rule: `--live` only for a change
-to terminal output); a dump is off the hot path.
+binary, not base64 in ZON, so the rest is faster. The small close after
+the big one is not the small pane's: it is the kernel freeing the 100 MB
+pane's memory on the 9P connection's thread (panes are freed two syncs
+after they close), 208 MB against the base's 108, since the restored
+unsaved file's undo holds a copy of its text (found with the access
+tracer, perf and schedstat, .scratch/daemon/trace). A small close alone
+is level (three after two others: 1.0 ms both; an isolated one, median
+of ten: base 0.77 ms, new 0.92). Of the 0.15 ms left, two thirds were
+outside the walk and are gone: savePane kept the whole 88 KB Pane aside
+and put it back, and built a 41 KB empty undo history when it was not
+slim; it saves only the fields it changes now. The type table is made
+once a process (it was made at every store record: 123 µs to 33 µs a
+small pane's record in Debug). ponytail: Store.close's CRC32 over the
+record is most of what is left, and a record repeats its 14.6 KB type
+table; a table once per store file would shrink both, a change to the
+store's format left until a close's cost matters. The live keystroke
+cells were not run (perf rule: `--live` only for a change to terminal
+output); a dump is off the hot path.
diff --git a/src/dump.zig b/src/dump.zig
index e6a41f09..2cef46e2 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -457,22 +457,34 @@ fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool
/// file's text, which is read from its file again (a store's record past
/// its bound).
pub fn savePane(gpa: std.mem.Allocator, pane: *pardes.panes.Pane, slim: bool) ![]u8 {
- const was = pane.*;
- defer pane.* = was;
- if (was.cwd == .inherited) {
+ // The fields it changes put back after, not the whole pane (88 KB) kept
+ // aside: a store record is made at every close.
+ const cwd = pane.cwd;
+ const attached_to = pane.attached_to;
+ const terminal = pane.terminal;
+ defer {
+ pane.cwd = cwd;
+ pane.attached_to = attached_to;
+ pane.terminal = terminal;
+ }
+ if (cwd == .inherited) {
// Read before the union is written (its tag is set first).
const dir = pane.cwdSlice();
pane.cwd = .{ .owned = @constCast(dir) };
}
pane.attached_to = null;
- var empty: pardes.panes.File.History = .{};
- if (slim) {
- pane.terminal = null;
- if (pane.file) |*f| {
- f.history = &empty;
- if (f.output == null and f.revision == f.saved_revision and filesystem.localPath(f.path) != null) f.content = &.{};
- }
+ if (!slim) return walk.save(pardes.panes.Pane, gpa, pane);
+ pane.terminal = null;
+ const f = if (pane.file) |*file| file else return walk.save(pardes.panes.Pane, gpa, pane);
+ const history = f.history;
+ const content = f.content;
+ defer {
+ f.history = history;
+ f.content = content;
}
+ var empty: pardes.panes.File.History = .{};
+ f.history = &empty;
+ if (f.output == null and f.revision == f.saved_revision and filesystem.localPath(f.path) != null) f.content = &.{};
return walk.save(pardes.panes.Pane, gpa, pane);
}