Repository navigation
perf(compiler): place auto memos by the routes that load them - #8032
benedikt-bartscher wants to merge 6 commits into
Conversation
[Medium impact] The PR appears safe to merge; no blocking issues remain. SummaryAuto memos now live in modules chosen by the routes that load them. Explicit
Reviews (3) · Last reviewed commit: "test(compiler): assert the route module ..." · Reviewed by Greptile |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
…component_memo's signature
… and name route memo modules by Dirs.ROUTES
…eyword-only and list the dropped source_module as breaking
…om and name the app root module in the plugin docstring
The memoize plugin mirrors auto memos into modules named after the
__module__of the page function that produced them (#6218, #6457). That fits@rx.memo, but not auto memos, whose page functions rarely say much about which pages use them:Pages registered through one helper all report the helper's module, so every route imports one memo module holding the memos of all routes:
/bloads all of/'s memos. Wrappers such as an i18n plugin's per-locale page function have the same effect.Pages in separate modules each get their own copy of the memos they share (a navbar used by
pages_a.pyandpages_b.pyis compiled into both modules), so every page change downloads it again.This PR places auto memos by the routes that load them instead. Explicit
@rx.memokeeps mirroring its source module..web/utils/components/routes/<page>.jsx, so a page's output never depends on the other pages.compile_memo_componentscomputes the routes that load each memo through the compiled import graph, which covers memos nested in other memos, in@rx.memobodies and in the app root..web/utils/components/shared/<hash>.jsx, named after the memos it holds so that adding a page doesn't rename it. Memos the app root loads go to its module, which every page loads anyway. Route modules re-export what they don't define./and/en) merge.output.codeSplitting.groupscan't split a module; one module per memo gave the same chunks but built in 21 s instead of 13 s on the site below.Measured on a prerendered 129-route bilingual site, JS raw / gzip:
//→/pricing/→/en__module__The
__module__workaround is no longer needed: with this PR the build is byte-identical with and without it. The prerendered HTML is unchanged. The first view's extra 8 KB over the workaround is react-router's route manifest, which lists the shared chunks of each route. In the helper repro above,/bdrops from 549 to 483 KB raw.For #6688's compile cache: a reused page's output stays valid when placement changes, and placement only needs each page's memo keys, which the cache already records. Placement follows the compiled import graph, so it gets tighter once #8013 drops descendant imports from passthrough memo modules.
Unnamed
rx.client_state()created inside a page function draws a global counter name (cs$0,cs$3, ...), so memos that look identical on two pages differ and stay route-local. They're correct, just not deduplicated; naming them per page deterministically is a separate change.