nostr: dev-gated REQ tracer at the pool.sub choke point (#9)

The cold-login REQ storm's remaining emitters are unpinned (the suspected
per-contact list loops don't exist; mutes are already batched). Every
sub/list flows through the shimmed pool.sub, so recordReq() there aggregates
kinds + relay fan-out + emitting call site per 10s window. Zero-cost when
off; arm with localStorage bitvid:reqTrace=1 (auto in dev mode), read
[req-trace] logs or window.__bitvidReqTrace.report().

One traced cold login on unstable will name the storm's sources; the
batching/deferral pass follows from that data.

Tests: tests/req-telemetry.test.mjs (3).

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Fable 5 committed 2026-07-03 21:02:27 -04:00
1 parent 99d1b1dd36
commit 096fe12c19
4 files changed
+295

No files matched your search

+5
View File
@@ -3,6 +3,7 @@
import { isDevMode } from "../config.js";
import { nostrToolsReady } from "../nostrToolsBootstrap.js";
import { devLogger, userLogger } from "../utils/logger.js";
import { recordReq } from "./reqTelemetry.js";
/**
* The default relay set bitvid bootstraps with before loading a user's
@@ -524,6 +525,10 @@ export function shimLegacySimplePoolMethods(pool) {
const { relayList, filterList, requests } =
createLegacySubscriptionContext(relays, filters);
// #9 REQ tracer: every sub/list passes through here — record kinds,
// fan-out, and the emitting call site (no-op unless tracing is armed).
recordReq(relayList.length, filterList);
const listeners = {
event: new Set(),
eose: new Set(),