Compare commits

...
Author SHA1 Message Date
Cursor Agent 0e9b05e984 Fix perf test bugs: duplicate rAF loop, committed artifacts, percentile edge case
- browserMetrics: Track rAF handle and cancel before restarting in reset()
  to prevent duplicate animation frame loops corrupting rafGapsMs data
- .gitignore: Add artifacts/ and remove accidentally committed test artifacts
- artifact: Clamp percentile index to >= 0 so target=0 returns the minimum
  value instead of undefined/null
2026-04-01 21:12:09 +00:00
5 changed files with 10 additions and 284 deletions

No files matched your search

+1
View File
@@ -21,3 +21,4 @@ apps/web/src/components/__screenshots__
.vitest-*
__screenshots__/
.tanstack
artifacts/
@@ -1,141 +0,0 @@
{
"suite": "virtualization",
"scenarioId": "large_threads",
"startedAt": "2026-04-01T20:57:00.745Z",
"completedAt": "2026-04-01T20:57:01.524Z",
"thresholds": {
"maxMountedTimelineRows": 140,
"threadSwitchP50Ms": 250,
"threadSwitchP95Ms": 500,
"maxLongTaskMs": 120,
"maxRafGapMs": 120,
"burstCompletionMs": 5000,
"longTasksOver50MsMax": 2
},
"summary": {
"maxMountedTimelineRows": 23,
"threadSwitchP50Ms": 49.5,
"threadSwitchP95Ms": 117,
"maxLongTaskMs": 0,
"longTasksOver50Ms": 0,
"maxRafGapMs": 25,
"burstCompletionMs": null
},
"browserMetrics": {
"actions": [
{
"name": "thread-switch-warmup-a",
"durationMs": 117,
"startedAtMs": 591,
"endedAtMs": 708
},
{
"name": "thread-switch-1",
"durationMs": 46.5,
"startedAtMs": 709.7999999523163,
"endedAtMs": 756.2999999523163
},
{
"name": "thread-switch-2",
"durationMs": 49.5,
"startedAtMs": 787.6000000238419,
"endedAtMs": 837.1000000238419
},
{
"name": "thread-switch-3",
"durationMs": 70.69999992847443,
"startedAtMs": 840.7000000476837,
"endedAtMs": 911.3999999761581
},
{
"name": "thread-switch-4",
"durationMs": 45.89999997615814,
"startedAtMs": 916,
"endedAtMs": 961.8999999761581
},
{
"name": "thread-switch-5",
"durationMs": 46.699999928474426,
"startedAtMs": 964.6000000238419,
"endedAtMs": 1011.2999999523163
},
{
"name": "thread-switch-6",
"durationMs": 49.89999997615814,
"startedAtMs": 1047.8999999761581,
"endedAtMs": 1097.7999999523163
}
],
"longTasks": [],
"rafGapsMs": [
0, 8, 0, 17, 0, 7.300000000000068, 0, 8.799999999999955, 0, 8.200000000000045, 0,
9.099999999999909, 0, 7.7000000000000455, 0, 8.399999999999977, 0, 8.800000000000068, 0, 16,
0, 8.399999999999977, 0, 9, 0, 8.299999999999955, 0, 7.600000000000023, 0, 17.100000000000023,
0, 8.600000000000023, 0, 8.299999999999955, 0, 16.200000000000045, 0, 7.899999999999977, 0,
9.299999999999955, 0, 7.399999999999977, 0, 9.200000000000045, 0, 16.700000000000045, 0, 8, 0,
8.299999999999955, 0, 7.899999999999977, 0, 8.700000000000045, 0, 17.100000000000023, 0,
8.199999999999932, 0, 16, 0, 16.600000000000023, 0, 8.399999999999977, 0, 8.899999999999977,
0, 7.800000000000068, 0, 17.399999999999977, 0, 8.299999999999955, 0, 8.300000000000068, 0,
7.699999999999932, 0, 16.700000000000045, 0, 8.100000000000023, 0, 17.399999999999977, 0,
7.7999999999999545, 0, 8.600000000000136, 0, 8.199999999999818, 0, 8.900000000000091, 0,
8.099999999999909, 0, 16.200000000000045, 0, 9.100000000000136, 0, 7.399999999999864, 0, 8.5,
0, 9, 0, 25, 0, 7.600000000000136, 0, 9.199999999999818, 0
],
"mountedRowSamples": [
{
"label": "heavy-a-open",
"count": 17,
"capturedAtMs": 708.5
},
{
"label": "thread-switch-1-rows",
"count": 17,
"capturedAtMs": 782
},
{
"label": "thread-switch-2-rows",
"count": 17,
"capturedAtMs": 837.7000000476837
},
{
"label": "thread-switch-3-rows",
"count": 17,
"capturedAtMs": 914.2000000476837
},
{
"label": "thread-switch-4-rows",
"count": 17,
"capturedAtMs": 962.5
},
{
"label": "thread-switch-5-rows",
"count": 17,
"capturedAtMs": 1034.1000000238419
},
{
"label": "thread-switch-6-rows",
"count": 17,
"capturedAtMs": 1098.3999999761581
},
{
"label": "scroll-start",
"count": 17,
"capturedAtMs": 1113.3999999761581
},
{
"label": "scroll-top",
"count": 23,
"capturedAtMs": 1148.3999999761581
},
{
"label": "scroll-bottom",
"count": 17,
"capturedAtMs": 1164.2000000476837
}
]
},
"serverMetrics": null,
"metadata": {
"heavyThreadMessageCount": 2000
}
}
@@ -1,139 +0,0 @@
{
"suite": "websocket-application",
"scenarioId": "dense_assistant_stream",
"startedAt": "2026-04-01T20:57:03.910Z",
"completedAt": "2026-04-01T20:57:07.151Z",
"thresholds": {
"maxMountedTimelineRows": 140,
"threadSwitchP50Ms": 250,
"threadSwitchP95Ms": 500,
"maxLongTaskMs": 120,
"maxRafGapMs": 120,
"burstCompletionMs": 5000,
"longTasksOver50MsMax": 2
},
"summary": {
"maxMountedTimelineRows": 0,
"threadSwitchP50Ms": 51.199999928474426,
"threadSwitchP95Ms": 52.39999997615814,
"maxLongTaskMs": 0,
"longTasksOver50Ms": 0,
"maxRafGapMs": 16.200000000000045,
"burstCompletionMs": 3135
},
"browserMetrics": {
"actions": [
{
"name": "thread-switch-burst-nav",
"durationMs": 51.199999928474426,
"startedAtMs": 1348.3999999761581,
"endedAtMs": 1399.5999999046326
},
{
"name": "thread-switch-burst-return",
"durationMs": 52.39999997615814,
"startedAtMs": 1401.1999999284744,
"endedAtMs": 1453.5999999046326
},
{
"name": "burst-completion",
"durationMs": 3135,
"startedAtMs": 332.2999999523163,
"endedAtMs": 3467.2999999523163
}
],
"longTasks": [],
"rafGapsMs": [
0, 7.899999999999977, 0, 9, 0, 7.300000000000011, 0, 8.899999999999977, 0, 7.800000000000011,
0, 9.300000000000011, 0, 8.100000000000023, 0, 7.699999999999989, 0, 9.199999999999989, 0,
7.800000000000011, 0, 7.899999999999977, 0, 9.300000000000011, 0, 7.300000000000011, 0,
9.099999999999966, 0, 7.7000000000000455, 0, 8.199999999999989, 0, 8.399999999999977, 0,
8.300000000000011, 0, 8.399999999999977, 0, 8.5, 0, 9.100000000000023, 0, 7.7000000000000455,
0, 8.199999999999932, 0, 8.600000000000023, 0, 8.799999999999955, 0, 7.7000000000000455, 0,
8.200000000000045, 0, 8.399999999999977, 0, 9.100000000000023, 0, 7.5, 0, 8.199999999999932,
0, 9.300000000000068, 0, 7.399999999999977, 0, 8.600000000000023, 0, 8.399999999999977, 0,
8.899999999999977, 0, 8.299999999999955, 0, 7.800000000000068, 0, 8, 0, 8.399999999999977, 0,
8.799999999999955, 0, 7.7000000000000455, 0, 9.299999999999955, 0, 7.400000000000091, 0,
9.299999999999955, 0, 8.299999999999955, 0, 7.7000000000000455, 0, 8.100000000000023, 0,
8.899999999999977, 0, 8.700000000000045, 0, 7.2999999999999545, 0, 9.399999999999977, 0,
8.200000000000045, 0, 8.100000000000023, 0, 7.699999999999932, 0, 9.300000000000068, 0,
8.199999999999932, 0, 8.300000000000068, 0, 7.699999999999932, 0, 8.700000000000045, 0,
8.699999999999932, 0, 7.600000000000023, 0, 8.100000000000023, 0, 8.399999999999977, 0,
8.700000000000045, 0, 8, 0, 8.699999999999932, 0, 8.200000000000045, 0, 8.799999999999955, 0,
8.5, 0, 7.800000000000068, 0, 8.5, 0, 8.600000000000023, 0, 8.399999999999977, 0,
7.899999999999977, 0, 8.100000000000023, 0, 8.100000000000023, 0, 8.399999999999977, 0,
9.299999999999955, 0, 8.100000000000023, 0, 7.5, 0, 9.200000000000045, 0, 8.5, 0,
7.899999999999864, 0, 8.800000000000182, 0, 8.199999999999818, 0, 7.800000000000182, 0, 8.5,
0, 8.199999999999818, 0, 8.900000000000091, 0, 8.299999999999955, 0, 7.900000000000091, 0,
7.899999999999864, 0, 9.300000000000182, 0, 7.599999999999909, 0, 8.400000000000091, 0, 8, 0,
8.399999999999864, 0, 9.200000000000045, 0, 7.400000000000091, 0, 9.299999999999955, 0,
8.200000000000045, 0, 7.5, 0, 9.299999999999955, 0, 8.099999999999909, 0, 7.600000000000136,
0, 9.299999999999955, 0, 8.200000000000045, 0, 8.399999999999864, 0, 7.5, 0,
8.400000000000091, 0, 8.599999999999909, 0, 7.7999999999999545, 0, 8.5, 0, 9.300000000000182,
0, 7.2999999999999545, 0, 9.399999999999864, 0, 7.5, 0, 8.100000000000136, 0, 8.5, 0,
8.099999999999909, 0, 9.100000000000136, 0, 8.599999999999909, 0, 7.5, 0, 9.099999999999909,
0, 7.600000000000136, 0, 8.399999999999864, 0, 8.100000000000136, 0, 8.399999999999864, 0,
8.200000000000045, 0, 9.299999999999955, 0, 8, 0, 16.200000000000045, 0, 9.200000000000045, 0,
8.299999999999955, 0, 8.299999999999955, 0, 8.400000000000091, 0, 7.900000000000091, 0,
8.599999999999909, 0, 8.5, 0, 8.099999999999909, 0, 7.7000000000000455, 0, 8.700000000000045,
0, 8.5, 0, 8.5, 0, 7.599999999999909, 0, 8.900000000000091, 0, 8.599999999999909, 0,
8.400000000000091, 0, 8.299999999999955, 0, 7.7999999999999545, 0, 8.600000000000136, 0,
8.200000000000045, 0, 8.799999999999955, 0, 7.599999999999909, 0, 8.100000000000136, 0,
8.599999999999909, 0, 8.299999999999955, 0, 8.100000000000136, 0, 8.599999999999909, 0,
9.099999999999909, 0, 8.200000000000045, 0, 7.400000000000091, 0, 8.899999999999864, 0, 8.5,
0, 8.5, 0, 7.900000000000091, 0, 8.799999999999955, 0, 7.400000000000091, 0,
9.299999999999955, 0, 7.400000000000091, 0, 9.299999999999955, 0, 8.299999999999955, 0,
8.299999999999955, 0, 7.400000000000091, 0, 8.899999999999864, 0, 8.800000000000182, 0,
7.599999999999909, 0, 8.099999999999909, 0, 8.200000000000045, 0, 9.400000000000091, 0,
7.7000000000000455, 0, 8.899999999999864, 0, 7.400000000000091, 0, 8.399999999999864, 0,
8.900000000000091, 0, 8, 0, 8.5, 0, 8.799999999999955, 0, 7.7000000000000455, 0,
8.200000000000045, 0, 8.700000000000045, 0, 7.899999999999864, 0, 8.799999999999955, 0,
8.400000000000091, 0, 8.099999999999909, 0, 8.200000000000045, 0, 8.200000000000045, 0,
8.200000000000045, 0, 8.799999999999955, 0, 7.7999999999999545, 0, 8.600000000000136, 0,
8.199999999999818, 0, 9.200000000000045, 0, 7.500000000000227, 0, 8.199999999999818, 0,
9.099999999999909, 0, 7.700000000000273, 0, 8.899999999999636, 0, 7.600000000000364, 0,
8.399999999999636, 0, 9.300000000000182, 0, 7.400000000000091, 0, 8.299999999999727, 0,
9.300000000000182, 0, 8.300000000000182, 0, 7.799999999999727, 0, 8.900000000000091, 0,
7.699999999999818, 0, 8.800000000000182, 0, 8.300000000000182, 0, 7.599999999999909, 0,
8.799999999999727, 0, 7.900000000000091, 0, 9.099999999999909, 0, 8.200000000000273, 0, 8, 0,
8.799999999999727, 0, 7.600000000000364, 0, 9.299999999999727, 0, 8.200000000000273, 0,
7.699999999999818, 0, 8, 0, 8.599999999999909, 0, 9.099999999999909, 0, 7.300000000000182, 0,
8.900000000000091, 0, 8.799999999999727, 0, 8.100000000000364, 0, 7.899999999999636, 0, 8, 0,
8.400000000000091, 0, 9.099999999999909, 0, 7.5, 0, 8.800000000000182, 0, 7.900000000000091,
0, 9.299999999999727, 0, 7.5, 0, 9.100000000000364, 0, 8.099999999999909, 0,
7.799999999999727, 0, 8.700000000000273, 0, 7.799999999999727, 0, 9.300000000000182, 0,
8.300000000000182, 0, 8, 0, 8.699999999999818, 0, 7.599999999999909, 0, 9.099999999999909, 0,
8.200000000000273, 0, 7.599999999999909, 0, 9.199999999999818, 0, 8.200000000000273, 0,
8.400000000000091, 0, 8.299999999999727, 0, 8.200000000000273, 0, 8.5, 0, 8.299999999999727,
0, 8.400000000000091, 0, 8.300000000000182, 0, 7.5, 0, 8.5, 0, 8.099999999999909, 0,
9.299999999999727, 0, 7.400000000000091, 0, 9, 0, 8, 0, 8.900000000000091, 0,
8.300000000000182, 0, 8.299999999999727, 0, 7.5, 0, 8.599999999999909, 0, 8, 0,
9.300000000000182, 0, 7.400000000000091, 0, 9.299999999999727, 0, 8.300000000000182, 0,
7.599999999999909, 0, 8.800000000000182, 0, 8.099999999999909, 0, 8, 0, 8.800000000000182, 0,
8.5, 0, 8.5, 0, 8.099999999999909, 0, 8.5, 0, 8, 0, 8.199999999999818, 0, 7.900000000000091,
0, 8.599999999999909, 0, 8.599999999999909, 0, 8, 0, 9.100000000000364, 0, 8.199999999999818,
0, 8.5, 0, 8, 0, 7.800000000000182, 0, 8.899999999999636, 0, 7.800000000000182, 0,
9.099999999999909, 0, 8.300000000000182, 0, 7.799999999999727, 0, 9, 0, 8.300000000000182, 0,
7.5, 0, 9.199999999999818, 0, 7.400000000000091, 0, 9.300000000000182, 0, 8, 0,
7.799999999999727, 0, 9.200000000000273, 0, 8, 0, 7.599999999999909, 0, 8.400000000000091, 0,
9.299999999999727, 0, 7.300000000000182, 0, 8.5, 0, 9.199999999999818, 0, 8.200000000000273,
0, 8.400000000000091, 0, 7.5, 0, 9.199999999999818, 0, 8.300000000000182, 0,
7.399999999999636, 0, 8.400000000000091, 0, 9, 0, 8.599999999999909, 0, 8.200000000000273, 0,
7.5, 0, 9.299999999999727, 0, 8.200000000000273, 0, 8.400000000000091, 0, 7.399999999999636,
0, 8.300000000000182, 0, 9.400000000000091, 0, 8, 0, 8.5, 0, 8.099999999999909, 0, 8, 0, 8, 0,
8.900000000000091, 0, 7.900000000000091, 0, 8.299999999999727, 0, 8.300000000000182, 0, 8.5,
0, 8.699999999999818, 0, 8.099999999999909, 0, 9, 0, 8.300000000000182, 0, 7.400000000000091,
0, 9.099999999999909, 0, 7.800000000000182, 0, 9.099999999999909, 0, 8.199999999999818, 0,
8.400000000000091, 0, 8.300000000000182, 0, 7.899999999999636, 0, 8.700000000000273, 0, 8.5,
0, 7.400000000000091, 0, 8.299999999999727, 0, 8.300000000000182, 0, 9.299999999999727, 0,
8.300000000000182, 0, 8.199999999999818, 0
],
"mountedRowSamples": []
},
"serverMetrics": null,
"metadata": {
"burstSeedThreadId": "perf-thread-burst",
"navigationThreadId": "perf-thread-light-01",
"sentinelText": "PERF_STREAM_SENTINEL:dense_assistant_stream:completed"
}
}
+4 -1
View File
@@ -68,7 +68,10 @@ export function percentile(values: ReadonlyArray<number>, target: number): numbe
}
const sorted = values.toSorted((left, right) => left - right);
const clampedTarget = Math.min(Math.max(target, 0), 1);
const index = Math.min(sorted.length - 1, Math.ceil(sorted.length * clampedTarget) - 1);
const index = Math.min(
sorted.length - 1,
Math.max(0, Math.ceil(sorted.length * clampedTarget) - 1),
);
return sorted[index] ?? null;
}
+5 -3
View File
@@ -30,15 +30,16 @@ export function installBrowserPerfCollector(
const rafGapsMs: number[] = [];
const mountedRowSamples: Array<BrowserPerfMetrics["mountedRowSamples"][number]> = [];
let previousAnimationFrameTs = 0;
let rafHandle = 0;
const animationFrameLoop = (timestampMs: number) => {
if (previousAnimationFrameTs > 0) {
rafGapsMs.push(timestampMs - previousAnimationFrameTs);
}
previousAnimationFrameTs = timestampMs;
window.requestAnimationFrame(animationFrameLoop);
rafHandle = window.requestAnimationFrame(animationFrameLoop);
};
window.requestAnimationFrame(animationFrameLoop);
rafHandle = window.requestAnimationFrame(animationFrameLoop);
if (typeof PerformanceObserver !== "undefined") {
try {
@@ -103,7 +104,8 @@ export function installBrowserPerfCollector(
rafGapsMs.length = 0;
mountedRowSamples.length = 0;
previousAnimationFrameTs = 0;
window.requestAnimationFrame(animationFrameLoop);
window.cancelAnimationFrame(rafHandle);
rafHandle = window.requestAnimationFrame(animationFrameLoop);
},
};
}