perf: trim vitest hot imports and refresh manifests

This commit is contained in:
Peter Steinberger
2026-03-23 05:25:01 +00:00
parent 7fcbf383d8
commit af9de86286
12 changed files with 1056 additions and 1088 deletions

View File

@@ -0,0 +1,6 @@
export function matchesHotspotSummaryLane(lane, targetLane, lanePrefixes = []) {
if (lane === targetLane) {
return true;
}
return lanePrefixes.some((prefix) => prefix.length > 0 && lane.startsWith(prefix));
}

View File

@@ -3,12 +3,14 @@ import path from "node:path";
import { parseMemoryTraceSummaryLines } from "./test-parallel-memory.mjs";
import { normalizeTrackedRepoPath, tryReadJsonFile, writeJsonFile } from "./test-report-utils.mjs";
import { unitMemoryHotspotManifestPath } from "./test-runner-manifest.mjs";
import { matchesHotspotSummaryLane } from "./test-update-memory-hotspots-utils.mjs";
function parseArgs(argv) {
const args = {
config: "vitest.unit.config.ts",
out: unitMemoryHotspotManifestPath,
lane: "unit-fast",
lanePrefixes: [],
logs: [],
minDeltaKb: 256 * 1024,
limit: 64,
@@ -30,6 +32,14 @@ function parseArgs(argv) {
i += 1;
continue;
}
if (arg === "--lane-prefix") {
const lanePrefix = argv[i + 1];
if (typeof lanePrefix === "string" && lanePrefix.length > 0) {
args.lanePrefixes.push(lanePrefix);
}
i += 1;
continue;
}
if (arg === "--log") {
const logPath = argv[i + 1];
if (typeof logPath === "string" && logPath.length > 0) {
@@ -109,8 +119,8 @@ if (existing) {
}
for (const logPath of opts.logs) {
const text = fs.readFileSync(logPath, "utf8");
const summaries = parseMemoryTraceSummaryLines(text).filter(
(summary) => summary.lane === opts.lane,
const summaries = parseMemoryTraceSummaryLines(text).filter((summary) =>
matchesHotspotSummaryLane(summary.lane, opts.lane, opts.lanePrefixes),
);
for (const summary of summaries) {
for (const record of summary.top) {
@@ -142,7 +152,10 @@ const output = {
config: opts.config,
generatedAt: new Date().toISOString(),
defaultMinDeltaKb: opts.minDeltaKb,
lane: opts.lane,
lane:
opts.lanePrefixes.length === 0
? opts.lane
: [opts.lane, ...opts.lanePrefixes.map((prefix) => String(prefix).concat("*"))].join(", "),
files,
};