RFR [14]: 8232207: Linux os::available_memory re-reads cgroup configuration on every invocation

Severin Gehwolf sgehwolf at redhat.com
Tue Oct 15 14:33:51 UTC 2019

Hi Claes,

On Tue, 2019-10-15 at 11:12 +0200, Claes Redestad wrote:
> Hi,
> on a Linux system with container support, os::available_memory will read
> cgroup configuration files from /proc to determine max memory limits.
> This leads to measurable memory overheads in some places, e.g., JIT
> compiler threads will poll os::available_memory between compilation to
> determine if we need to reduce the number of compiler threads.
> Overhead from polling these /proc files can take up to 5% of total CPU
> resource usage during startup and warmup.

Would there be a way to reproduce this myself? What did you use to
measure this? It would come in handy for the cgroups v2 work I'm doing.

How does this compare to -XX:-UseContainerSupport runs?

Aside: It seems we'd need similar work for
OSContainer::active_processor_count(). Or rather, cpu_quota(),
cpu_period() and cpu_shares() functions. See:


I'll give using a similar approach for active_processor_count() a shot.


> This patch caches the max memory limit and adds a very short (20ms) 
> grace time re-reading it from cgroup config files. This is enough to
> reduce the overhead to be more or less undetectable on my system, while
> not significantly reducing responsiveness to configuration changes.
> Bug:    https://bugs.openjdk.java.net/browse/JDK-8232207
> Webrev: http://cr.openjdk.java.net/~redestad/8232207/open.00/
> Testing: tier1-3 (with a 1s grace time, rerunning a sanity test with
> 20ms)
> Thanks!
> /Claes

More information about the hotspot-runtime-dev mailing list