RFR: 8227006 - [linux] Runtime.availableProcessors execution time increased by factor of 100

Bob Vandette 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.

BUG: https://bugs.openjdk.java.net/browse/JDK-8227006
WEBREV:  http://cr.openjdk.java.net/~bobv/8227006/webrev.01

Adding a single cache of active_processor_count with a 20ms timeout results in the following improvements. 


39346 calls/sec 
40007 calls/sec 
39708 calls/sec 
39732 calls/sec 
39736 calls/sec 
39629 calls/sec 


1106795 calls/sec 
1135589 calls/sec 
1123782 calls/sec 
1123605 calls/sec 
1123343 calls/sec 
1123135 calls/sec 


9867172 calls/sec 
10077977 calls/sec 
9989674 calls/sec 
9983963 calls/sec 
9984400 calls/sec 
9985898 calls/sec 
9985123 calls/sec 
9985608 calls/sec 

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 mailing list