Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
The RunTask is responsible for logging output from nodes to the console and also stays active since we want the cluster to keep running. However, the implementation of the logging and waiting resulted in a spin loop that continually polls for data to have been written to one of the nodes' output files. On my laptop, this causes an idle invocation of `gradle run` to consume an entire core. The JDK provides a method to be notified of changes to files through the use of a WatchService. While a WatchService based implementation for logging and waiting works, a delay of up to ten seconds is encountered when running on macOS. This is due to the lack of a native WatchService implementation that uses kqueue or FSEvents; the current WatchService implementation in the JDK uses polling with a default interval of ten seconds. While the interval can be changed programmatically it is not an acceptable solution due to the need to access the com.sun.nio.file.SensitivityWatchEventModifier enum, which is in an internal package. The change in this commit instead introduces a check to see if any data was available to read and log. If no data is available in any of the node output files, the thread sleeps for 100ms. This is enough time to prevent consuming large amounts of cpu while still providing output to the console in a timely fashion.
- Loading branch information