stack/apps/backend
Bilal Godil 81c84289b8 perf(platform-analytics): cut ClickHouse query peak memory
Reduce the worst-case concurrent ClickHouse memory of the internal
platform-analytics route (all 17 CH queries fire in one Promise.all on
the shared admin user, against a 9 GB per-user cap).

- Use sipHash64(user_id) as the distinct key in the uniqExact/uniqExactIf
  aggregates (dauSeries, sparkByProject, mauProjects, activeByProject).
  Exact at this scale (64-bit, negligible collision prob over 1M users),
  verified byte-identical; -40% to -61% peak memory per query.
- Sample the new/retained/reactivated activity split at 1-in-4 users
  (consistent cityHash bucket on both subqueries, counts scaled x4). The
  split's window function + all-history scan made it the heaviest query
  (~1.3 GiB at 1M users / 50M events); sampling cuts it ~78% for a ~0.4%
  mean error. Dashboard chart now notes it is a sampled estimate.

Adds the benchmark/optimization harnesses used to validate these changes
(seed isolated bench_pa DBs, measure peak memory, verify result equality).
2026-06-19 10:54:37 -07:00
..
prisma feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
scripts perf(platform-analytics): cut ClickHouse query peak memory 2026-06-19 10:54:37 -07:00
src perf(platform-analytics): cut ClickHouse query peak memory 2026-06-19 10:54:37 -07:00
.env feat(hexclave): PR 2 — visible rebrand (Hexclave brand goes public) (#1481) 2026-05-26 19:18:20 -07:00
.env.development feat(hexclave): PR 2 — visible rebrand (Hexclave brand goes public) (#1481) 2026-05-26 19:18:20 -07:00
.eslintrc.cjs tsup for stack-shared (#647) 2025-04-28 21:26:52 -07:00
.gitignore private files n sm build shit (#1276) 2026-03-23 12:31:36 -07:00
instrumentation-client.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
LICENSE Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
next.config.mjs private files n sm build shit (#1276) 2026-03-23 12:31:36 -07:00
package.json add platform analytics route to the dashboard 2026-06-18 16:53:03 -07:00
prisma.config.ts [Fix]: Assortment of Bugs with Timefold Table and Payments (#1348) 2026-04-18 14:17:24 -07:00
tsconfig.json Fix lint 2026-02-27 09:59:26 -08:00
vercel.json External db sync (#1036) 2026-02-05 12:04:31 -08:00
vitest.config.ts Add LLM metadata endpoints (#1499) 2026-05-28 18:07:28 -07:00
vitest.setup.ts Customizable ports (#962) 2025-10-20 15:24:47 -07:00