Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 5, 2023

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
@stackblitz
Copy link

stackblitz bot commented Mar 30, 2023

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