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: replace Map/Set with WeakMap/WeakSet #8549

Merged
merged 2 commits into from
Oct 20, 2023

Conversation

Alfred-Skyblue
Copy link
Member

For the keys of object properties, we should use WeakMap and WeakSet, because they will not prevent the garbage collector from reclaiming the key.

@Alfred-Skyblue Alfred-Skyblue marked this pull request as ready for review June 12, 2023 06:46
@Alfred-Skyblue
Copy link
Member Author

TBR

@netlify
Copy link

netlify bot commented Jul 4, 2023

Deploy Preview for vue-sfc-playground failed.

Name Link
🔨 Latest commit 73cd394
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/64a3cca9e99c4f0008c092a4

@netlify
Copy link

netlify bot commented Jul 4, 2023

Deploy Preview for vue-next-template-explorer failed.

Name Link
🔨 Latest commit 73cd394
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/64a3cca92d4ae20008bcee36

Copy link
Member

@sxzz sxzz left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link

github-actions bot commented Aug 21, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 85.8 kB (+4 B) 32.6 kB (+4 B) 29.5 kB (+4 B)
vue.global.prod.js 132 kB (+8 B) 49.3 kB (+2 B) 44.3 kB (-20 B)

Usages

Name Size Gzip Brotli
createApp 47.9 kB (+4 B) 18.9 kB (+3 B) 17.3 kB (+74 B)
createSSRApp 50.6 kB (+4 B) 20 kB (+2 B) 18.2 kB (-9 B)
defineCustomElement 50.3 kB (+4 B) 19.6 kB (+2 B) 17.9 kB (-1 B)
overall 61.2 kB (+4 B) 23.7 kB (+4 B) 21.5 kB (-44 B)

@LinusBorg
Copy link
Member

LinusBorg commented Oct 20, 2023

This PR solves the same problem as #7827, but I think #7827 should be preferred as it would also clean up deps that are primitive types (strings). But maybe the WeakMap approach is more perfomant? Not sure.

either way the pros and cons should be weighted before merging this. Also, johnson seems to already have included the fix from #7827 in his larger reactivity refactor of #5912 according to #9419 (comment)

@LinusBorg LinusBorg added need discussion and removed ready to merge The PR is ready to be merged. labels Oct 20, 2023
@Alfred-Skyblue
Copy link
Member Author

@LinusBorg #7827 addresses memory leaks in reactivity. This PR aims to replace as many Maps in the project with WeakMaps as possible. It doesn't conflict with the code in #7827, and I believe WeakMap is the best solution for the in this PR.

@LinusBorg
Copy link
Member

Okay, seems I was too quick here. Thanks for getting back to me quickly. :)

@LinusBorg LinusBorg added ready to merge The PR is ready to be merged. and removed need discussion labels Oct 20, 2023
@yyx990803 yyx990803 merged commit 712f96d into vuejs:main Oct 20, 2023
9 checks passed
@Alfred-Skyblue Alfred-Skyblue deleted the chore-perf branch October 20, 2023 13:18
lumozx pushed a commit to lumozx/core that referenced this pull request Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged.
Projects
Development

Successfully merging this pull request may close these issues.

4 participants