~/container/cpu-shares$ bash cpu-shares-bug.sh Note: JavaStress.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Sending build context to Docker daemon 46.08kB Step 1/4 : FROM docker.io/library/openjdk:17-jdk-slim ---> 2a9873d16f48 Step 2/4 : COPY stress /bin ---> Using cache ---> 4fff027afda4 Step 3/4 : COPY JavaStress*.class / ---> 16807a6cb508 Step 4/4 : CMD ["bash"] ---> Running in c0fc5ac68617 Removing intermediate container c0fc5ac68617 ---> 58146bd9c232 Successfully built 58146bd9c232 Successfully tagged my-openjdk17-image:latest This machine has 32 cpus #---------------------------------------------------------------------- # (1) See how much CPU we can get from the stress command with two # containers, each with --cpu-shares=100 # baseline: run a single container without --cpu-shares stress: info: [8] dispatching hogs: 32 cpu, 0 io, 0 vm, 0 hdd stress: info: [8] successful run completed in 10s real 0m10.005s user 5m17.440s sys 0m0.077s ---------------------------------------- + cat stress.1.log stress: info: [8] dispatching hogs: 32 cpu, 0 io, 0 vm, 0 hdd stress: info: [8] successful run completed in 10s real 0m10.005s user 2m0.906s sys 0m0.019s ---------------------------------------- + cat stress.2.log stress: info: [8] dispatching hogs: 32 cpu, 0 io, 0 vm, 0 hdd stress: info: [8] successful run completed in 10s real 0m10.008s user 3m19.141s sys 0m0.057s #---------------------------------------------------------------------- # (2) See how much CPU we can get from with the JavaStress program with two # containers, each with --cpu-shares=100 # baseline: run a single container without --cpu-shares Runtime.getRuntime().availableProcessors() = 32 ForkJoinPool.commonPool().getParallelism() = 31 Elapsed = 10001 ms, counter = 280710 real 0m10.257s user 5m7.419s sys 0m3.891s ---------------------------------------- + cat JavaStress.1.log Runtime.getRuntime().availableProcessors() = 1 ForkJoinPool.commonPool().getParallelism() = 1 Elapsed = 10000 ms, counter = 29208 real 0m10.154s user 0m22.193s sys 0m0.501s ---------------------------------------- + cat JavaStress.2.log Runtime.getRuntime().availableProcessors() = 1 ForkJoinPool.commonPool().getParallelism() = 1 Elapsed = 10000 ms, counter = 32792 real 0m10.150s user 0m22.438s sys 0m0.340s