Skip to content

chore: make effect scheduling more efficient #16346

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Rich-Harris
Copy link
Member

probably won't merge this due to conflicts with async, which is where I noticed this, but I thought it worth pushing up so that I don't lose track of it

We currently have some inefficiency around effect scheduling. Inside certain blocks, like each and await blocks, we update internal sources that populate the branches within. Updating these sources causes a schedule_effect to occur while the flush is ongoing, but since the parent effects have already been marked clean by the time the child effect is scheduled, this causes the root effect to be re-added to queued_root_effects, which in turn causes another turn of the while loop in flush_queued_root_effects. Since the newly scheduled effects are already handled as part of the first flush, the second flush is just a wasteful no-op.

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@16346

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.

1 participant