-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Switch to chokidar #13
Conversation
@contra in fact, Gaze has 30+ issues while we have two. |
Woohoo! |
Some (10) chokidar tests fail on windows. Also a little tweak was necessary to run tests: |
@heikki Thanks for pointing that out, forgot to run the windows tests recently. Fixed in paulmillr/chokidar@ecace6c. It was really just the one relative paths test failing and throwing off the fixture cleanup, messing up the rest of the tests. |
@es128 Tests pass now 🎉 For some reason |
grr... it's really istanbul's fault w/e I'll change it |
out.emit('change', outEvt); | ||
if(cb) cb(outEvt); | ||
}); | ||
if(opts.ignoreInitial === undefined) opts.ignoreInitial = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats this new option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without it, add
events are emitted upon instantiation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (opts.ignoreInitial == null)
Lots of minor style things, some probably not your fault (this repo is old, old style guidelines). I would check out the vinyl-fs repo for what our current style looks like |
Yeah thanks for the review. I was matching existing style, so perhaps all that should be done as a separate PR since it impacts more than just my changes? If I do it all here, it will become hard to tell which part of the diff is relevant to switching to chokidar. |
Still need to see some benchmarks before switching @phated @sindresorhus any thoughts? |
Probably yes, after seeing benchmarks. |
FWIW the navelgazer has some benchmarks. Library versions aren't mentioned. YMMV. |
I've updated the chokidar to the 1.0.0-rc2 in this benchmark locally and tested it. @xzyfer It's a synthetic piece of shit. We do |
@paulmillr Why do you need to throttle events at 50ms to make things work? Seems like a bandaid for a race condition somewhere |
The throttle doesn't delay the change event, it suppresses duplicates. There is a delay on unlinks so that if the file comes back quickly the whole transaction gets emitted as a change. The navelgazer benchmark does not show results for current versions of gaze, so even if accurate it isn't a fair comparison. I don't expect chokidar to react to anything in the sub-ms range. The priority has been stability and consistency, and perf is likely to vary widely between platforms. All the underlying watch methods are liars, so there are many cases where the true state of things needs to be double-checked by getting a stat or readdir before emitting. I'll see what I can do about adapting gaze's benchmark scripts so we can get a reasonable idea of how they actually compare. |
Yes, there are race condition-y things that happen at the file system level that have to be corrected for. Especially when it comes to all the text editors that use atomic write methods. |
@es128 Yeah, I think creating an accurate benchmark would be handy and then we can run it on all platforms to see if there are any irregularities that have to be fixed |
Results change big time when testing separately: ∴ navelgazer git:(master) node benchmarks/change.js
Benchmarking single change on darwin-x64-v8-3.14...
-------------------------------------------------------
chokidar@1.0.0-rc2: 1.82ms
-------------------------------------------------------
∴ navelgazer git:(master) node benchmarks/change.js
Benchmarking single change on darwin-x64-v8-3.14...
-------------------------------------------------------
navelgazer@1.0.0: 1.55ms
-------------------------------------------------------
∴ navelgazer git:(master) node benchmarks/change.js
Benchmarking single change on darwin-x64-v8-3.14...
-------------------------------------------------------
fs.watch@v0.10.35: 2.25ms
-------------------------------------------------------
∴ navelgazer git:(master) node benchmarks/change.js
Benchmarking single change on darwin-x64-v8-3.14...
-------------------------------------------------------
watch@0.11.0: 4,005.98ms
-------------------------------------------------------
∴ navelgazer git:(master) node benchmarks/change.js
Benchmarking single change on darwin-x64-v8-3.14...
-------------------------------------------------------
pathwatcher@2.1.3: 2.49ms
------------------------------------------------------- |
Well I'll say preemptively that OS X, with the fsevents API, is likely to turn out pretty solid, but linux and windows are backed by I don't expect there is any potential for dramatic gains without reintroducing problems or adopting new underlying watch methods. Which is what brings us back around to why @shama has taken the approach he has with navelgazer, which sounds like will be pretty awesome if he can stabilize its problems. In the meantime, weighing performance and stability, I believe chokidar is the best option. I think I've more or less proven the stability side already, will work on putting some legit numbers to the perf side. |
1 similar comment
The coverage issue has to do with the backward-compatible event mapping (meaning events aren't just passed through like before). Coverage could be increased by either
|
This is going to end up in gulp4 so we can make breaking changes. |
So are you saying you'd like me to adopt chokidar's event names and follow option 2? |
I'd say yes because it keeps the code small, but you should wait for @contra to chime in. |
Traveling right now, will look at this when I get a minute |
Sorry about the coveralls spam. Realized I hadn't done the return statement in the However, an argument could be made that all the methods should actually be returning |
out.emit('change', outEvt); | ||
if(cb) cb(); | ||
}); | ||
function mapEvents(evt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be much better as an object
eventMap = {
add: 'added',
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments on the code. code needs cleanup and some comments so it is clear, new options need documentation. good to switch to chokidar after that is done |
I think we should remove glob-watcher, as we don't need another abstraction on chokidar (it watches globs now) |
vinyl-fs could just include chokidar as watch (or remove it all together... we should open an issue about that on vinyl-fs to discuss) |
👍 |
Updated the PR per @contra's feedback in case you do want to continue to use glob-watcher as-is without any breaking API changes. If the decision is to make more structural changes of the sort @phated is getting at, I could get behind that notion too. One particular inconsistency with glob-watcher's current API is that method calls return the underlying |
@es128 I'm down to break some stuff, this will land in gulp 4 anyways which already has breaks. Feel free to change whatever you want, and make a list of all of the changes + flag the breaking ones and I'll review it 🌴 |
Cool, and I'm happy to help this along, but would like to better understand your thoughts on what an ideal greenfield implementation of chokidar for You might be referring to small breaking changes like my note about the return values from the methods here. Or we could switch to using chokidar's event names directly without mapping. Or it might make sense to set glob-watcher aside and just implement chokidar directly in gulp or vinyl-fs for use with I don't have enough expertise with gulp to have strong opinions on many of these matters. Please let me know how you think we should proceed. |
@es128 Shelving glob-watcher and just doing it in vinyl-fs is fine for me. Also, no event mapping and returning for chaining seems fine too. |
Closing since we are using chokidar directly in gulp 4 |
This is aimed at establishing parity with prior behavior using gaze, except for swapping out
old
forstats
as the extra argument coming from the watcher's events.Switching to chokidar's regular event names (sooner or later) would be fine too if it wouldn't be too disruptive for downstream users of this module to adjust.
Please evaluate and let me know if there's any issue or concern. If not, I can release chokidar 1.0.0 before you push this out.