Skip to content

perf: handle files formatting didn't change on the runtime thread - #1472

Merged
dsherret merged 1 commit into
mainfrom
perf-format-pipeline
Nov 28, 2026
Merged

dsherret merged 1 commit into
mainfrom
perf-format-pipeline

Conversation

@dsherret

Copy link
Copy Markdown
Member

After formatting a file, run_parallelized sent the result to a blocking thread to call the command's callback, then waited for it to come back. For a file formatting didn't change, the callback only compares the text and maybe stores its hash for incremental formatting, so going to another thread and back costs more than the work. The runtime thread does this for every file, and with fast plugins it's the bottleneck, so it adds up.

This calls the callback on the runtime thread when the text is unchanged, which is the case for most files when checking or formatting a repo. Changed files still go to a blocking thread since the callback writes them or outputs a diff.

dprint check --incremental=false with @dprint/tidy on 32 threads (Windows), on 21,073 already formatted files from vite, storybook and rolldown (with #1471 applied for both):

Before After
525 ms 411 ms

@dsherret
dsherret merged commit 3c91533 into main Nov 28, 2026
6 checks passed
@dsherret
dsherret deleted the perf-format-pipeline branch November 28, 2026 03:51
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