From 8f7083c738f28698f6fce31dbbf77e47c9bd26df Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Sun, 1 Mar 2026 22:00:17 -0600 Subject: [PATCH] refactor: remove warmCache, rely on multi-threaded on-demand resolver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the warmCache approach queued all 1.36M active DIDs — most of which won't post for hours — competing with actually-active DIDs for resolver time. the on-demand queue with 4 threads is a natural activity-weighted priority queue that resolves exactly the right DIDs. Co-Authored-By: Claude Opus 4.6 --- src/main.zig | 3 --- src/validator.zig | 22 ---------------------- 2 files changed, 25 deletions(-) diff --git a/src/main.zig b/src/main.zig index e3eea4e..22572ab 100644 --- a/src/main.zig +++ b/src/main.zig @@ -119,9 +119,6 @@ pub fn main() !void { // start: loads active hosts from DB, spawns subscriber threads try slurper.start(); - // pre-populate resolver queue with all known active DIDs - val.warmCache(&dp); - // start GC thread (runs every 10 minutes) const gc_thread = try std.Thread.spawn(.{}, gcLoop, .{&dp}); diff --git a/src/validator.zig b/src/validator.zig index ce4b9b6..e01ede4 100644 --- a/src/validator.zig +++ b/src/validator.zig @@ -8,7 +8,6 @@ const std = @import("std"); const zat = @import("zat"); const broadcaster = @import("broadcaster.zig"); -const event_log_mod = @import("event_log.zig"); const Allocator = std.mem.Allocator; const log = std.log.scoped(.relay); @@ -102,27 +101,6 @@ pub const Validator = struct { } } - /// pre-populate the resolve queue with all active DIDs from the database. - /// call after slurper.start() so subscribers are already running. - pub fn warmCache(self: *Validator, persist: *event_log_mod.DiskPersist) void { - var result = persist.db.query( - "SELECT did FROM account WHERE status = 'active' AND upstream_status = 'active' ORDER BY uid ASC", - .{}, - ) catch |err| { - log.warn("cache warming: query failed: {s}", .{@errorName(err)}); - return; - }; - defer result.deinit(); - - var count: u64 = 0; - while (result.nextUnsafe() catch null) |row| { - const did = row.get([]const u8, 0); - self.queueResolve(did); - count += 1; - } - log.info("cache warming: queued {d} DIDs for resolution", .{count}); - } - /// validate a #sync frame: signature verification only (no ops, no MST). /// #sync resets a repo to a new commit state — used for recovery from broken streams. /// on cache miss, queues background resolution and skips. -- 2.51.2