chore: make effect scheduling more efficient #16346
Open
+7
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 itWe currently have some inefficiency around effect scheduling. Inside certain blocks, like
each
andawait
blocks, we update internal sources that populate the branches within. Updating these sources causes aschedule_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 toqueued_root_effects
, which in turn causes another turn of thewhile
loop inflush_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.