-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
bun install ~2x slower than npm install in docker build #5142
Comments
Thanks for making this issue, we should be able to make it much faster on Docker. Are you just running |
These numbers are from running locally |
I am having the same issue - the Then the remaining executions take 2x the time. It just sits idle in "resolving dependencies". Perhaps bun has less aggressive retry logic than npm? FYI/off topic: my next builds ( |
Tried on another Ubuntu machine and got the expected results. I have a feeling this could be Docker version related. Tomorrow I can update with the Docker version of the machine having the performance discrepancy. Platform: Linux 5.15.0-76-generic x86_64 x86_64 Docker version 24.0.4, build 3713ee1 NPM: 17.5 seconds I tried this on my Mac and the results are more in line with what I would expect. Platform: Darwin 22.5.0 arm64 arm NPM: 9.5 seconds |
The machine from the original report was running: Docker version 24.0.6, build ed223bc |
Same issue here, with the latest versions of Node & Bun. For context, this is a production API (Express, Zod, Drizzle, Postgres, etc) Docker version 23.0.1, build a5ee5b1dfc Node (node:20.7-alpine3.18 + pnpm): 10.2s Out of curiosity, is Bun's image using the Alpine distro underneath? cc @Electroid @Jarred-Sumner |
@rafaell-lycan The |
I did try bunlovesnode/bun:1.0.0-node18 and it was much faster - for my particular case:
|
#10037 fixed a deadlock that could in theory occur and may be related to this |
Still regularly encountering exceptionally slow installs in docker container. Almost always the install runs for pretty exactly 300 seconds plus a few. To me this looks like a 5 minute timeout that it reliably runs into. Just did a fresh build
using a plain dockerfile
for CI/CD this is unbearable |
I really wish I knew how to reproduce this. My best guess right now is DNS. Perhaps issue with IPv6 vs IPv4. If you try using 8.8.8.8 or 1.1.1.1 for DNS it might fix itself. If the destination drive is a network drive like NFS or Windows via WSL, that would also explain it. We do lots of synchronous I/O in bun install which is often faster the disk is fast but slower when the disk is slow |
For me personally i do use WSL, but docker engine and the projects themselves are fully on the linux side, nothing on the host.
Can you elaborate on this, afaik docker uses the host DNS, which would be the one configured on my WSL instance not host system? Or where am I supposed to change the DNS? |
happy eyeballs, DNS caching have been implemented - #11206 If this is still not fixed, please let us know and we'll re-open the issue. |
@Jarred-Sumner I have this exact issue (although it's more than 2x, closer to 10x). I replicate it 100% of the time on my machine, is there any data I can obtain for you that can help diagnose what's going on? Some basic technical info about the machine with the issue: Apple M2 Max I've tried numerous different versions of Bun for the last few weeks, hoping it would eventually just get solved, but unfortunately not. I've just tried again now with 1.1.26 and it still has the issue. |
when running bun with verbose there are definitely long delays between fetching so seems like the networking issue is not resolved. Also with some dns tweaks I managed to make it mostly very fast but out of sudden it stuck on one of last files for over a minute... this is random of course |
@ciekawy I notice it 100% of the time on my personal machine (macOS), however when I push the Dockerfile up to a Linux machine, it works just fine. So I am kind of curious if |
Well there is no issues with any of npm, yarn, pnpm. Neither I notice any similar problems with any other services and I use dozens of docker images for my work... |
As for dns changes actually after verification, the only change that possibly makes real difference (the practical case I care about is docker build) is Considering bun itself being in general considerably faster I'd guess it would benefit from some batching optimizations eg keepalive to fetch number of deps and similarly as for disk access. |
What version of Bun is running?
1.0.1+31aec4ebe325982fc0ef27498984b0ad9969162b
What platform is your computer?
Linux 6.2.0-32-generic x86_64 x86_64
What steps can reproduce the bug?
This seems to be across the board for me, but the example below uses a create-react-template to demonstrate how severe this gets with lots of dependencies.
Create CRA Template
Node/NPM Dockerfile
docker build -t npm-cra -f Dockerfile.npm .
Bun Dockerfile
docker build -t bun-cra -f Dockerfile.bun .
What is the expected behavior?
When running outside of Docker, npm takes 5 second and bun takes 1 second. I would expect that inside the docker build bun outperforms the npm install.
What do you see instead?
The npm install inside Docker takes 12 seconds
The bun install inside Docker takes 29 seconds
Additional information
No response
The text was updated successfully, but these errors were encountered: