containers / buildah

A tool that facilitates building OCI images.
https://buildah.io
Apache License 2.0
7.43k stars 784 forks source link

MultiStage build times are erratic #913

Closed frezbo closed 5 years ago

frezbo commented 6 years ago
img (aws:rean-gov-sd)(kc)$ for i in {1..10}; do time buildah build-using-dockerfile --layers -f Dockerfile.scratch .; done
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m16.534s
user    0m0.258s
sys 0m0.153s
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m21.990s
user    0m0.252s
sys 0m0.162s
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m16.506s
user    0m0.272s
sys 0m0.141s
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m17.568s
user    0m0.274s
sys 0m0.154s
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m16.797s
user    0m0.253s
sys 0m0.159s
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m1.140s
user    0m0.167s
sys 0m0.130s
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m1.246s
user    0m0.182s
sys 0m0.128s
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m1.973s
user    0m0.169s
sys 0m0.125s
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m10.702s
user    0m0.258s
sys 0m0.139s
STEP 1: FROM alpine
STEP 2: COPY Dockerfile.new /
--> Using cache 300d81f006676f27886326df2fbb10dfa0af7e4818a7c02b06ad2047a48f95e2
STEP 3: COMMIT 
STEP 4: FROM scratch
STEP 5: COPY --from=base /Dockerfile.new /
--> Using cache a097a36b724628b84c449d93f0a5563671175182489942d74ad93e454a5684d7
STEP 6: COMMIT 

real    0m1.695s
user    0m0.181s
sys 0m0.127s
img (aws:rean-gov-sd)(kc)$ 

Dockerfile

img (aws:rean-gov-sd)(kc)$ cat Dockerfile.scratch 
FROM alpine as base
COPY Dockerfile.new /

FROM scratch
COPY --from=base /Dockerfile.new /

img (aws:rean-gov-sd)(kc)$ 
frezbo commented 6 years ago

More data: Non- Multistage build

img (aws:rean-gov-sd)(kc)$ for i in {1..10}; do time buildah build-using-dockerfile --layers -f Dockerfile.new .; done
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.869s
user    0m0.124s
sys 0m0.126s
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.659s
user    0m0.152s
sys 0m0.100s
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.724s
user    0m0.139s
sys 0m0.098s
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.883s
user    0m0.146s
sys 0m0.102s
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.705s
user    0m0.149s
sys 0m0.107s
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.771s
user    0m0.137s
sys 0m0.110s
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.714s
user    0m0.146s
sys 0m0.111s
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.824s
user    0m0.141s
sys 0m0.093s
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.706s
user    0m0.141s
sys 0m0.102s
STEP 1: FROM docker.io/library/alpine
STEP 2: RUN echo hi
--> Using cache f252e091be7c0e2c3a03345e3113216822a2b586cfab42036f61b47d1849d7c7
STEP 3: COMMIT 

real    0m0.747s
user    0m0.145s
sys 0m0.104s
img (aws:rean-gov-sd)(kc)$ 

Dockerfile

img (aws:rean-gov-sd)(kc)$ cat Dockerfile.new 
FROM docker.io/library/alpine
RUN echo hi

img (aws:rean-gov-sd)(kc)$ 
frezbo commented 6 years ago

I'm currently evaluating tools that builds Dockerfiles rootless and creting benchmark data, so that one coule be finalized in CI. As of now buildkit wins.

rhatdan commented 6 years ago

@mtrmac @nalind @baude @umohnani8 PTAL

mtrmac commented 6 years ago

It would be useful to collect data with more detailed timing information; at least buildah --debug.

(The difference between ~16 and ~2 seconds is way too much to be a completely random fluctuation; just a wild guess, could there be an adaptive caching proxy in the way, which eventually learns that some files are frequently requested?)

rhatdan commented 5 years ago

@frezbo Any more info on this?

rhatdan commented 5 years ago

No response from reporter, Closing reopen if this is still an issue.