From 89f4b611e4e6e1732595d070184daf167b53bfb3 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 20 Nov 2026 04:51:01 -0300 Subject: tape: the budget is a count, step 7 (reports/pardes-handle-69-design.md section 2, P33's lean 3): Names.rescore stops after 3,000,000 of the scorer's cells (a key's bytes times the query's and one, what `match` can visit of a candidate, so a long query's slice is no longer than a short one's) and a tick's Places.fill after 512 KiB read, the places an insert above the view moves charged as read (with many places below it, the moving was what only the clock bounded), so no clock is read in a step: Tape.over, the free over, overNow, the budget site and the two clock reads are deleted, and a far client's guess of a key into a big name query is the session's step by construction (test/daemon.py --far's new scene, a Find over 40,000 names typed into: mispredicted 1, 1, 1 and 4 in four runs of the base, 0 in four of this); the constants measured by pardes-perf's new --search (ReleaseFast, this machine at a load of 12 to 24, every call's instructions counted): a tick's fill on the 18 MB text at most 23-24M instructions where the clock's 4 ms ticks took 47-75M, a rescore's scan on a long query at most 31.5M where the clock's took 32.6M; the longest rescore is not the scan but its sort of every hit at each call (about 125-145M instructions, 16-22 ms, with the clock and with the count alike: not bounded by either, left); the semantics word moves (the site's number goes: 7a610621b2f37456 -> df1f0502317ed362), so cross_replay across this change diverges at the first site after it, as it must; tui core-test 857/1008 (151 skipped), shell-test 1048/1051, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, process-test 0 of 144 failed, both soaks diverged 0 unequal 0 corpus 22 of 22 no leak (bytes: the base's one unlisted `now` stop at 30 ms), daemon.py plain, --far, --games (alone, at load 24), --window-clients, --upgrade both ways against merge31 (new->old alone after the Adopt race); gui unit-test 1645/1649 (the perf check's BaselineHarnessMismatch); frames 77/77, perfab +0.055%, the 121 counts within 0.1% against tree2 (key-down on medium 10,039,595, render on medium 11,454,507; the base 10,039,283 and 11,454,252) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Names.zig | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'core/Names.zig') diff --git a/core/Names.zig b/core/Names.zig index fff2c84f..2fbbec37 100644 --- a/core/Names.zig +++ b/core/Names.zig @@ -2,7 +2,7 @@ //! directory (listed by the disk engine, Stream.zig), the recent files, the open panes, //! a file's declarations. Each keystroke scores them again with a small //! fzf-style scorer (subsequence, Smith-Waterman with affine gaps, bonuses -//! at the starts of words and path segments), a frame's budget at a time, +//! at the starts of words and path segments), a frame's count at a time, //! the best kept first. Lifted from the pick prototype (Pick.zig), whose //! scorer took ~1 ms for 20k paths in a release build. Embedded in a //! Query; the rows it shows are the Query's to make. @@ -56,8 +56,12 @@ pub const max_query = 64; /// A candidate is scored over its first this many bytes. const max_text = 512; const max_cands = 200_000; -/// A keystroke's scoring, and a frame's: what is left waits a frame. -const score_budget_ns = 4 * std.time.ns_per_ms; +/// A keystroke's scoring, and a frame's: at most this many of the +/// scorer's cells (a key's bytes times the query's and one: what `match` +/// can visit of a candidate); what is left waits a frame. A count, not the +/// clock: a client's guess of a key scores as far as the session's step +/// (P27, P30). About 4 ms in a release build (`pardes-perf --search`). +const score_cells = 3_000_000; pub fn deinit(n: *Names, gpa: std.mem.Allocator) void { n.bytes.deinit(gpa); @@ -136,12 +140,12 @@ pub fn typed(n: *Names, gpa: std.mem.Allocator, text: []const u8) void { } /// Scores the pending candidates, then `cands[scored..]`, into `hits`, and -/// sorts them: at most `score_budget_ns` of it a call, the rest on the -/// next frames while the best so far is shown. +/// sorts them: at most `score_cells` of it a call, the rest on the next +/// frames while the best so far is shown. pub fn rescore(n: *Names, gpa: std.mem.Allocator) void { const q = n.queryText(); const empty = std.mem.trim(u8, q, " ").len == 0; - const started = pardes.FrameStats.nowNs(); + var left: usize = score_cells; const had = n.hits.items.len; const was_scored = n.scored; var count: usize = 0; @@ -157,8 +161,8 @@ pub fn rescore(n: *Names, gpa: std.mem.Allocator) void { const key = n.bytes.items[c.start + c.key ..][0..c.key_len]; const s = if (empty) 0 else match(q, key, n.lower.items[c.start + c.key ..][0..c.key_len], c.base, null, null); if (s) |score| n.hits.append(gpa, .{ .cand = i, .score = score }) catch break; - // The clock every 256 candidates: reading it is not free either. - if (!empty and count % 256 == 255 and pardes.tape.over(started, score_budget_ns)) break; + left -|= @as(usize, @min(c.key_len, max_text)) * (q.len + 1); + if (!empty and left == 0) break; } // An empty query keeps the source's order (the walk's, recency): no // row moves as the walk goes on, it only grows at the foot. -- cgit v1.3