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

Switch to chokidar #13

Closed
wants to merge 3 commits into from
Closed

Switch to chokidar #13

wants to merge 3 commits into from

Conversation

es128
Copy link

@es128 es128 commented Jan 22, 2015

  • io.js compatibility (update/correction: gaze 0.5.1 is compatible with io.js also, but 0.6.* isn't)
  • not as buggy

This is aimed at establishing parity with prior behavior using gaze, except for swapping out old for stats 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.

@paulmillr
Copy link

@contra in fact, Gaze has 30+ issues while we have two.

@TrySound
Copy link

Woohoo!

@heikki
Copy link

heikki commented Jan 22, 2015

Some (10) chokidar tests fail on windows. Also a little tweak was necessary to run tests:
"test": "istanbul test node_modules/mocha/bin/_mocha"

@es128
Copy link
Author

es128 commented Jan 22, 2015

@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.

@heikki
Copy link

heikki commented Jan 22, 2015

@es128 Tests pass now 🎉

For some reason npm test fix paulmillr/chokidar@48387fb doesn't work for me.
This path works: node_modules/mocha/bin/_mocha.

@es128
Copy link
Author

es128 commented Jan 22, 2015

grr... it's really istanbul's fault

w/e I'll change it

es128 added a commit to paulmillr/chokidar that referenced this pull request Jan 22, 2015
@heikki
Copy link

heikki commented Jan 22, 2015

Btw, there's appveyor if you want to try automating windows tests. For example liftoff and gulp-cli use it.

out.emit('change', outEvt);
if(cb) cb(outEvt);
});
if(opts.ignoreInitial === undefined) opts.ignoreInitial = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats this new option?

Copy link
Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (opts.ignoreInitial == null)

@yocontra
Copy link
Member

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

@es128
Copy link
Author

es128 commented Jan 22, 2015

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.

@yocontra
Copy link
Member

Still need to see some benchmarks before switching

@phated @sindresorhus any thoughts?

@sindresorhus
Copy link

Probably yes, after seeing benchmarks.

@xzyfer
Copy link

xzyfer commented Jan 22, 2015

FWIW the navelgazer has some benchmarks.

Library versions aren't mentioned. YMMV.

@paulmillr
Copy link

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 setTimeout ... 50 throttling for change events to make everything work perfectly. It says chokidar takes 51ms. Make your judgement. How about benchmarking stability?

@yocontra
Copy link
Member

@paulmillr Why do you need to throttle events at 50ms to make things work? Seems like a bandaid for a race condition somewhere

@es128
Copy link
Author

es128 commented Jan 23, 2015

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.

@es128
Copy link
Author

es128 commented Jan 23, 2015

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.

@yocontra
Copy link
Member

@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

@heikki
Copy link

heikki commented Jan 23, 2015

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
-------------------------------------------------------

@es128
Copy link
Author

es128 commented Jan 23, 2015

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 fs.watch by default and may not fare as well - anecdotally I'll assert that it's good enough for anyone's real-life use-cases though.

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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-6.25%) to 93.75% when pulling fca10f2 on es128:chokidar into 103840f on wearefractal:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-6.25%) to 93.75% when pulling fca10f2 on es128:chokidar into 103840f on wearefractal:master.

@es128
Copy link
Author

es128 commented Apr 7, 2015

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

  1. adding tests that add a new file, delete a watched file, and add or remove a dir; or
  2. removing the mapping and pass through event details like before, but that would be a breaking change because then chokidar's event names are different from gaze's

@phated
Copy link
Member

phated commented Apr 8, 2015

This is going to end up in gulp4 so we can make breaking changes.

@es128
Copy link
Author

es128 commented Apr 8, 2015

So are you saying you'd like me to adopt chokidar's event names and follow option 2?

@phated
Copy link
Member

phated commented Apr 8, 2015

I'd say yes because it keeps the code small, but you should wait for @contra to chime in.

@yocontra
Copy link
Member

yocontra commented Apr 8, 2015

Traveling right now, will look at this when I get a minute

@coveralls
Copy link

Coverage Status

Coverage decreased (-6.12%) to 93.88% when pulling a107487 on es128:chokidar into 103840f on wearefractal:master.

@es128
Copy link
Author

es128 commented Apr 8, 2015

Sorry about the coveralls spam. Realized I hadn't done the return statement in the end method to keep it consistent with before: https://github.com/wearefractal/glob-watcher/pull/13/files#diff-168726dbe96b3ce427e7fedce31bb0bcR77

However, an argument could be made that all the methods should actually be returning out to make glob-watcher's API properly chainable.

out.emit('change', outEvt);
if(cb) cb();
});
function mapEvents(evt) {
Copy link
Member

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',
  ...
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yocontra
Copy link
Member

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

@phated
Copy link
Member

phated commented Aug 18, 2015

I think we should remove glob-watcher, as we don't need another abstraction on chokidar (it watches globs now)

@phated
Copy link
Member

phated commented Aug 18, 2015

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)

@paulmillr
Copy link

👍

@es128
Copy link
Author

es128 commented Aug 18, 2015

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 watcher instance instead of glob-watcher's own EventEmitter instance (under the identifier out in the code), which could lead to some odd unexpected behavior if anyone were to try to chain methods.

@yocontra
Copy link
Member

@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 🌴

@es128
Copy link
Author

es128 commented Aug 18, 2015

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 gulp.watch would look like.

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 gulp.watch.

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.

@yocontra
Copy link
Member

@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.

@phated
Copy link
Member

phated commented Aug 18, 2015

Ref gulpjs/vinyl-fs#86

@phated
Copy link
Member

phated commented Oct 20, 2015

Closing since we are using chokidar directly in gulp 4

@phated phated closed this Oct 20, 2015
calleddave0p4 added a commit to calleddave0p4/chokidar that referenced this pull request Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants