Buildah: build a large image with buildah use more time than docker a lot

Created on 9 Sep 2020  Â·  6Comments  Â·  Source: containers/buildah

My Dockerfile is as flows and the output image size is 523M

FROM alpine AS buildc
RUN apk add --no-cache build-base
RUN echo -e "#include <stdio.h>\nint main(int ac, char *av[]){printf(\"hello c\\\\n\");return 0;}" | tee /hello.c
COPY . /foo
RUN gcc -o /a.out /hello.c

# the COPY above SHOULD NOT invalidate the cache for the buildgo stage.

FROM alpine AS buildgo
RUN apk add --no-cache build-base
RUN apk add --no-cache go
RUN echo -e "package main\nfunc main(){println(\"hello go\")}" | tee /hello.go
RUN go build -o /a.out /hello.go

builadh

 time builadh bud -f Dockerfile

It cost 1m28s with buildah.

docker

time docker build --no-cache -f Dockerfile .

It cost 39s with docker.

We also analysize the buildah with pprof and find it cost a lot of time call io.Copy and sha256.Write. Statistics indicate that it call sha256.Write more than one hundred thousand in the build. For build a large image, may be use io.CopyBuffer with a reasonable buffer can relieve this problem.

profile001

Most helpful comment

@jingxiaolu There has been a full rewrite of the COPY code, we would love to have you run your analysys on the master branch or v1.16.2 to see how much it has improved.

Fantastic job ,20s in my environment with this new version, about 19s more faster than docker.

All 6 comments

@zvier thanks very much for the very thorough problem report. I know @nalind has been working feverishly on making the builds faster, so I'll ask him to comment on that status.

@TomSweeneyRedHat @nalind
could you please share your updates here? many thanks~

@jingxiaolu There has been a full rewrite of the COPY code, we would love to have you run your analysys on the master branch or v1.16.2 to see how much it has improved.

@rhatdan thanks very much for your update!
@zvier please~

@jingxiaolu There has been a full rewrite of the COPY code, we would love to have you run your analysys on the master branch or v1.16.2 to see how much it has improved.

Fantastic job ,20s in my environment with this new version, about 19s more faster than docker.

@zvier thanks very much for the follow-up. I'm so glad the changes were successful for your environment.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bkhadars picture bkhadars  Â·  11Comments

ssbarnea picture ssbarnea  Â·  11Comments

huapox picture huapox  Â·  12Comments

azatsarynnyy picture azatsarynnyy  Â·  4Comments

zhouhao3 picture zhouhao3  Â·  9Comments