-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Very slow startup time #3743
Comments
If you can improve performance and keep maintenance overhead to a minimum, go for it. We do use Generally, I'm opposed to handrolling solution like this, since we've been (and continue to be) bitten by oversimplified solutions to complex fs-related problems. If you can find a suitable module in the ecosystem which is more performant for our use case, please prefer that. Keep in mind that we may want to do per-directory config files in the future... and Mocha also runs in the browser, so whatever you do should be isolated in such a way that the browser doesn't choke on it. |
@boneskull thanks, I'll see what I can find. findup-sync is used in 2 places: (ignoring tests, where it can remain as a devDependency) a) discovering the location of a .mocharc file For (a), you look for a hard-coded list of non-glob filenames. For (b), are globs indended to be supported, or is that merely a coincidence? In other words, if I find an alternative module that does not support globs, is that a blocker? There is no documentation for the Documentation for the --package option does not mention globs: https://mochajs.org/#custom-locations |
I'm investigating cosmiconfig as an alternative. It handles all the situations mocha cares about: discovering a config file, using different loaders based on file extension, and pulling the I filed a few issues to support mocha's use-case: |
see #3830 |
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend avoiding the use of globally installed Mocha.Description
mocha's CLI startup time is very slow. findup-sync appears to be a culprit, coupled with the fact that mocha loads findup-sync twice since it spawns a child-process.
node -e "require('findup-sync')"
is taking at least half a second on my Windows box. Windows suffers from higher per-file FS overhead, but I think this is still way too slow, considering that findup is barely doing anything.findup-sync indirectly loads fast-glob, micromatch, and nanomatch, which internally do some sort of initialization of compilers and parsers for their glob pattern handling. I think these compilers are meant to be super-fast, but ironically all the extra complexity means they initialize pretty slowly. mrmlnc/fast-glob#92
Would you accept a PR that replaces mocha's usage of findup with a faster
while()
loop?Are there specific globbing behaviors you want to preserve? I see that findup-sync is used for .mochrc discovery and package-file discovery. The former definitely doesn't need glob support; I'm unsure about the latter.
Steps to Reproduce
I've been adding
console.time()
andconsole.timeEnd()
statements to mocha's code to track down whichrequire()
calls are the slowest.Versions
mocha v6.0.0-1
node v11.3.0
Additional Information
The text was updated successfully, but these errors were encountered: