core
core copied to clipboard
perf(reactivity): avoid unnecessary recursion in removeSub
I stumbled across an edge case where the performance of computed can go awry:
The time taken grows exponentially with the value of LAYERS. I used 22 in the example, but you may need to tweak it depending on your hardware.
The problem is with cleaning up the subs. removeSub() calls itself recursively if dep.subs is undefined. But in this example, deps.subs is always undefined for all deps, so it ends up calling removeSub() a huge number of times. The same links are being removed over and over.
I've attempted to fix it by additionally checking that deps.subs wasn't already undefined.
The diff makes the change look more complicated than it actually is. I've moved the if (dep.subs === link) { part further down and wrapped it around the clean-up section.
@vue/compiler-core
pnpm add https://pkg.pr.new/@vue/compiler-core@12135
@vue/compiler-sfc
pnpm add https://pkg.pr.new/@vue/compiler-sfc@12135
@vue/compiler-dom
pnpm add https://pkg.pr.new/@vue/compiler-dom@12135
@vue/compiler-ssr
pnpm add https://pkg.pr.new/@vue/compiler-ssr@12135
@vue/reactivity
pnpm add https://pkg.pr.new/@vue/reactivity@12135
@vue/runtime-core
pnpm add https://pkg.pr.new/@vue/runtime-core@12135
@vue/runtime-dom
pnpm add https://pkg.pr.new/@vue/runtime-dom@12135
@vue/shared
pnpm add https://pkg.pr.new/@vue/shared@12135
@vue/server-renderer
pnpm add https://pkg.pr.new/@vue/server-renderer@12135
vue
pnpm add https://pkg.pr.new/vue@12135
@vue/compat
pnpm add https://pkg.pr.new/@vue/compat@12135
commit: b225ac7
Size Report
Bundles
| File | Size | Gzip | Brotli |
|---|---|---|---|
| runtime-dom.global.prod.js | 101 kB (-5 B) | 38.1 kB (-1 B) | 34.3 kB (+71 B) |
| vue.global.prod.js | 160 kB (-5 B) | 58 kB (-1 B) | 51.5 kB (-32 B) |
Usages
| Name | Size | Gzip | Brotli |
|---|---|---|---|
| createApp (CAPI only) | 49.1 kB (-5 B) | 18.9 kB (-2 B) | 17.3 kB (-1 B) |
| createApp | 55.7 kB (-5 B) | 21.4 kB (-2 B) | 19.5 kB (-45 B) |
| createSSRApp | 59.7 kB (-5 B) | 23.1 kB (-1 B) | 21.1 kB (+46 B) |
| defineCustomElement | 60.4 kB (-5 B) | 23 kB (-2 B) | 20.9 kB (-9 B) |
| overall | 69.4 kB (-5 B) | 26.5 kB (-1 B) | 24.1 kB (+42 B) |
/ecosystem-ci run
📝 Ran ecosystem CI: Open
| suite | result | latest scheduled |
|---|---|---|
| language-tools | :x: failure | :x: failure |
| nuxt | :white_check_mark: success | :white_check_mark: success |
| pinia | :white_check_mark: success | :white_check_mark: success |
| primevue | :white_check_mark: success | :white_check_mark: success |
| quasar | :x: failure | :white_check_mark: success |
| radix-vue | :white_check_mark: success | :white_check_mark: success |
| router | :white_check_mark: success | :white_check_mark: success |
| test-utils | :white_check_mark: success | :white_check_mark: success |
| vant | :white_check_mark: success | :white_check_mark: success |
| vite-plugin-vue | :white_check_mark: success | :white_check_mark: success |
| vitepress | :white_check_mark: success | :white_check_mark: success |
| vue-i18n | :white_check_mark: success | :white_check_mark: success |
| vue-macros | :white_check_mark: success | :white_check_mark: success |
| vuetify | :white_check_mark: success | :white_check_mark: success |
| vueuse | :white_check_mark: success | :white_check_mark: success |
| vue-simple-compiler | :white_check_mark: success | :white_check_mark: success |
/ecosystem-ci run quasar
📝 Ran ecosystem CI: Open
| suite | result | latest scheduled |
|---|---|---|
| quasar | :white_check_mark: success | :white_check_mark: success |