From b28053aede910b8714db4f27ef66e59dd96945c0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 24 Nov 2026 21:10:15 -0300 Subject: Prompt: `/` and `?` search a file's body as they are typed (walk UI, pick-ui SPEC.md §7.3, item 2 of line E): its places found from where it began (Places.search, the view's on the key, a frame's budget a tick after), tinted, the current one stronger and selected as soon as it is found (`?`: the last before the caret, once the text between is searched), the gutter marked in the blank after each line number (`▸` the current place's line, `▪` the others'), counted `3/7 · 5 lines` (`3/⋯` while they are found; the lines counted once, at the step they are all found, a pass to the last place), ` · wrapped` past the end from where it began, `0` for no match; a pattern that is no regex keeps the last places, dimmed (Places.paint), the reason in the count; Enter lands, the pattern in `/`, and folds the pane's one search word into its trail (`/dirty/ 3/7`, Trail.setWord: the newest back step, in place of the one it had); n and N write it again in place and echo `/dirty/ 4/7 · line 112` on the message row, ` ↻` after a step round an end, `–/7` with the selection off its places, every step (Prompt.settle beside the places'); the first Esc in normal mode clears a search's tints (SPEC §10.4's first step: C's Esc order when it lands) and the word stays, dimmed (draw.zig, Trail.spanOf); Look on the word lights its places again and selects the one it was on, Exec searches again from the caret (Trail.lookStep, execStep); `*` makes the selection's pattern the search word, no prompt and no query pane; Alt-Enter keeps the places as rows: today's query pane (Query.open .text), the body as it was; `?` is helix's backward search, a new role (modal.zig, config.zig); THE FAULTS THE TESTS MET, both B's and latent until a word step was made: Trail.wordOf returned the text of a COPY of the step (a slice of its stack frame: the word drawn as garbage), now the step's own bytes; Trail.lastCur held `cur` under `n`, though keep() leaves a held pane's at `n` (a search word alone: the dump's load moved it and the digests differed), now `n`; TEST FIRST: Prompt.zig "/ searches the body as it is typed ..." and "? searches back from the caret ..."; Places' `*` test reads the echo, Query's and Stream's `/` tests keep their query pane by Alt-Enter, Query's `*` test reads the word; test/perf.zig --search measures a key in `/` and `s` on a 1 MB file; goldens fsearch, lookrange (the prompt in the tag, the word in the trail); core-test 1016/1182 (166 skipped), shell-test 1229/1232, pane-test 182/184, behaviour-test 274/277 (the failures A's, as on item 1), process-test A's six and none of mine, term-test 17/17, kitty-test 45/45 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- test/perf.zig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/perf.zig') diff --git a/test/perf.zig b/test/perf.zig index f36d64ac..4ba061e1 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -1822,6 +1822,38 @@ fn measureSearch(io: std.Io) !void { } slow.report("fill", pattern, set.hits.items.len); } + + // A key typed into a text prompt in the tag (core/Prompt.zig) on a 1 MB + // file, with its frame: `/` from the middle (its places from the view on, + // a frame's budget a tick after), `s` over the whole text (`%`). + const mb: Fixture = .{ .name = "onemeg", .lines = 17_000, .cols = 60 }; + const mb_path = try std.fmt.allocPrint(gpa, "{s}/{s}.zig", .{ dir, mb.name }); + defer gpa.free(mb_path); + const mb_text = try generate(mb); + try writeFile(mb_path, mb_text); + std.debug.print("prompt keys over {d} bytes\n", .{mb_text.len}); + gpa.free(mb_text); + for ([_][]const u8{ "/", "%s" }) |opener| for ([_][]const u8{ "helper", "qqq" }) |typed| { + const core = try boot(); + defer core.deinit(); + pardes.look.lookAt(core, 0, mb_path); + pump(core); + const id = filePane(core) orelse return error.OpenDidNotOpenFile; + const pane = core.panes[id].?; + seek(pane, mb, 0); + pane.file.?.scroll = mb.lines / 2; + pane.body.cur_row = @intCast(mb.lines / 2); + _ = try frame(core); + for (opener) |c| core.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + _ = try frame(core); + for (typed, 0..) |c, n| { + const was = counter.read(); + const t0 = nowNs(); + core.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + _ = try frame(core); + std.debug.print("prompt {s} \"{s}\": {d} instructions, {d} us (key and frame)\n", .{ opener, typed[0 .. n + 1], counter.read() -| was, (nowNs() -| t0) / 1000 }); + } + }; } /// The longest of a scan's calls. -- cgit v1.3 From d2984ed50f72468b1c7304f4b354a2a5f242e2ca Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 24 Nov 2026 23:05:03 -0300 Subject: perf: pardes-perf --walkf measures line F's hot paths in a 2,000-line file, each a step and its frame (a Down in the registers' level unrolled, a frame with `]`'s targets painted against one at rest, a Down in the themes picker), and the painted targets look for the spec's six alone (`f p T c g d`, pick-ui SPEC §4.4: the tree objects function, test, comment; a type's, an argument's, an entry's and an element's queries no longer run on the frame): a frame with `]` painted 18.1M instructions in Debug before, 11.7M after, against 1.17M at rest (walk UI line F, the brief's measures; the ReleaseFast counts in the report) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- core/body_layer.zig | 6 ++--- test/perf.zig | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 4 deletions(-) (limited to 'test/perf.zig') diff --git a/core/body_layer.zig b/core/body_layer.zig index 13c24f97..3736e467 100644 --- a/core/body_layer.zig +++ b/core/body_layer.zig @@ -558,8 +558,8 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane /// Painted targets (SPEC §4.4), while a motion root's level shows in this /// body's tag: each of its keys at the line it would go to, in the gutter /// (`g e t b .` for `g`; for `]` the next and for `[` the previous -/// function, paragraph, test, comment, change, diagnostic, type, argument: -/// `f p T c g d t a`); browsing `m a` or `m i` unrolled, the brackets' +/// function, paragraph, test, comment, change and diagnostic: `f p T c g +/// d`, the spec's, each tree object a query of the rows shown); browsing `m a` or `m i` unrolled, the brackets' /// region around the caret tinted. Only the rows shown are looked at: a /// target off them is not painted (the tag's arrows, SPEC §15, are not /// built). At rest it costs one test of the view's tag state. @@ -778,7 +778,7 @@ fn targetLine(p: *Pardes, pane: *Pane, f: *panes.File.State, role: modal.Normal. if (forward) return if (a < hits.len) lineOf(f, hits[a].start) else null; return if (a > 0) lineOf(f, hits[a - 1].start) else null; }, - inline .goto_function, .goto_class, .goto_parameter, .goto_comment, .goto_test, .goto_entry, .goto_xml_element => |r| { + inline .goto_function, .goto_comment, .goto_test => |r| { // The tree as the motion reads it, made once a revision; with // the Changes layer's lines in the buffer its offsets are not the // buffer's: not painted then. diff --git a/test/perf.zig b/test/perf.zig index 16066e9f..9308bbcd 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -396,6 +396,8 @@ const Options = struct { search: bool = false, /// A picker's key and frame (`measurePick`). pick: bool = false, + /// The walk UI's line F: registers, painted targets, themes (`measureWalkF`). + walkf: bool = false, terminal_mib: ?usize = null, /// The real binary's keystroke-to-present, `yes` stream and big open /// (a tty pardes), or its keystrokes alone (a pardes-gui). @@ -412,7 +414,7 @@ const Options = struct { while (i < args.len) : (i += 1) { const arg = args[i]; if (!std.mem.startsWith(u8, arg, "--")) return error.UnknownOption; - const option = std.meta.stringToEnum(enum { json, creation, startup, mini, search, pick, @"terminal-mib", @"self-test", reps, cols, rows, base, only, op, @"max-ratio", live, @"live-gui" }, arg[2..]) orelse + const option = std.meta.stringToEnum(enum { json, creation, startup, mini, search, pick, walkf, @"terminal-mib", @"self-test", reps, cols, rows, base, only, op, @"max-ratio", live, @"live-gui" }, arg[2..]) orelse return error.UnknownOption; switch (option) { .json => opts.json = true, @@ -421,6 +423,7 @@ const Options = struct { .mini => opts.mini = true, .search => opts.search = true, .pick => opts.pick = true, + .walkf => opts.walkf = true, .@"self-test" => opts.self_test = true, else => { i += 1; @@ -484,6 +487,7 @@ pub fn main(init: std.process.Init) !void { if (opts.mini) return measureMini(init.io, init.gpa, reps, opts.json); if (opts.search) return measureSearch(init.io); if (opts.pick) return measurePick(init.io); + if (opts.walkf) return measureWalkF(init.io); if (opts.live) |exe| return measureLive(init.io, exe, false, reps, opts.json); if (opts.live_gui) |exe| return measureLive(init.io, exe, true, reps, opts.json); // The image-frame cells load the image addon by the path the build baked @@ -1903,6 +1907,77 @@ fn measurePick(io: std.Io) !void { if (!std.mem.endsWith(u8, landing.file.?.path, ".zig") or std.mem.indexOf(u8, landing.file.?.path, "pickme_") == null) return error.NoPreview; } +/// `--walkf`: line F's hot paths in a 2,000-line file, each a step and +/// the frame that draws it, its instructions counted: a key in the +/// registers' level unrolled (Down, its value step read again); a frame +/// with `]`'s targets painted against one at rest; a cursor move in the +/// themes picker (the window wearing the next theme). +fn measureWalkF(io: std.Io) !void { + var random: [12]u8 = undefined; + io.random(&random); + const dir = try std.fmt.allocPrint(gpa, "/tmp/pardes-walkf-{x}", .{random}); + defer gpa.free(dir); + try std.Io.Dir.createDirAbsolute(io, dir, .default_dir); + defer std.Io.Dir.cwd().deleteTree(io, dir) catch {}; + const path = try std.fmt.allocPrint(gpa, "{s}/walkf.zig", .{dir}); + defer gpa.free(path); + var body: std.ArrayList(u8) = .empty; + defer body.deinit(gpa); + for (0..250) |i| try body.print(gpa, "/// The {d}th.\nfn f{d}(a: u32) u32 {{\n const b = a + {d};\n return b;\n}}\n\ntest \"f{d}\" {{\n}}\n", .{ i, i, i, i }); + try writeFile(path, body.items); + var counter: Instructions = try .open(); + defer counter.close(); + const core = try boot(); + defer core.deinit(); + core.settings.jumps = .walk; + pardes.look.lookAt(core, 0, path); + pump(core); + _ = filePane(core) orelse return error.OpenDidNotOpenFile; + for ("abcdefgh", 0..) |r, i| try core.registers.put(gpa, r, body.items[i * 40 ..][0..200], 0, 1, true); + try frame(core); + const Step = struct { + fn run(c: *pardes.Pardes, ev: pardes.Event, n: *Instructions, s: *Slowest) !void { + const was = n.read(); + const t0 = nowNs(); + c.update(ev); + try frame(c); + s.add(nowNs() -| t0, n.read() -| was, 0); + } + }; + const shown = struct { + fn wait(c: *pardes.Pardes) !void { + c.advance(c.clock.now_ns); + c.clock.now_ns = c.view().tag_state.due_ns; + try frame(c); + } + }; + // Registers: `"`, its level shown, unrolled; then Down over its rows. + core.update(.{ .key = .{ .cp = '"' } }); + try shown.wait(core); + core.update(.{ .key = .{ .cp = pardes.Key.down } }); + var regs: Slowest = .{}; + for (0..8) |_| try Step.run(core, .{ .key = .{ .cp = pardes.Key.down } }, &counter, ®s); + regs.report("registers Down + frame", "\"", 0); + core.update(.{ .key = .{ .cp = pardes.Key.escape } }); + // A frame at rest, then frames with `]`'s targets painted. + var rest: Slowest = .{}; + var painted: Slowest = .{}; + for (0..8) |_| try Step.run(core, .tick, &counter, &rest); + core.update(.{ .key = .{ .cp = ']' } }); + try shown.wait(core); + for (0..8) |_| try Step.run(core, .tick, &counter, &painted); + rest.report("tick + frame at rest", "", 0); + painted.report("tick + frame, ] painted", "]", 0); + core.update(.{ .key = .{ .cp = pardes.Key.escape } }); + // The themes picker: Down, the window wearing the next. + pardes.Pick.open(core, core.view().active, .themes, "", "", ""); + try frame(core); + var themes: Slowest = .{}; + for (0..8) |_| try Step.run(core, .{ .key = .{ .cp = pardes.Key.down } }, &counter, &themes); + themes.report("themes Down + frame", "", 0); + if (core.theme_preview == null) return error.NoThemePreview; +} + /// The longest of a scan's calls. const Slowest = struct { calls: usize = 0, -- cgit v1.3