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

Severin Gehwolf sgehwolf at redhat.com
Tue Oct 15 16:11:19 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.
> 
> 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/

This looks fine to me.

It's a reasonable compromise between caching and getting updates from
the container runtime. FWIW, this also helps the jshell case (as
detailed in JDK-8227006).

Crazy idea: Perhaps it'd be worth turning those 20ms into a JVM
parameter. Accept -1 for caching until the JVM restarts.

Note that from an OpenShift perspective, config changes == container
restart, ergo JVM restart. So there is no point in actually re-reading
the limits.

Just my $0.02

Thanks,
Severin

> 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