adoptium / containers

Repo containing the dockerfiles and scripts to produce the official eclipse-temurin containers.
https://hub.docker.com/_/eclipse-temurin/
Apache License 2.0
206 stars 91 forks source link

Increase JVM memory percentage #433

Closed tariqajyusuf closed 9 months ago

tariqajyusuf commented 9 months ago

The JVM by default uses only 25% of the system memory. In a container environment we should have this larger so that the system doesn't necessarily go through memory thrash despite most of the allocated memory still being available.

karianna commented 9 months ago

This is a per user/per application setting that you'll need to add but we can't add this for everyone.

tariqajyusuf commented 9 months ago

Can you elaborate more on what you mean by having this a per-container setting? Most JDK containers are running a single Java application. By default the JVM will only use 25% of the available memory. If the entire container is for a JVM, creating a 1GB container means that the JVM will not use more than 256MB. It doesn’t make a lot of sense for every JDK image user to have default 25% max utilization of their image.

karianna commented 9 months ago

https://learn.microsoft.com/en-us/azure/developer/java/containers/kubernetes?source=recommendations for reference - the JVM ergonomics are dynamic and should ideally be set by the user for their workload.

tariqajyusuf commented 9 months ago

Got it, it feels like this should be a default change instead of requiring two different configurations that are often going to be the same.

With this practice, it may be worth considering including documentation in adaptium's docker README. I tested a number of well used JVM based images that don't set this so I suspect this is a setting that a lot of people are not aware of.

karianna commented 9 months ago

separately Microsoft is working on improving ergonomics profiles for containers - see https://github.com/microsoft/openjdk-proposals/blob/main/ergonomics_profiles/readme.md