Search code examples
performancedockerbenchmarking

Docker doesn't get 100% of the CPU


We just wrote a CPU intensive application to benchmark Docker images. It's a Java application that approximates the decimals of Pi.

  • If we run java -jar superpi.jar it stresses all the cores and takes 30 seconds
  • If we run docker run fewlaps/superpi it stresses only two of the four cores and takes 70 seconds

The Docker image is running the .jar as we do when running it on the host. Why is the Docker image not as fast as running the .jar locally? We expected some difference between running it locally and running it on Docker, but the process takes double the time.

Is there any way to request that Docker use all the CPU?

BTW, the project is published here on GitHub: Fewlaps/SuperPI


Solution

  • Friends, I'm full of shame: the own MacOS Docker desktop client has a setting to enable more or less cores. Don't know if it's something added in the last version, but I didn't notice. By default, it gets two cores instead of four, which seems savvy.

    Here's how the screen appears:

    enter image description here

    By the way, only for the information, on the same machine:

    • Running the .jar takes 64,973 millis
    • Running the Docker image that runs the .jar takes 83,449 millis