-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
watchers: use singleton server #8546
Conversation
This is a draft pull-request, I'd like to know if this change cause trouble to any party. This is an optimization that should help us at Ericsson handle very large workspaces when users open multiple windows. The changes should be fully functional, only the API would require some cleaning: |
@akosyakov I originally wanted to get a unique identifier for a given frontend connecting to the backend in the Is there a way using inversify to generate one when handling an incoming frontend connection, and pass that around? When I tried I couldn't get anything to be injected correctly. |
I won't have time for reviews in this and next months please proceed. File watching we should ensure that clients only get events which they ask for. If this PR improves performance and does not break it then it is fine. For performance optimisations PR should provide a reproducible method to collect some numbers before and after. A reviewer should run this method too and decide whether code change is worth improvements. |
@akosyakov got it, thanks for your feedback! I'll provide a way to benchmark tomorrow (although one can already get a feel just enabling the |
bb748c4
to
31077c4
Compare
Added more things to test. |
Please add tests to check that opening 2 tabs with different folders ensures that each tab does not receive events about workspace of another tab. |
adda895
to
0ffc370
Compare
@akosyakov thanks to this simple request, it made me notice a bug where events weren't correctly forwarded when running the server in a child process. This is now fixed and I added more things to test in the PR description. |
a337b48
to
6e6dc4b
Compare
This PR is good for review now. |
6e6dc4b
to
7dcd8f4
Compare
72f30d0
to
3f4a514
Compare
@kittaakos thanks for your comments! I think I addressed everything :) |
99e9455
to
338a25a
Compare
Very nice. Thanks for the heads-up, @marechal-p. I will give it a try on Windows this week. |
103f300
to
d686e00
Compare
d686e00
to
4e84964
Compare
I rebased to resolve the conflict. cc @kittaakos |
Thanks for the heads-up, @marechal-p. I tried it last week: it worked for me although I did not fully understand the verbose file-watcher logs. Please someone else also take a look into the changeset. Thanks! |
4e84964
to
b190927
Compare
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.
The changes work very well for me and it is definitely an overall improvement to the file watchers 👍
I verified the source code (offline review), as well as tested as many use-cases and scenarios I could think of to validate the functionality.
Theia spawns as many nsfw servers as there are clients, maybe more. This commit replaces this behaviour by centralizing everything into the same service process in order to optimize resources (watch handles are a limited resource on a given Linux host). Some notes on the current design: - Everytime someone requests to watch an `(uri, options)` couple we will re-use the same watch handle (and actual nsfw instance). This allows for resource allocation optimizations. - Since a given service can only serve a single client, I added an event dispatcher named `FileSystemWatcherServiceDispatcher`. You must register yourself with some unique id you will use to make requests. - The new `.watchUriChanges` function now takes a `clientId` so that when events are sent to the dispatcher it then gets routed back to your own client. - Added a `--nsfw-watcher-verbose` backend argument to enable verbose logging for the watcher server. Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
b190927
to
495f303
Compare
Theia spawns as many nsfw servers as there are clients, maybe more.
This commit replaces this behaviour by centralizing everything into the
same service process in order to optimize resources (watch handles are a
limited resource on a given Linux host).
Some notes on the current design:
(uri, options)
couple we willre-use the same watch handle (and actual nsfw instance). This allows for
resource allocation optimizations.
dispatcher named
FileSystemWatcherServerDispatcher
. You must registeryourself with some unique id you will use to make requests.
.watchUriChanges
function now takes aclientId
so thatwhen events are sent to the dispatcher it then gets routed back to your
own client.
--nsfw-watcher-verbose
backend argument to enable verboselogging for the watcher server.
Signed-off-by: Paul Maréchal paul.marechal@ericsson.com
How to test
sample.file-watching.verbose
preference.yarn --cwd examples/browser start --nsfw-watcher-verbose
NEW
log notifications.REF++
log notificationsREF--
log notifications.lsof | grep inotify | wc -l
a couple of times before opening a frontend and note the general value.lsof | grep inotify | wc -l
each time.@theia/example-browser
app:Sample File Watching: X file(s) changed! <workspace>
Review checklist
Reminder for reviewers