summaryrefslogtreecommitdiff
path: root/src/Names.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-31 06:28:48 -0300
committerGabriel Schneider <[email protected]>2026-10-31 06:28:48 -0300
commita479792a1ab2b593642d7f648194bfa23ce01dba (patch)
tree96ddee7d879a9084daa07db43b0b7910b072a785 /src/Names.zig
parente179cc44fe5060c76a5b00c41e53f11209f5acd9 (diff)
parent4c761893e5b3fdae422622cfa02104ab36633045 (diff)
downloadpardes-a479792a1ab2b593642d7f648194bfa23ce01dba.tar.gz
pardes-a479792a1ab2b593642d7f648194bfa23ce01dba.zip
Merge the upstream daemon and replicated client/server refactor
Diffstat (limited to 'src/Names.zig')
-rw-r--r--src/Names.zig10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Names.zig b/src/Names.zig
index 0c8ba075..63eec14f 100644
--- a/src/Names.zig
+++ b/src/Names.zig
@@ -33,6 +33,10 @@ query_len: u8 = 0,
/// Bumped whenever `hits` change: the rows are made again only then.
gen: u32 = 0,
+/// The query is `query_buf[0..query_len]`: what lies past it is undefined
+/// (0xAA in Debug, not in a release build), so no digest reads it.
+pub const replica = .{ .len = .{.{ "query_buf", "query_len" }} };
+
pub const Cand = struct {
/// The row: `bytes[start..][0..len]`.
start: u32,
@@ -146,8 +150,7 @@ pub fn typed(n: *Names, gpa: std.mem.Allocator, text: []const u8) void {
pub fn rescore(n: *Names, gpa: std.mem.Allocator) void {
const q = n.queryText();
const empty = std.mem.trim(u8, q, " ").len == 0;
- const io = std.Io.Threaded.global_single_threaded.io();
- const started = std.Io.Clock.awake.now(io);
+ const started = pardes.FrameStats.nowNs();
const had = n.hits.items.len;
const was_scored = n.scored;
var count: usize = 0;
@@ -164,8 +167,7 @@ pub fn rescore(n: *Names, gpa: std.mem.Allocator) void {
const s = if (empty) 0 else match(q, key, n.lower.items[c.start + c.key ..][0..c.key_len], c.base, null, 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
- started.durationTo(std.Io.Clock.awake.now(io)).toNanoseconds() > score_budget_ns) break;
+ if (!empty and count % 256 == 255 and pardes.tape.over(started, score_budget_ns)) 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.