test(perf): fiber-tree probe, and the client-side diagnosis it produced
probe-fiber-tree.mts walks the live React tree and reports which components are mounted, what DOM they render and their props. Heap snapshots only give minified names like `y`, and source maps do not help because the snapshot records runtime names — props shape plus rendered DOM identifies a component reliably. It injects a DevTools hook stub before load so React registers every root; climbing from one DOM node's fiber missed most of the tree (2,093 fibers vs 3,918). What it found, on a 28-widget board: - The most-mounted component is @mantine/core/Box (513). It is the primitive every Mantine component renders through, so it is a symptom of how much is mounted rather than a bug. Proportions match the 650 MB session snapshot (13% vs 17%), so the minified `y` there is almost certainly Box. - 71 Menu -> Popover -> PopoverDropdown triplets are mounted for context menus that are almost never opened. Isolated with the existing enableRightClickOnWidgets flag: 3,918 fibers with them, 3,554 without — 364 fibers, 9%, scaling with item count. The dropdown contents are already lazy; the wrappers are not. A fix that deferred the Menu until first right-click was reverted: it broke right-click and inflated the tree to 20,107 fibers, because the replayed contextmenu event re-entered the arming handler. Doing it properly needs one board-level menu instead of one per item. The Playwright check that caught this is in the findings — a fiber count alone would have read as a win. Also records that the demo account had completed_board_tour = 0, so earlier rounds measured the first-time-user path; completing it moves the tree by 38 fibers, so the published numbers stand.
This commit is contained in:
3 files changed
+225
No files matched your search
@@ -44,6 +44,8 @@ const navIterations = Number(process.env.STRESS_NAV_ITERATIONS ?? 6);
|
||||
const soakMs = Number(process.env.STRESS_SOAK_MS ?? 120_000);
|
||||
const soakIntervalMs = Number(process.env.STRESS_SOAK_INTERVAL_MS ?? 20_000);
|
||||
const keepContainer = process.env.STRESS_KEEP_CONTAINER === "true";
|
||||
/** Dump a browser heap snapshot here (analyse with analyze-react-fibers.mjs). */
|
||||
const clientSnapshotPath = process.env.STRESS_CLIENT_SNAPSHOT;
|
||||
const outputDirectory = path.resolve(process.env.STRESS_OUTPUT ?? `.bench/stress/${label}`);
|
||||
|
||||
const password = process.env.STRESS_PASSWORD ?? "demodemo";
|
||||
@@ -297,6 +299,22 @@ const interactWithWidgetsAsync = async (page: Page, maxClicks = 6) => {
|
||||
return { available, clicked };
|
||||
};
|
||||
|
||||
/** Streams a browser heap snapshot to disk over CDP, for offline fiber analysis. */
|
||||
const captureClientSnapshotAsync = async (page: Page, destination: string) => {
|
||||
const cdp = await page.context().newCDPSession(page);
|
||||
const chunks: string[] = [];
|
||||
cdp.on("HeapProfiler.addHeapSnapshotChunk", ({ chunk }) => chunks.push(chunk));
|
||||
try {
|
||||
await cdp.send("HeapProfiler.enable");
|
||||
await cdp.send("HeapProfiler.collectGarbage");
|
||||
await cdp.send("HeapProfiler.takeHeapSnapshot", { reportProgress: false });
|
||||
await writeFile(destination, chunks.join(""));
|
||||
log(`client heap snapshot -> ${destination}`);
|
||||
} finally {
|
||||
await cdp.detach().catch(() => undefined);
|
||||
}
|
||||
};
|
||||
|
||||
const waitForBoardAsync = async (page: Page) => {
|
||||
const boardSelector = "[data-homarr-dev-benchmark-board]";
|
||||
await page.locator(boardSelector).waitFor({ state: "visible", timeout: 120_000 });
|
||||
@@ -444,6 +462,8 @@ const main = async () => {
|
||||
await captureAsync("07-multi-tab");
|
||||
}
|
||||
|
||||
if (clientSnapshotPath) await captureClientSnapshotAsync(freshPage, clientSnapshotPath);
|
||||
|
||||
const clientHeap = await sampleClientHeapAsync(freshPage);
|
||||
log(
|
||||
`client heap: used=${toMiB(clientHeap.jsHeapUsedBytes)} MiB total=${toMiB(clientHeap.jsHeapTotalBytes)} MiB ` +
|
||||
|
||||
Reference in new issue
Block a user