OpenSearch/buildSrc
Jay Modi 085d9c6e82
Reduce CPU usage of gradle run (#49055) (#49102)
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.
2019-11-14 13:05:47 -07:00
..
reaper Apply 2-space indent to all gradle scripts (#49071) 2019-11-14 11:01:23 +00:00
src Reduce CPU usage of gradle run (#49055) (#49102) 2019-11-14 13:05:47 -07:00
.gitignore Build: Add fake project to include buildSrc as normal project 2016-05-06 22:26:15 -07:00
build.gradle Apply 2-space indent to all gradle scripts (#49071) 2019-11-14 11:01:23 +00:00
settings.gradle Remove empty buildSrc subproject (#47415) 2019-10-01 16:34:31 -07:00
version.properties Upgrade to joda 2.10.4 (#47805) 2019-10-31 14:49:50 +01:00