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

refactor(scheduler): remove redundant sorting #11646

Merged
merged 7 commits into from
Aug 19, 2024

Conversation

skirtles-code
Copy link
Contributor

Note: This PR currently contains all the changes from #7746. I think that PR should be merged first. This PR is much simpler than it looks, but I needed the code from that PR to avoid breaking the tests.

To understand the refactoring I've done here, see commit fed5518.


Currently, we sort scheduler jobs twice in the main scheduler queue:

  1. In queueJob/findInsertionIndex we calculate where to insert new jobs, ensuring the queue is correctly sorted.
  2. In flushJobs we sort the queue again.

This second sort shouldn't be needed, as the jobs should already be sorted. Its extra code and extra work. It can also lead to inconsistencies and bugs when the two sorts don't perfectly align.

This PR removes that second sort.

This caused a few test failures. Those failures had two underlying causes:

  1. The bug fixed by fix(runtime-core): pre jobs without an id should run first #7746. The extra sort was hiding the problem from the existing tests. I've included the changes from that PR in this PR, but they aren't really part of this refactoring. I think that PR should be merged first, fixing the bug, separately from this refactoring.
  2. There was a bug in findInsertionIndex. The value of start needs to be 0 when isFlushing is false, but it was being set to 1 instead. This bug didn't impact users because the sort in flushJobs was correcting the order. Now the second sort is removed it needs to be handled directly in findInsertionIndex.

With those problems addressed, the existing tests all pass.

Copy link

github-actions bot commented Aug 18, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 98.6 kB (-121 B) 37.4 kB (-32 B) 33.6 kB (-41 B)
vue.global.prod.js 156 kB (-121 B) 57.2 kB (-41 B) 50.9 kB (-1 B)

Usages

Name Size Gzip Brotli
createApp 54 kB (-121 B) 20.9 kB (-44 B) 19.1 kB (-83 B)
createSSRApp 58 kB (-121 B) 22.6 kB (-49 B) 20.6 kB (-52 B)
defineCustomElement 58.7 kB (-121 B) 22.4 kB (-38 B) 20.5 kB (+8 B)
overall 67.6 kB (-121 B) 26 kB (-28 B) 23.7 kB (-22 B)

Copy link

pkg-pr-new bot commented Aug 18, 2024

commit: 57a350b

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@11646

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@11646

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@11646

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@11646

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@11646

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@11646

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@11646

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@11646

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@11646

vue

pnpm add https://pkg.pr.new/vue@11646

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@11646

Open in Stackblitz

@yyx990803
Copy link
Member

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Aug 19, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools failure failure
nuxt success success
pinia success success
primevue success success
quasar success success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@yyx990803 yyx990803 merged commit 7fbf496 into vuejs:main Aug 19, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants