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

feat: optimize build #694

Merged
merged 4 commits into from
Oct 4, 2019

Conversation

orisano
Copy link
Contributor

@orisano orisano commented Jun 4, 2019

  • replace md5 to highwayhash
  • optimize HasFilepathPrefix

Result in my project:
runtime.main: 87.51s -> 55.40s
total: 129.54s -> 88.29s

before:

profile001

after:

profile002

@orisano orisano force-pushed the feat-optimize-build branch from c798a46 to 4647b3e Compare June 4, 2019 18:31
@orisano
Copy link
Contributor Author

orisano commented Jun 4, 2019

Bench Result of HasFilepathPrefix.

name                                           old time/op    new time/op    delta
HasFilepathPrefix/PathDepth=2,PrefixDepth=1-4     297ns ± 9%     289ns ±21%     ~     (p=0.726 n=10+10)
HasFilepathPrefix/PathDepth=3,PrefixDepth=1-4     298ns ± 3%     270ns ± 6%   -9.16%  (p=0.000 n=10+9)
HasFilepathPrefix/PathDepth=4,PrefixDepth=1-4     332ns ± 4%     289ns ±13%  -13.04%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=5,PrefixDepth=1-4     384ns ±14%     319ns ± 7%  -16.92%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=2,PrefixDepth=2-4     303ns ±14%     337ns ±38%     ~     (p=0.133 n=10+9)
HasFilepathPrefix/PathDepth=3,PrefixDepth=2-4     362ns ±17%     346ns ±13%     ~     (p=0.247 n=10+10)
HasFilepathPrefix/PathDepth=4,PrefixDepth=2-4     427ns ±22%     390ns ±16%     ~     (p=0.086 n=10+10)
HasFilepathPrefix/PathDepth=5,PrefixDepth=2-4     403ns ± 9%     347ns ± 6%  -13.88%  (p=0.000 n=9+9)
HasFilepathPrefix/PathDepth=2,PrefixDepth=3-4     342ns ± 7%     353ns ±13%     ~     (p=0.530 n=9+9)
HasFilepathPrefix/PathDepth=3,PrefixDepth=3-4     413ns ±15%     353ns ± 8%  -14.39%  (p=0.001 n=10+10)
HasFilepathPrefix/PathDepth=4,PrefixDepth=3-4     531ns ±28%     383ns ± 3%  -27.77%  (p=0.000 n=9+10)
HasFilepathPrefix/PathDepth=5,PrefixDepth=3-4     485ns ±29%     424ns ±19%  -12.53%  (p=0.009 n=10+10)

name                                           old alloc/op   new alloc/op   delta
HasFilepathPrefix/PathDepth=2,PrefixDepth=1-4     80.0B ± 0%     80.0B ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=3,PrefixDepth=1-4     96.0B ± 0%     80.0B ± 0%  -16.67%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=4,PrefixDepth=1-4      112B ± 0%       80B ± 0%  -28.57%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=5,PrefixDepth=1-4      128B ± 0%       80B ± 0%  -37.50%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=2,PrefixDepth=2-4     96.0B ± 0%    112.0B ± 0%  +16.67%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=3,PrefixDepth=2-4      112B ± 0%      112B ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=4,PrefixDepth=2-4      128B ± 0%      112B ± 0%  -12.50%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=5,PrefixDepth=2-4      144B ± 0%      112B ± 0%  -22.22%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=2,PrefixDepth=3-4      112B ± 0%      144B ± 0%  +28.57%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=3,PrefixDepth=3-4      128B ± 0%      144B ± 0%  +12.50%  (p=0.000 n=10+10)
HasFilepathPrefix/PathDepth=4,PrefixDepth=3-4      144B ± 0%      144B ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=5,PrefixDepth=3-4      160B ± 0%      144B ± 0%  -10.00%  (p=0.000 n=10+10)

name                                           old allocs/op  new allocs/op  delta
HasFilepathPrefix/PathDepth=2,PrefixDepth=1-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=3,PrefixDepth=1-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=4,PrefixDepth=1-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=5,PrefixDepth=1-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=2,PrefixDepth=2-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=3,PrefixDepth=2-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=4,PrefixDepth=2-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=5,PrefixDepth=2-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=2,PrefixDepth=3-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=3,PrefixDepth=3-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=4,PrefixDepth=3-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
HasFilepathPrefix/PathDepth=5,PrefixDepth=3-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)

@orisano orisano force-pushed the feat-optimize-build branch from 4647b3e to ace76f4 Compare June 4, 2019 18:35
@orisano
Copy link
Contributor Author

orisano commented Jul 28, 2019

ping

hasher := func(p string) (string, error) {
h := md5.New()
h, _ := highwayhash.New(key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check error. Can you explain or add link to benefits os highwayhash instead of md5.
Any disadvantages? Is this project being actively worked on?

pkg/util/util.go Show resolved Hide resolved
@tejal29
Copy link
Contributor

tejal29 commented Sep 17, 2019

@orisano This looks awesome! Thank you for all tour work!
Left a few comments.

@tejal29
Copy link
Contributor

tejal29 commented Sep 17, 2019

Looks like this failed

Building images for Dockerfile Dockerfile_test_meta_arg
Error building images: Failed to build image gcr.io/kaniko-test/docker-dockerfile_test_registry with kaniko command "[docker run -v /home/kbuilder/.config/gcloud:/root/.config/gcloud -v /tmpfs/tmp/622634064:/kaniko/benchmarks -v /usr/local/go/src/github.com/GoogleContainerTools/kaniko/integration:/workspace -e BENCHMARK_FILE=false executor-image -f /workspace/dockerfiles/Dockerfile_test_registry -d gcr.io/kaniko-test/kaniko-dockerfile_test_registry  -c /workspace]": exit status 1 

if _, err := io.Copy(h, f); err != nil {
buf := pool.Get().(*[]byte)
defer pool.Put(buf)
if _, err := io.CopyBuffer(h, f, *buf); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool!

@tejal29 tejal29 merged commit 865d49c into GoogleContainerTools:master Oct 4, 2019
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

Successfully merging this pull request may close these issues.

3 participants