-
Notifications
You must be signed in to change notification settings - Fork 131
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
Globbing the whole workspace could be faster #1182
Comments
Thanks for the detailed report @Blugatroff! We had a similar report in #1140, but that's unfortunately very light on details which made it hard to investigate. Indeed 3.5s is a long time and I'd like it to be shorter, and think that it's possible to shorten it - according to your logs the globbing is 500ms, and reading the lockfile is 800. The first one is not too surprising but the latter is! |
I believe a recursive walk using just |
Yes @f-f , https://github.com/Blugatroff/pure-advent/ Could the globbing specifically also take long because there are a lots of deeply nested directories in my project directory which get searched unnecessarily? I'm talking about stuff like |
That was the general conclusion I reached in #1140, but there wasn't a reproducible repo to confirm that. |
Maybe we can speed it up with something like |
@Blugatroff I had a look at your However, in an effort to dogfood ourselves a repo with a large amount of files, in #1197 I am adding a large number of text fixtures - this makes it easier to write tests, but it also adds a good number of directories to traverse for spago. 400ms should be large enough to serve as a benchmark for further patches. The slow bit of code is here: Lines 177 to 187 in 455d94a
There are two possible sources for the slowdown here:
And we have a good trail we could follow:
|
I have investigated this a bit further, i tried the code snippet you linked and it is indeed much faster. While doing this, i also figured out which of my directories is responsible for most of the slowdown. It's my So ignoring gitignored directories before/while globbing instead of filtering afterwards is a huge improvement. |
I have merged the PR linked above, and parsing times have improved for Spago itself as well - it now takes 150ms to glob the workspace (vs 400ms before the patch). I have released the patch in a new version (0.93.29), could you try this out @wclr? We could still squeeze out some more performance out of this - the ideal would be to just drop |
Addresses purescript#1182 This implementation is using `micromatch` (a dependency of fast-glob) and `fs.walk` to traverse the file system itself, instead of relying on fast-glob. As opposed to the previous implementation (from purescript#1209) This implementation takes every .gitignore file into account, not just the root one. The callbacks `entryFilter` and `deepFilter` are used to control which directories to recurse into. When `entryFilter` encounters a .gitignore file, it's patterns are parsed into micromatch compatible ones and every subsequent call to these filter functions respect them. I'm not sure whether this should have been (partially) implemented in the registry-dev repo since that's where the FFI for fast-glob is located. I also did not remove the fast-glob npm dependency, since i'm not sure if it is still in use elsewhere and because the registry-dev dependency definitely still contains the foreign functions relying on it being available.
I think the first step here is to figure put - likely with a small test - if the issue here occurs only on windows, since performance on mac and linux has improved significantly and spago is not looking at those files there. |
spago build
takes surprisingly long to read it's configuration files.When using my somewhat older laptop i noticed, that an invocation of
spago build
on my smallish AdventOfCode project took 3.5 seconds, even though everything had already been compiled.I tried investigating what took so long by inserting
logDebug
and using the--verbose
flag.I noticed that running
purs
isn't actually the single most expensive step (took 800ms), instead globbing the workspace for everyspago.yaml
and parsingspago.lock
takes quite long.I usually expect a package manager to finish very quickly when there is no actual work to be done, even on slightly older hardware.
The old spago just takes 1.5s on the same project and device, so is this just the cost of writing spago in a language that compiles to javascript, or can we reduce this startup time? Or perhaps some of these steps can be skipped in certain cases?
How I measured:
time node ~/clones/spago/bin/bundle.js build --verbose
shows:The text was updated successfully, but these errors were encountered: