Skip to content

Support cgroup v2 locations when reading CPU share and memory limit#113

Open
matmannion wants to merge 1 commit intofabric8io-images:masterfrom
matmannion:bugfix/cgroupv2
Open

Support cgroup v2 locations when reading CPU share and memory limit#113
matmannion wants to merge 1 commit intofabric8io-images:masterfrom
matmannion:bugfix/cgroupv2

Conversation

@matmannion
Copy link
Copy Markdown

If the docker daemon is running on a host that supports control group v2, run-java.sh does not correctly calculate CPU share or memory limits because it only looks in the v1 location. This fixes this by looking in the correct locations for control group v2.

For example, with current master:

$ docker run -e JAVA_MAX_MEM_RATIO=80 --memory=2g --cpu-quota 1000000 -it openjdk:8 /bin/bash
root@edec19b1d93e:/# curl -s https://raw.githubusercontent.com/fabric8io-images/run-java-sh/master/fish-pepper/run-java-sh/fp-files/run-java.sh -o /usr/local/bin/run-java.sh
root@edec19b1d93e:/# chmod +x /usr/local/bin/run-java.sh
root@edec19b1d93e:/# run-java.sh options
-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnOutOfMemoryError

vs with this change:

$ docker run -e JAVA_MAX_MEM_RATIO=80 --memory=2g --cpu-quota 1000000 -it openjdk:8 /bin/bash
root@39eca3625501:/# curl -s https://raw.githubusercontent.com/matmannion/run-java-sh/bugfix/cgroupv2/fish-pepper/run-java-sh/fp-files/run-java.sh -o /usr/local/bin/run-java.sh
root@39eca3625501:/# chmod +x /usr/local/bin/run-java.sh 
root@39eca3625501:/# run-java.sh options
-Xmx1638m -XX:ParallelGCThreads=10 -XX:ConcGCThreads=10 -Djava.util.concurrent.ForkJoinPool.common.parallelism=10 -XX:CICompilerCount=4 -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnOutOfMemoryError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant