diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 15:42:33 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 16:31:13 -0300 |
| commit | 6f9a8b907a504c28aef6c68b923508419b54f0ee (patch) | |
| tree | 4a9411cf4caffb6b7886f52dd67392a623915338 /core/ninep | |
| parent | fa3550eedec44e624384b478fc19a40d94fb7a82 (diff) | |
| download | pardes-6f9a8b907a504c28aef6c68b923508419b54f0ee.tar.gz pardes-6f9a8b907a504c28aef6c68b923508419b54f0ee.zip | |
changes layer: a file with no layer pays for it what tree6 paid, found by measure (instructions by symbol and by source line, Intel PT, on the ReleaseFast pardes-perf, tree6 against round 9's base): perfops against tree6 from 12 of 121 over 0.1% to 1 (the base's `body-appends` +0.44%, `open` +0.235%, `client-key-down` +0.13..0.16%, `client-delete-undo`, `client-edit-char`, `deep-sel` +0.10..0.14%, every frame +3.8k); (1) `File.fillBody`'s row walk compiled worse with the gutter number's layer lookups (`readOnlyRow`, `fileRow`) inlined beside it: PT by source line, tree6's lines matched to the base's by their text, the same bytes walked, the inlined `fitEnd` byte loop +98k an op with no line and its checks reshuffled (body-appends +86k an op): `fillBody(comptime layered)`, as tree6's `comptime ghosted` was, chosen by `mapRows` and `bodyText` (a length test); (2) the 9P path asked the file's text and its offsets through calls: `bodyOf`, `fileDot`, `setFileDot`, `showFileOffset` answer with no layer by a length test, inline (core/ninep/pane.zig); (3) `open` (+8.8k since tree6, step 1's): not the change-id rule's regexp (it stands after the file rules and is never reached for a file) but its PARSE: pardes-perf's open boots a core each time and each core reads the rules at its first plumb (`Plumb.Parser.take` +4.0k, `expand` +1.4k, `feed` +1.2k, `endSet`, `word`, `append`, `stringToEnum`: +8.6k): the rule is deleted from core/plumbing and Look's own unresolved path takes a change id (core/look.zig `lookUnresolved`: eight letters or more, k to z, in a pane neither a raw terminal's nor a kind's, the rule's `src is pardes`; `jj.diffChange`; one naming no change searched for as before), no rule and no parse anywhere; (4) a client's key (+2.0..2.4k): the digest of File.State's two new fields, two small hash updates a pane a digest (Wyhash's buffered update and its memcpy): one field, `layer: Layer` (`owner`, `lines`: what were `layer` and `read_only`), digested by hand (`Layer.digest`: nothing hashed with no layer shown, a length test), its line in replica.zig's `hand_walked` (the test joining a client over a pane showing the layer); LEFT FOR THE COORDINATOR'S RULING: `terminal on all` +0.141% (+147k an op over the 18 terminal cells, +7.8k a terminal frame, the same in-run by an in-process counter around each cell): PT by line in the terminal's render cell: core/ansi.zig `recolor`'s per-cell style loop (source unchanged) compiled worse inlined into `body_layer.renderBody` after round 8's deletions there (`w.ghost`'s skips, `Pane.wrapAt`'s `ghost` field): what it buys is those deletions; `@call(.never_inline, ansi.recolor)` made it worse (+0.227%, and `deep-sel` +0.285%), not kept; perfops (the gate's malloc setting, load 2-9): v4 against tree6 120 of 121 within 0.1%, largest under the budget `client-key-down` on medium +0.065%; core-test 952/1118 (166 skipped) Debug tui
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/ninep')
| -rw-r--r-- | core/ninep/pane.zig | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/core/ninep/pane.zig b/core/ninep/pane.zig index 2616c735..093a9223 100644 --- a/core/ninep/pane.zig +++ b/core/ninep/pane.zig @@ -150,9 +150,11 @@ pub const State = struct { /// buffer less its read-only lines, the `Changes` layer's, which are no /// text of the file's). Every address, `dot` and range over 9P is of this /// text (`fileDot`); a write to it is the file's (`spliceBody`). -pub fn bodyOf(p: *Pardes, pane: *const Pane) []const u8 { - if (pane.file) |*f| return panes.File.fileText(f, p.scratch.allocator()) catch ""; - return ""; +pub inline fn bodyOf(p: *Pardes, pane: *const Pane) []const u8 { + const f = if (pane.file) |*file| file else return ""; + // No layer shown: the buffer is the file's text (a length test). + if (f.layer.lines.len == 0) return f.content; + return panes.File.fileText(f, p.scratch.allocator()) catch ""; } /// The buffer the editor edits (with the layer's lines): what the @@ -165,7 +167,7 @@ fn bufferOf(pane: *const Pane) []const u8 { /// Whether 9P reads of the pane are a copy of its file's text, not a /// region of its buffer (`fsPayload` reads the buffer). fn layered(pane: *const Pane) bool { - return if (pane.file) |*f| f.read_only.len > 0 else false; + return if (pane.file) |*f| f.layer.lines.len > 0 else false; } pub fn fileOf(pane: *Pane) ?*panes.File.State { @@ -301,20 +303,22 @@ pub fn showOffset(tab: u16, pane: *Pane, off: usize) void { /// `dotOf` in the file's text's offsets, as 9P serves it (`bodyOf`): a dot /// in a read-only line is after the file line above it. -pub fn fileDot(pane: *Pane) State.Range { +pub inline fn fileDot(pane: *Pane) State.Range { const d = dotOf(pane); const f = if (pane.file) |*file| file else return d; + if (f.layer.lines.len == 0) return d; return .{ .q0 = clip(panes.File.fileOffset(f, d.q0)), .q1 = clip(panes.File.fileOffset(f, d.q1)) }; } /// `setDot` from the file's text's offsets (`fileDot`). -pub fn setFileDot(tab: u16, pane: *Pane, r: State.Range) void { +pub inline fn setFileDot(tab: u16, pane: *Pane, r: State.Range) void { const f = if (pane.file) |*file| file else return setDot(tab, pane, r); + if (f.layer.lines.len == 0) return setDot(tab, pane, r); setDot(tab, pane, .{ .q0 = clip(panes.File.bufferOffset(f, r.q0, false)), .q1 = clip(panes.File.bufferOffset(f, r.q1, r.q1 > r.q0)) }); } /// `showOffset` of a file's text's offset. -pub fn showFileOffset(tab: u16, pane: *Pane, off: usize) void { +pub inline fn showFileOffset(tab: u16, pane: *Pane, off: usize) void { const f = if (pane.file) |*file| file else return showOffset(tab, pane, off); showOffset(tab, pane, panes.File.bufferOffset(f, off, false)); } |
