-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 task execution when using gulp.watch with large tasks #285
Comments
Here is a better example that doesn't involve any plugins and is easy to reproduce:
Run
Modify
Terminate
Run
Modify style.css:
The execution time of the css task when triggered by the watcher has now increased from 19ms to 650ms, the only difference is that the watch task now contains a watcher for the images folder, running the task directly is still fast:
|
How large is the folder tree inside the images folder? |
The example above used 500 images at one level (images/1.png, images/2.png etc) and in my real world case there is 100 images split across 2 sub-folders:
|
@shama does gaze start globbing immediately or does it nextTick that process? It looks like starting a watch blocks the main thread |
Immediately but we could push it to nextTick if you think it would help. |
@shama The internals of watch should also be setImmediate/nextTick-ing to not block the event loop for extended periods of time - I'll take a look at the code and see if I can find some trouble points |
Benchmarks: shama/gaze#79 |
It looks like this will be yet another thing fixed in the next version of gaze. The current version does a lot of fs traversing where the next version avoids it whenever it can. See this comment: shama/gaze#79 (comment) |
Since this is a gaze issue I will close this. When @shama releases the next version of gaze, this problem will be fixed. |
[Edit: added a better example as a comment below]
I have a project with a lot of images, I have a gulp task (
images
) for processing these images that takes 9 seconds to copy the images to a new folder. I have a gulp task calledwatch
that listens for various changes throughout the project and triggers corresponding tasks:I run
gulp watch
and changeapp/file.php
, the tasktests
(triggered by the watcher) runs as expected and takes ~1 second to complete.I then update the
watch
task to include a watcher for the images directory that triggers theimages
task:Now I change
app/file.php
again and this time the tasktests
(triggered by the watcher) takes 10 seconds to run.If I run
gulp tests
it completes in 1 secondIf I run
gulp watch
with only a watcher for tests, when a change is detectedtests
completes in 1 secondIf I run
gulp watch
with a watcher for images, when a change is detectedtests
completes in 10 seconds.Any ideas would could be causing this? Bug? Intentional? PEBCAK?
(note: I have tried this with various different tasks in place of
tests
, the same behaviour happens if I run a task for compiling less, concatenating javascript etc)The exact gulpfile.js that has this behaviour is as follows:
Thanks!
The text was updated successfully, but these errors were encountered: