Skip to content

perf: apply gitignores on the threads reading directories when globbing - #1474

Merged
dsherret merged 1 commit into
mainfrom
perf-glob-gitignore
Nov 29, 2026
Merged

dsherret merged 1 commit into
mainfrom
perf-glob-gitignore

Conversation

@dsherret

@dsherret dsherret commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

When globbing, the threads reading directories already match the entries against the patterns, but resolving each directory's gitignore and checking the entries against it was left to the single thread consuming what they read. That's most of what that thread does, and in repositories with gitignores it's what limits how fast globbing is, so adding reader threads didn't help.

This makes GitIgnoreTree usable from several threads (its cache is behind a lock and what's resolved is in an Arc) and has the reader threads resolve and apply the gitignore of the directory they read. A directory is only pushed to be read after its parent's entries were processed, so its parent's gitignore is already resolved when it's needed. The gitignore is still only resolved for a directory with entries that need it.

Globbing vite, storybook and rolldown together (24,085 files, with their gitignores) on Windows:

Before After
80 ms 63 ms

Before this, the consuming thread was busy for 48 ms of the 80 ms. The default of 8 reader threads is still the fastest after this.

@dsherret
dsherret added this pull request to stack #1477 November 28, 2026 15:09
@dsherret
dsherret merged commit 373f3e4 into main Nov 29, 2026
6 checks passed
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