Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(replay): de-flake snapshot processing perf test (#62699)

Raúl Negrón-Oteroda6c422aaec1
diff --git a/frontend/src/scenes/session-recordings/player/snapshot-processing/process-all-snapshots.test.ts b/frontend/src/scenes/session-recordings/player/snapshot-processing/process-all-snapshots.test.ts
index b886e4090d49..c6a00acf0c0b 100644
--- a/frontend/src/scenes/session-recordings/player/snapshot-processing/process-all-snapshots.test.ts
+++ b/frontend/src/scenes/session-recordings/player/snapshot-processing/process-all-snapshots.test.ts
@@ -67,17 +67,11 @@ describe('process all snapshots', () => {
expect(results).toHaveLength(99)
}
- durations.sort((a, b) => a - b)
- // Drop slowest 2 runs (typically first runs with cold JIT/cache)
- const trimmedDurations = durations.slice(0, -2)
- const median = trimmedDurations[Math.floor(trimmedDurations.length / 2)]
- const mean = trimmedDurations.reduce((sum, d) => sum + d, 0) / trimmedDurations.length
- const stdDev = Math.sqrt(
- trimmedDurations.reduce((sum, d) => sum + (d - mean) ** 2, 0) / trimmedDurations.length
- )
-
- expect(median).toBeLessThan(50)
- expect(stdDev).toBeLessThan(25)
+ // Assert on the fastest run only: scheduler/CPU contention on shared CI runners
+ // inflates median and stdDev unpredictably, but noise is additive, so the minimum
+ // is the most stable estimate of intrinsic cost and still catches real regressions.
+ const fastest = Math.min(...durations)
+ expect(fastest).toBeLessThan(50)
})
it('deduplicates snapshot', async () => {