HotswapProjects / HotswapAgent

Java unlimited redefinition of classes at runtime.
GNU General Public License v2.0
2.36k stars 493 forks source link

FileWatcher can skip file events #318

Open ninja- opened 5 years ago

ninja- commented 5 years ago

I recently found that the when unpacking a lot of files into the extra-classpath directory, FileWatcher can sometimes skip the events for random files completely, and only catch it randomly after 4-5 unpacks to extra-classpath directory...

My alternative for now is a signal handler that hotswaps all files existing in directory, without FileWatcher. But it would be great to get this fixed upstream as this would simplify the setup.

My first guess was the race due to need to subscribe to new subdirectories created? But it's probably not that, since after a second unpack they already exists and only files are changed..

skybber commented 5 years ago

What operating system are you using?

ninja- commented 5 years ago

Ubuntu 18.04, files are in a docker bind mount from host. Latest kernel. Java 12

skybber commented 5 years ago

There could be some bottlenecks in file event dispatching in HA.

  1. the first one is thread sleep in EventDispatcher (can be decreased):

https://github.com/HotswapProjects/HotswapAgent/blob/master/hotswap-agent-core/src/main/java/org/hotswap/agent/watch/nio/EventDispatcher.java#L136

  1. the second one is max capacity of event queue, could be inreased if you have >500 directories (packages) in your project:

https://github.com/HotswapProjects/HotswapAgent/blob/master/hotswap-agent-core/src/main/java/org/hotswap/agent/watch/nio/EventDispatcher.java#L94

  1. at last you can extend timeout in HotswapperPlugin :

https://github.com/HotswapProjects/HotswapAgent/blob/master/hotswap-agent-core/src/main/java/org/hotswap/agent/plugin/hotswapper/HotswapperPlugin.java#L94

There was a issue regarding sensitivity/responsivity of Java watcher, I don't know if it is still issue on Linux now.

https://github.com/HotswapProjects/HotswapAgent/issues/41

ninja- commented 5 years ago

None of these look to me like they can cause it...and sensitive is already to set to highest

skybber commented 5 years ago