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

[Bug Report]: oven/bun:alpine build is way slower (2s vs 14s for a project with antd) #2075

Open
chneau opened this issue Jan 28, 2025 · 5 comments

Comments

@chneau
Copy link

chneau commented Jan 28, 2025

Steps to reproduce

Have a new farm: bun create farm@latest.

Add dockerfile like so:

FROM oven/bun AS build-client
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install
COPY . .
RUN bun x farm build

Run
Switch FROM oven/bun to FROM oven/bun:alpine
Run and notice considerable longer build time

Reproduce link

No response

What is actually happening?

alpine version of farm is very very slower.

System Info

It's all docker
@chneau chneau changed the title [Bug Report]: oven/bun:alpine build is way slower (2s vs 14s) [Bug Report]: oven/bun:alpine build is way slower (2s vs 14s for a project with antd) Jan 28, 2025
@fu050409
Copy link
Member

Thanks for you reporting, have you tried it in a physical machine? I think this may be due to the overhead associated with virtual environments rather than ours, lol😂

@chneau
Copy link
Author

chneau commented Jan 29, 2025

I'll create a repo for reproduction with steps.
Here is my theory:

  • Alpine is not using glibc but musl (which is different from overhead of virtual environment it's just a different library of C stuff (I don't know this much from here))
  • When you add @farmfe/core you as well install the binary versions for each architecture: "@farmfe/core-linux-x64-gnu": "1.6.6", "@farmfe/core-linux-x64-musl": "1.6.6"
  • What I think is: @farmfe/core-linux-x64-musl is way slower than @farmfe/core-linux-x64-gnu for some reason

@fu050409
Copy link
Member

Thanks

@chneau
Copy link
Author

chneau commented Jan 29, 2025

Here it is https://github.com/chneau/farm-alpine-slow-bug

Please clone and run bun run docker-build-fast and check the timing of the build step, and so the same for bun run docker-build-slow. Here is the screenshot for me:

Image

That's 10.8sec vs 2.4sec.

Why does it matter to me?
I usually use :alpine as the final stage of a multi step Dockerfile, where, for example, I build the server, the client and on a final stage I copy the assets from client to final public folder, copy server.js to final and entrypoint to the server.js which will server the client files as a SPA. Having the exact same :alpine image for each steps cuts down image download and make the build faster to run.

I started to notice that farm build was significantly slower compared to my machine, the only difference would be the -gnu version I use on my PC vs the -musl version I use on the docker build.

Here I enter a territory I don't know much but I would bet something like that: https://www.reddit.com/r/rust/comments/gdycv8/why_does_musl_make_my_code_so_slow/ ?

@wre232114
Copy link
Member

We'll take a look, thanks for the reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants