RFR: 8227006 - [linux] Runtime.availableProcessors execution time increased by factor of 100
bob.vandette at oracle.com
Wed Oct 30 18:35:16 UTC 2019
Summary: The container support added to Linux caused the call to os::active_processor_count to
become much more expensive than prior to the container addition. This RFR adds a cache to avoid
the extra overhead on repetitive calls to Runtime.getRuntime().availableProcessors(). The cache
timeout is set at 20ms. This allows the docker update command to alter the number of available processors
which will be reflected in the return from the API.
Adding a single cache of active_processor_count with a 20ms timeout results in the following improvements.
DISABLE CONTAINER SUPPORT (-XX:-UseContainerSupport)
20MS TIMEOUT CACHE
So the cache actually improves performance beyond the pre-container support by 8x but
this of course only helps programs that call this function in a loop.
More information about the hotspot-runtime-dev