Skip to content

perf(hmr): keep track of already traversed modules when propagating update#12658

Merged
patak-cat merged 1 commit intomainfrom
perf/dedupe-propagate-update
Apr 5, 2023
Merged

perf(hmr): keep track of already traversed modules when propagating update#12658
patak-cat merged 1 commit intomainfrom
perf/dedupe-propagate-update

Conversation

@ArnaudBarre
Copy link
Member

@ArnaudBarre ArnaudBarre commented Mar 30, 2023

Re: #12062

Not sure this is a complete fix, but probably helps.

This will mostly help people having tree structure like this:

Screenshot 2023-03-30 at 02 56 15

Note: This is not an adviced pattern, and I highly recommend having direct imports from views to components inside the same project. This will always lead to faster HMR (not all views need to refresh on an non self accepting file that is currently re-exported by a barrel file)

I also changed the data structure of boundaries to an array because a set is misleading

@ArnaudBarre ArnaudBarre self-assigned this Mar 30, 2023
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@mattrunyon
Copy link
Contributor

I tried this on my repo where I was having issues with thousands of HMR updates and it fixes the HMR performance for me.

@bluwy
Copy link
Member

bluwy commented Mar 30, 2023

/ecosystem-ci run

@bluwy bluwy added the performance Performance related enhancement label Mar 30, 2023
@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Mar 30, 2023

📝 Ran ecosystem CI: Open

suite result
astro ✅ success
histoire ❌ failure
iles ❌ failure
ladle ✅ success
laravel ✅ success
marko ✅ success
nuxt ✅ success
previewjs ✅ success
qwik ✅ success
rakkas ✅ success
sveltekit ✅ success
vite-plugin-ssr ✅ success
vite-plugin-react ✅ success
vite-plugin-react-pages ✅ success
vite-plugin-react-swc ✅ success
vite-plugin-svelte ❌ failure
vite-plugin-vue ✅ success
vite-setup-catalogue ✅ success
vitepress ✅ success
vitest ✅ success
windicss ✅ success

@bluwy bluwy changed the title perf: keep track of already traversed modules when propagating update perf(hmr): keep track of already traversed modules when propagating update Mar 30, 2023
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Forgot to loop back on this PR, but this looks like a nice and safe change. ecosystem-ci seems to be invalid for the failing ones.

importer,
traversedModules,
boundaries,
currentChain.concat(importer),
Copy link
Member

Choose a reason for hiding this comment

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

Looks great! Let's merge so we can test it during the beta.

Later on, maybe it is worth exploring using a data structure for currentChain/propagateUpdate that doesn't require the creation of new arrays on every call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: hmr performance Performance related enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants