Skip to content

Watcher and initial load performance improvements #357

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

Merged
merged 5 commits into from
Mar 27, 2019
Merged

Conversation

code-asher
Copy link
Member

@code-asher code-asher commented Mar 27, 2019

  • Set low CPU priority on the watcher on Linux (the lowest possible, 19).
  • Batch stat calls.
  • Batch readdir calls.
  • Batch lstat calls.

I benchmarked using stat across 10k files, with the current batch settings it seems to result in around a 1.5-1.9 increase in speed when ran locally.

I'm not sure what the optimal batch size and timeout are, but I played around with how responsive the terminal felt and went with something that seemed reasonable. During load the terminal is much more responsive, but we might be able to further improve.

Edit: It looks like the remaining lag on the terminal during load is due to either the client parsing all the messages sent back to it from all the batched calls or the server stringifying all those messages (probably some of both). I suppose the only way to make it better is to somehow make JSON.parse and JSON.stringify asynchronous and low-priority for messages that don't need to be immediately responsive (maybe spawn a process or worker for those messages).

Edit 2: Moving all the parsing/stringifying to separate threads using processes/workers might be a good idea?

@code-asher code-asher requested a review from kylecarbs as a code owner March 27, 2019 18:51
@code-asher code-asher changed the title Watcher-related performance changes Watcher and initial load performance changes Mar 27, 2019
callbackify seems to always adds an error as the first argument. Opted
to just use the promise for this one.
@code-asher code-asher changed the title Watcher and initial load performance changes Watcher and initial load performance improvements Mar 27, 2019
@kylecarbs kylecarbs merged commit 259095e into master Mar 27, 2019
@kylecarbs kylecarbs deleted the perf/watcher branch March 27, 2019 22:04
code-asher added a commit that referenced this pull request Jun 19, 2019
* Set low CPU priority on watcher

Fixes #247.

* Batch stat and readdir calls

* Fix fs.exists

callbackify seems to always adds an error as the first argument. Opted
to just use the promise for this one.

* Batch lstat

* Add maximum time for flushing batches
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.

2 participants