Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker for mac performance tuning #61

Open
paolomainardi opened this issue Nov 21, 2022 · 4 comments
Open

Docker for mac performance tuning #61

paolomainardi opened this issue Nov 21, 2022 · 4 comments

Comments

@paolomainardi
Copy link
Member

paolomainardi commented Nov 21, 2022

Context

We all know that Docker performance on mac for some cases is quite limited in terms of filesystem performance, mainly caused by the shared network disk between the host and the docker for mac VM.

There is a long-standing issue you can find here: docker/roadmap#7

We as a company invested a lot in the past to reach close-native performance between Linux and macOS, in the docker-machine era we used NFS sharing which leads to very close native performance, then we decided to mainly use Linux for our developer workstations also to avoid this kind of performance issues.

With the Apple Silicon era, we decided to invest again in macOS for our developer workstations, as the machines are powerful, cheap and with the best-in-class hardware you can find on the market now.

The current Docker for Mac improved a lot the filesystem sharing issues, but it still falls behind the native performance, especially with heavy fs scenarios usage like Node and PHP with node_modules and vendor directories which can become very very big also in simple projects.

Benchmark

Repository: https://github.com/paolomainardi/docker-for-mac-bench

I am going to use create-react-app as a use case scenario, the test is executed:

  1. Empty node_modules
  2. NPM cache

Filesystem

Native

❯ time npm install

real 6.12s 

Doker for mac - gRPC Fuse (default)

❯ time npm install

real 56.835s

Docker for mac - Virtiofs (beta)

root@f546acf5bf5b:/usr/src/app# time npm install

real    18.864s

CPU

❯ make test-cpu
time node cpu-bench.js
        4.08 real         4.01 user         0.06 sys
docker run --rm -it -v $PWD:/usr/src/app -v $PWD/.cache:/root/.npm -w /usr/src/app node:18-slim bash -c "time node cpu-bench.js"

real    0m4.138s
user    0m4.104s
sys     0m0.024s

macOS 13

❯ make test-native test-docker-nomount test-docker-nodemodule-mount test-docker-mount
Testing: Native installation...

real 4.66

Testing: Docker without volume mount...

real	0m 7.23s

Testing: Docker with node_modules mounted as a named volume...

real	0m 6.97s

Testing: Docker with volume mount...

real	0m 17.15s
@paolomainardi
Copy link
Member Author

Ref: docker/for-mac#6590

@mgdesign mgdesign changed the title Drupal for mac performance tuning Docker for mac performance tuning Nov 22, 2022
@paolomainardi
Copy link
Member Author

@paolomainardi
Copy link
Member Author

Ref: docker/roadmap#7

@paolomainardi
Copy link
Member Author

Another test with:

  1. Ventura 13.1
  2. Docker Desktop 4.15.0
➜  bench-macos git:(main) make
Testing: Native installation...

real 4.02

Testing: Docker without volumes...

real	0m 6.56s

Testing: Docker with a bind mount: './create/react/app:/usr/src/app' and a volume on: 'nodemodules:/usr/src/app/node_modules'

real	0m 7.04s

Testing: Docker with a bind mount: ./create-react-app:/usr/src/app

real	0m 21.86s

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

No branches or pull requests

1 participant