From b132abc78977b5618838fa609f90f3ffbb4de7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 4 Jun 2026 12:34:13 +0200 Subject: [PATCH] perf(analytics): thread source-priority once through bp-in-target fast path Load the source-priority blob once and pass it into both BP readers instead of letting each re-query the user. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/lib/analytics/bp-in-target-fast-path.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/analytics/bp-in-target-fast-path.ts b/src/lib/analytics/bp-in-target-fast-path.ts index 2d42884d8..cd6147477 100644 --- a/src/lib/analytics/bp-in-target-fast-path.ts +++ b/src/lib/analytics/bp-in-target-fast-path.ts @@ -53,6 +53,7 @@ import { prisma } from "@/lib/db"; import { annotate } from "@/lib/logging/context"; import { readRollupBuckets } from "@/lib/rollups/measurement-rollups"; +import { loadUserSourcePriority } from "@/lib/rollups/measurement-read"; import { probeRollupCoverage, type RollupCoverageMap, @@ -197,6 +198,9 @@ async function computeFromRollups( return d; })(); + // v1.11.2 — load the source-priority blob once and thread it into both + // reads so the sys/dia fan-out doesn't re-query the user twice. + const priority = await loadUserSourcePriority(userId); const [sysBuckets, diaBuckets] = await Promise.all([ readRollupBuckets( userId, @@ -204,6 +208,7 @@ async function computeFromRollups( "DAY", readSince, now, + priority, ), readRollupBuckets( userId, @@ -211,6 +216,7 @@ async function computeFromRollups( "DAY", readSince, now, + priority, ), ]);