fury-old icon indicating copy to clipboard operation
fury-old copied to clipboard

filewatcher uses too many threads

Open propensive opened this issue 5 years ago • 2 comments

When watching Fury, waiting for changes, it creates 30 new threads in order to watch the various source directories. It feels like this ought to be a single thread.

propensive avatar May 01 '20 11:05 propensive

The example here which avoids using Better Files looks very simple. We can block the current thread. We could even wrap the events in a Stream.

propensive avatar May 03 '20 21:05 propensive

The threads named "FileSystemWatchService" are created by the OpenJDK implementation of file system poller. I don't think the directory-watcher library has any control over them.

Since Fury creates one directory watcher per source directory, we are bound to have 30 "FileSystemWatchService" threads for the full Fury build (fewer for partial builds, such as fury/core).

I guess it possible to create a single watcher for the whole directory tree (or just the smallest common parent of all the source directories) and filter out unrelated events, but this doesn't sound like a very good idea.

odisseus avatar May 25 '20 11:05 odisseus