Skip to content

fix: avoid microtask in flushSync #16394

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

Merged
merged 4 commits into from
Jul 16, 2025
Merged

Conversation

Rich-Harris
Copy link
Member

file this under 'things that don't matter at all in the real world but matter a great deal in benchmarks'

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Jul 16, 2025

🦋 Changeset detected

Latest commit: 282cd94

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Playground

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

@Rich-Harris
Copy link
Member Author

In case this seems unnecessary:

sbench_create_signals
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  370.47ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 385.32ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  160.90ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 173.83ms
sbench_create_0to1
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 5.50ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 5.54ms
sbench_create_1to1
  time: fastest is b (main)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 20.92ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 20.86ms
  gc_time: fastest is b (main)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 2.95ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 2.88ms
sbench_create_2to1
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 18.23ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 18.39ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 2.95ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 2.97ms
sbench_create_4to1
  time: fastest is b (main)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 16.94ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 16.82ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  2.91ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 2.99ms
sbench_create_1000to1
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 15.17ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 15.31ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  3.03ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 3.13ms
sbench_create_1to2
  time: fastest is b (main)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 10.14ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 10.13ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  0.75ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 0.78ms
sbench_create_1to4
  time: fastest is b (main)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 8.60ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 8.50ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼    0.55ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 0.63ms
sbench_create_1to8
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼   6.32ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 6.90ms
sbench_create_1to1000
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 8.21ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 8.28ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  0.63ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 0.68ms
kairo_avoidable_owned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼              496.03ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 1397.77ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼                    35.21ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 679.47ms
kairo_avoidable_unowned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼            595.58ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 1307.73ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼                    36.39ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 609.89ms
kairo_broad_owned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  476.75ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 509.22ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   1.93ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 17.15ms
kairo_broad_unowned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  473.87ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 508.22ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   1.93ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 17.46ms
kairo_deep_owned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼   205.71ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 228.45ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   1.69ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 16.43ms
kairo_deep_unowned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  949.68ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 980.03ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   2.03ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 17.07ms
kairo_diamond_owned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼         411.28ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 684.22ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   19.78ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 223.92ms
kairo_diamond_unowned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼        506.73ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 778.16ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   19.53ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 222.74ms
kairo_triangle_owned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼      126.25ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 167.67ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   3.43ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 31.46ms
kairo_triangle_unowned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼    245.34ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 288.21ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   3.39ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 32.83ms
kairo_mux_owned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  328.86ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 344.89ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼               2.62ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 9.41ms
kairo_mux_unowned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  486.95ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 507.78ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼               3.30ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 10.61ms
kairo_repeated_owned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼        78.36ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 123.92ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   2.94ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 34.61ms
kairo_repeated_unowned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼         75.80ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 122.41ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   3.34ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 32.98ms
kairo_unstable_owned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼      114.68ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 158.05ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   3.48ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 33.52ms
kairo_unstable_unowned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼      129.37ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 173.25ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼                   3.52ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 33.59ms
mol_bench_owned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  286.24ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 294.20ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼                  1.03ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 6.22ms
mol_bench_unowned
  time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼  304.55ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 312.96ms
  gc_time: fastest is a (avoid-microtask-in-flushsync)
    a: ◼◼◼                  0.85ms
    b: ◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼ 6.57ms

Copy link
Contributor

Choose a reason for hiding this comment

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

craziness

@Rich-Harris Rich-Harris merged commit 4947283 into main Jul 16, 2025
15 checks passed
@Rich-Harris Rich-Harris deleted the avoid-microtask-in-flushsync branch July 16, 2025 16:08
@github-actions github-actions bot mentioned this pull request Jul 16, 2025
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy