Skip to content

perf: format large files first - #1490

Merged
dsherret merged 3 commits into
mainfrom
perf/large-files-first
Nov 30, 2026
Merged

dsherret merged 3 commits into
mainfrom
perf/large-files-first

Conversation

@dsherret

@dsherret dsherret commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Formatting could end with every thread waiting on a single one that started formatting a large file late. Files of at least 256KB are now formatted first.

On Windows, the size is in the directory listing. Elsewhere it takes a stat, which made globbing and checking files that are all in the incremental cache slower when done while globbing, so instead a thread does it from the end of the queue while the other threads are formatting, until there are no files left in the queue.

This is for files that get formatted in batches (ex. it does not apply to process plugins elsewhere than on Windows). Paths provided on the command line also have large files first, using the sizes from when finding out whether the path is a file.

dprint check with the tidy plugin on files from Vite, Storybook and Rolldown:

Before After
Windows, 21,073 files (one is 8.5MB) 427ms 346ms
Linux, same files 590ms 487ms
macOS, same files 966ms 961ms
Windows, only the 6,804 TypeScript files 141ms 141ms
Linux, only the 6,804 TypeScript files 223ms 222ms

@dsherret
dsherret added this pull request to stack #1492 November 30, 2026 16:05
@dsherret
dsherret merged commit e6d2b0c into main Nov 30, 2026
3 of 4 checks passed
@dsherret
dsherret deleted the perf/large-files-first branch November 30, 2026 16:06
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