Skip to content

[code-infra] Reduce per-page memory in the browser test suite - #23424

Merged
Janpot merged 2 commits into
mui:masterfrom
Janpot:claude/browser-test-memory
Aug 26, 2026
Merged

Janpot merged 2 commits into
mui:masterfrom
Janpot:claude/browser-test-memory

Conversation

@Janpot

@Janpot Janpot commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

With isolate: false a page is never reloaded, and pages stay open until the whole run ends (vitest#10990) — so whatever the shared setup imports is held by all 21 projects for the entire run.

test/setupVitest.ts imported unstable_resetCleanupTracking from the @mui/x-data-grid and @mui/x-data-grid-pro barrels, which through the source aliases evaluates ~650 modules plus @mui/material in every page — charts, chat, scheduler, pickers, none of which touch the grid. (Both imports were also the same function.) Moved to test/utils/setupDataGrid.ts, registered only by the three Data Grid projects.

Also registers the crash handler once per page instead of once per test file, which is why one crash prints dozens of times in CI logs.

before after
heap, x-date-pickers page 47.5 MB 39.3 MB (−17%)
peak RSS, full local run 18.15 GB 17.35 GB

Buys headroom; doesn't fix the OOM on its own (vitest#9696, #10990). FWIW the jump to a ~50% failure rate bisects to a single commit, #22807.

Testing: full browser suite passes (758 files); x-data-grid* and x-date-pickers* jsdom match master, including its existing flakes.

The browser suite keeps `projects * maxWorkers` pages open for the whole run
(vitest-dev/vitest#10990) and every page holds the union of the modules from
each file it ran, since `isolate: false` never reloads it. Anything the shared
setup pulls in is therefore paid for by all 21 projects, for the whole run.

`test/setupVitest.ts` imported `unstable_resetCleanupTracking` from the
`@mui/x-data-grid` and `@mui/x-data-grid-pro` barrels. Through the source
aliases that evaluates ~650 first-party modules plus `@mui/material`,
`@mui/system` and `@mui/utils` in every page — including charts, chat,
scheduler, pickers and the rest, none of which touch the grid. Both imports
also resolved to the same function, since the pro barrel re-exports
`@mui/x-data-grid/hooks`.

Move the reset into `test/utils/setupDataGrid.ts` and register it only from the
three Data Grid projects. Measured on an `x-date-pickers` page: 47.5MB -> 39.3MB
retained JS heap (-17%). Across a full local run, peak RSS drops from 18.15GB to
17.35GB.

Also register the crash handler once per page instead of once per test file.
`beforeAll` runs per file, so it was adding a duplicate Playwright
`page.on('crash')` listener each time and reporting a single crash dozens of
times over. The guard lives in a regular module because setup files are
re-evaluated per file while their imports stay cached.
@Janpot Janpot added scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). type: regression A bug, but worse, it used to behave as expected. labels Aug 25, 2026
@Janpot Janpot changed the title [test] Reduce per-page memory in the browser test suite [code-infra] Reduce per-page memory in the browser test suite Aug 25, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-23424--material-ui-x.netlify.app/
QR code for https://deploy-preview-23424--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-scheduler 0B(0.00%) 0B(0.00%)
@mui/x-scheduler-premium 0B(0.00%) 0B(0.00%)
@mui/x-chat 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

`test/setupVitest.ts` has always called `server.commands.setupCrashHandler()`
without a matching `BrowserCommands` augmentation, but it is not typechecked:
`test/tsconfig.json` lists `setupVite.ts` in `include`, which does not exist.

Moving the crash-handler registration into `test/utils/` brought it under
`utils/**/*`, where it is checked, so the missing declaration surfaced.

@LukasTy LukasTy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice targeted improvement. 💯

@Janpot
Janpot marked this pull request as ready for review August 25, 2026 15:10
@Janpot
Janpot merged commit ce56700 into mui:master Aug 26, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). type: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants