perf: externalise @ioredis/commands, and identify what actually holds the memory
Tested the hypothesis that cached base64 images were bloating TanStack Query and Redis. They are not, measured on a loaded 4-tab session: base64 data-URLs, server heap 0.01 MiB (2 strings) base64 blobs, browser heap 0.01 MiB (7 strings) Redis total 2.17 MB image bytes in Redis none - image-proxy stores URL + headers only What the server heap is actually made of (141 MiB used): 41.4 MiB is bundled JavaScript source retained as strings, ~29% of the heap. The memory is the code, not cached data — which is why every cache-tuning idea in the fix catalog measured at zero, and why serverExternalPackages was the only lever that moved idle memory. 7.86 MiB of that is literal duplicate copies: the same module inlined into several Turbopack chunks and retained once per chunk. @ioredis/commands' command table was in 10 chunks and resident 6 times (2.07 MiB wasted), so it is now external — ioredis is already external and owns it as a direct dependency, so it stays traced. Recorded as bundle hygiene, NOT a memory win: idle 89.7 -> 89.4 MiB is inside noise, and board-loaded/peak deltas were smaller than the run-to-run spread (one "before" run read 220.6 MiB against 169-173 for identical code). got and @octokit/request-error duplicate just as badly but were deliberately left bundled: they are only transitive dependencies, and a check inside the image showed got is not traced into node_modules, so externalising it would have turned a bundled module into a require that resolves to nothing — a possible MODULE_NOT_FOUND for zero measured gain. analyze-heap-strings.mjs buckets a snapshot's strings by what they are, which is what made "37 MiB of strings" actionable instead of just alarming. Verified: 28/28 widgets render, auth control passes, zero module-not-found in the container log, typecheck clean. pnpm test 1794/1795 with two different Testcontainers flakes across runs (pi-hole, sabnzbd); both pass 18/18 in isolation.
This commit is contained in:
3 files changed
+129
No files matched your search
@@ -73,6 +73,15 @@ const nextConfig: NextConfig = {
|
||||
"linkedom",
|
||||
// Only reachable through /api/mcp/[transport].
|
||||
"@modelcontextprotocol/sdk",
|
||||
// Bundling inlines a copy per chunk: a server heap snapshot found this package's
|
||||
// command table in 10 chunks and resident 6 times over (2.1 MiB of duplication).
|
||||
// Safe to externalise because ioredis is already external and owns this as a
|
||||
// direct dependency, so it is always traced alongside it. Bundle hygiene — it did
|
||||
// not move measured memory (idle 89.7 -> 89.4 MiB, inside run-to-run noise).
|
||||
// got and @octokit/request-error duplicate similarly but are only transitive
|
||||
// deps here, so externalising them risks a runtime require that was never traced,
|
||||
// for no measured gain.
|
||||
"@ioredis/commands",
|
||||
],
|
||||
experimental: {
|
||||
optimizePackageImports: ["@mantine/core", "@mantine/hooks", "@tabler/icons-react"],
|
||||
|
||||
Reference in new issue
Block a user