Skip to content
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

Slow config file search in projects with many directories #289

Open
marvinhagemeister opened this issue Jan 18, 2023 · 2 comments
Open

Slow config file search in projects with many directories #289

marvinhagemeister opened this issue Jan 18, 2023 · 2 comments

Comments

@marvinhagemeister
Copy link

I'm currently profiling various linting setups of the project's I have access to and noticed that a noticeable chunk is spent on trying to resolve config files for prettier. Prettier in turn uses cosmiconfig to find the config file. Searching for the config files gets seemingly slower the more folders a project has. In my case it consumes about 5% (~9s) of the total linting time for searching for config files. This is a project with a lot of folders.

I went ahead and logged patched cosmiconfig locally to log out every file it tries to read to count them. It looks like it's trying every directory for config files and ultimately this ends up in 14k file system calls during the linting task. The thing is that the project only has one config for prettier and that is located at the project root. No further prettier configurations exist. Therefore those 14k file system calls could be avoided and are in vain.

Screenshot 2023-01-18 at 11 21 11

@d-fischer
Copy link
Member

The normal behavior should be that if you run the prettier CLI from the project root folder (which should always be the case if you run it via npx or package scripts), it shouldn't look in more places than a few different file names in that folder.

Can you paste that list somewhere (probably external)? Redact parts of the folder names if you want, but try not to remove complete lines or make them completely unreadable.

Also, can you give me the following things:

  • The exact node version you're using to run prettier
  • The exact version of prettier you're running
  • Your OS with version (if Windows, maybe even the exact build shown by winver)

@jrandolf
Copy link
Collaborator

jrandolf commented Sep 2, 2023

This can probably be fixed with some statefulness on cosmiconfigs side using a filesystem cache. Certainly would welcome a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants