Repository navigation
Conversation
processedBlock was recomputed ~25-30x per render on Svelte: block.lite.tsx memoizes it in _processedBlock, but the cache useTarget branches are empty for svelte (and svelte is in IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK), so the getter runs the full pipeline on every read and the markup reads it 14 direct times (blockComponent/Tag/canShowBlock read it again). Let svelte fall through to the default cache branch. resolveLocalizedValues walked component.options twice (containsLocalizedValues + extractLocalizedValues) via the generic traverse (a closure + Object.entries per node); do it in one in-place pass. Output byte-identical. ~166x at 25 reads/block on a 1,021-block page.
|
|
Review Agent skipped this PR — @PuruVJ doesn't have a Builder seat in this space. If you're @PuruVJ: you may already have a seat under a different GitHub account. Reconnect GitHub If you're an admin: Add @PuruVJ to this space |
|
A few comments from the code review bots. "Byte-identical" is true for JSON content, not for post-binding values. |
Was chasing TBT on a big page and
processedBlockkept coming up. On Svelte it's recomputed ~25-30 times per block per render. The cache already exists (_processedBlock), it's just switched off for Svelte: the read/write/invalidateuseTargetbranches are empty andsveltesits inIS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK. Let it fall through to thedefaultbranch so it computes once. TheonUpdateinvalidation runs for Svelte now too, so it still recomputes once per render, just not 25 times.While in there:
resolveLocalizedValueswalkedcomponent.optionstwice (contains-check, then extract), both through the generictraversethat allocates a closure plus anObject.entriesarray per node. Made it one in-place pass. Output is byte-identical (checked across densities and locales, including a missing locale).Numbers
1,021-block page, ~127k props. tinybench, output asserted byte-identical before timing,
structuredCloneexcluded.The "after" path only computes once, so the speedup tracks the read count. Localization on its own is ~2x and byte-identical. The cache is the multiplier.
Other things
responsiveStyles, which is CSS-only and never holds a LocalizedValue. Skipping that one key is another ~30%. Left it out to keep this byte-identical, easy follow-up.Short version: it was doing the same work 25 times and walking the tree twice for localization. Now it does the work once and walks once.
Note
Medium Risk
Touches Svelte block processing cache and in-place localization of content options. Wrong cache invalidation or walk behavior could stale-render or drop localized fields.
Overview
Cuts Svelte TBT by letting
processedBlockuse the existing_processedBlockcache (andonUpdateinvalidation) instead of recomputing ~25 times per block per render. Vue/Angular/Qwik/Solid stay uncached.Also rewrites
resolveLocalizedValuesto one in-place walk ofcomponent.optionsinstead of a contains-check plus extract viatraverse. Same output, including the missing-locale warning.Reviewed by Cursor Bugbot for commit 158a958. Bugbot is set up for automated code reviews on this repo. Configure here.