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 Performance Slow Compared to Brew Installation #822

Open
2 of 5 tasks
nickzelei opened this issue Oct 1, 2024 · 5 comments
Open
2 of 5 tasks

Docker Performance Slow Compared to Brew Installation #822

nickzelei opened this issue Oct 1, 2024 · 5 comments

Comments

@nickzelei
Copy link

nickzelei commented Oct 1, 2024

Description

I'm trying to understand more about why running mockery seems to be so much slower than when run bare metal.

I read through the issue todo and cleaned out my go mod cache.

Mockery Version

v2.46.1

Go Version

go version go1.23.1 darwin/arm64

Installation Method

  • Binary Distribution
  • Docker
  • brew
  • go install
  • Other: [specify]

Steps to Reproduce

You can repro this in the neosync repo.

  1. go clean -modcache
  2. go mod download
  3. mockery ~ 3 seconds
  4. docker run -v "$PWD":/src -w /src vektra/mockery:v2.46.1 ~1 minute

I've even tried mounting only what is necessary via:

docker run \
  -v "$PWD/backend":/src/backend \
  -v "$PWD/worker":/src/worker \
  -v "$PWD/internal":/src/internal \
  -v "$PWD/.mockery.yml":/src/.mockery.yml \
  -v "$PWD/go.mod":/src/go.mod \
  -v "$PWD/go.sum":/src/go.sum \
  -v "${GOPATH:-$HOME/go}/pkg/mod":/go/pkg/mod \
  -w /src \
  vektra/mockery:v2.46.01

But the docker run still takes orders of magnitude longer than the bare metal.

Am I missing some form of cache that should be mounted into the docker container?

Expected Behavior

The docker run should be near the speed of the brew installed version.

Actual Behavior

Takes much longer.

@nickzelei nickzelei changed the title Docker Performance Slow Compared to Binary Docker Performance Slow Compared to Brew Installation Oct 1, 2024
@LandonTClipp
Copy link
Collaborator

This is going to require some benchmarking. In a case like this, I'd try a few things:

  1. Run mockery with strace -Tin both docker and non-docker contexts to see how long it spends in syscalls.
  2. Run mockery with --log-level=DEBUG to see if there's an obvious step where it spends too much time.

Does mockery run slow even after multiple iterations in docker (I wonder if this is a cache issue)? What version of docker are you running?

@rezikovka
Copy link

rezikovka commented Oct 27, 2024

Same problem.
Docker Desktop 4.34.3 (170107)
Apple M1 Max
In my project brew-installed mockery works in ~7 sec, but docker container takes several minutes

@LandonTClipp
Copy link
Collaborator

LandonTClipp commented Nov 7, 2024

Sadly, this might be somewhat expected. Docker on Macs must run inside of a VM, which is going to incur a noticeable performance penalty. This is what Docker Desktop does under the hood. Although, an order of magnitude is not exactly expected. This might be a factor of how the VM is configured. I cannot debug environment-specific issues like this so I will have to rely on others to identify where mockery is spending most of its time. I bet it is IO related.

@AdivonSlav
Copy link

For what it's worth, Docker performance on Linux is much slower as well than running the mockery binary directly for me.
Running Fedora Linux 41 with kernel version 6.11.7

Running a mockery Docker container with --log-level=DEBUG, it seems that it stops directly after DBG package cache is nil and then after a minute spits out lots of DBG found file

@RangelReale
Copy link
Contributor

I also have this feeling that when running in a Dockerfile, mockery is a lot slower than "native", in my M2 running directly it takes about 4 seconds, but running on docker build using the same architecture (--platform linux/arm64), it takes about 55 seconds, in our k8s CI jobs it takes 2 minutes.

If course running in docker it is expected to be slower, but this seems too much, even the go building don't have this difference in time.

I'm seeing if I can discover where this time difference happens, not very easy to do profiling in docker images.

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

5 participants