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

Simple macro benchmark #2192

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zregvart
Copy link
Member

@zregvart zregvart commented Nov 29, 2024

Implementation of a simple macro benchmark executing ec validate image with the fixed state and no external dependencies.

For this the OCI distribution registry is run in a container with the data from the benchmark/simple/data.tar.gz that contains the copy of all images/blobs that the command and the policy rules currently access and the git repository.

The benchmark outputs in the golang standard benchmark format that can be utilized with tools in the golang benchmarking ecosystem.

Due to the global downloadCache variable in internal/policy/source/source.go the benchmark cannot be run in parallel. So only invoking the benchmark once is currently possible.

Reference: https://issues.redhat.com/browse/EC-968

Copy link

codecov bot commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 1.98347% with 593 lines in your changes missing coverage. Please review.

Project coverage is 67.26%. Comparing base (52d753b) to head (6710bd1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
benchmark/internal/registry/registry.go 0.00% 93 Missing ⚠️
benchmark/offliner/base_images.go 0.00% 77 Missing ⚠️
benchmark/simple/simple.go 0.00% 74 Missing ⚠️
benchmark/offliner/offliner.go 14.11% 73 Missing ⚠️
benchmark/offliner/scans.go 0.00% 67 Missing ⚠️
benchmark/offliner/related.go 0.00% 49 Missing ⚠️
benchmark/internal/untar/untar.go 0.00% 48 Missing ⚠️
benchmark/offliner/subjects.go 0.00% 45 Missing ⚠️
benchmark/offliner/referrers.go 0.00% 33 Missing ⚠️
benchmark/offliner/refs.go 0.00% 12 Missing ⚠️
... and 3 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2192      +/-   ##
==========================================
- Coverage   72.42%   67.26%   -5.16%     
==========================================
  Files          88      100      +12     
  Lines        7539     8135     +596     
==========================================
+ Hits         5460     5472      +12     
- Misses       2079     2663     +584     
Flag Coverage Δ
generative 67.26% <1.98%> (-5.16%) ⬇️
integration 67.26% <1.98%> (-5.16%) ⬇️
unit 67.26% <1.98%> (-5.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
benchmark/offliner/nab.go 0.00% <0.00%> (ø)
benchmark/internal/suite/suite.go 0.00% <0.00%> (ø)
cmd/root.go 0.00% <0.00%> (ø)
benchmark/offliner/refs.go 0.00% <0.00%> (ø)
benchmark/offliner/referrers.go 0.00% <0.00%> (ø)
benchmark/offliner/subjects.go 0.00% <0.00%> (ø)
benchmark/internal/untar/untar.go 0.00% <0.00%> (ø)
benchmark/offliner/related.go 0.00% <0.00%> (ø)
benchmark/offliner/scans.go 0.00% <0.00%> (ø)
benchmark/offliner/offliner.go 14.11% <14.11%> (ø)
... and 3 more

@zregvart zregvart force-pushed the issue/EC-968 branch 2 times, most recently from 965e4a4 to 8892a99 Compare December 3, 2024 12:55
benchmark/internal/untar/untar.go Fixed Show fixed Hide fixed
benchmark/internal/untar/untar.go Fixed Show fixed Hide fixed
benchmark/internal/untar/untar.go Fixed Show fixed Hide fixed
benchmark/internal/untar/untar.go Fixed Show fixed Hide fixed
benchmark/internal/untar/untar.go Fixed Show fixed Hide fixed
benchmark/internal/untar/untar.go Fixed Show fixed Hide fixed
@zregvart zregvart force-pushed the issue/EC-968 branch 2 times, most recently from 5de07b4 to ca57b86 Compare December 3, 2024 14:17
@zregvart
Copy link
Member Author

zregvart commented Dec 3, 2024

I ran the benchmark on main (this branch) and with reverted #2184, this gives us some data to work with:

$ make benchmark > new.txt
$ git revert --no-commit --mainline 1 b8c77a098e2e0aa661d2f61cb7d44569494fe195
$ make benchmark > old.txt
$ go run golang.org/x/perf/cmd/benchstat@latest old.txt new.txt 
pkg: golang.org/x/benchmarks
goos: linux
goarch: amd64
          │   old.txt   │             new.txt             │
          │   sec/op    │   sec/op     vs base            │
Simple-12   21.08 ± 24%   22.64 ± 28%  ~ (p=0.475 n=10+7)

          │       old.txt        │                 new.txt                  │
          │ GC-bytes-from-system │ GC-bytes-from-system  vs base            │
Simple-12           7.450Mi ± 4%           7.452Mi ± 0%  ~ (p=1.000 n=10+7)

          │   old.txt   │             new.txt              │
          │ STW-sec/GC  │  STW-sec/GC   vs base            │
Simple-12   72.11µ ± 5%   76.71µ ± 15%  ~ (p=0.109 n=10+7)

          │   old.txt   │             new.txt              │
          │ STW-sec/op  │  STW-sec/op   vs base            │
Simple-12   3.678m ± 8%   3.989m ± 10%  ~ (p=0.193 n=10+7)

          │      old.txt       │                new.txt                 │
          │ allocated-bytes/op │ allocated-bytes/op  vs base            │
Simple-12         3.531Gi ± 0%         3.529Gi ± 0%  ~ (p=0.601 n=10+7)

          │   old.txt   │             new.txt             │
          │  allocs/op  │  allocs/op   vs base            │
Simple-12   74.91M ± 0%   74.90M ± 0%  ~ (p=0.417 n=10+7)

          │      old.txt      │                new.txt                │
          │ bytes-from-system │ bytes-from-system  vs base            │
Simple-12        336.5Mi ± 6%        331.6Mi ± 8%  ~ (p=0.109 n=10+7)

          │        old.txt         │                  new.txt                   │
          │ heap-bytes-from-system │ heap-bytes-from-system  vs base            │
Simple-12             313.2Mi ± 5%             309.3Mi ± 7%  ~ (p=0.103 n=10+7)

          │         old.txt         │                   new.txt                   │
          │ other-bytes-from-system │ other-bytes-from-system  vs base            │
Simple-12             13.06Mi ± 22%             12.19Mi ± 18%  ~ (p=0.315 n=10+7)

          │    old.txt     │              new.txt               │
          │ peak-RSS-bytes │ peak-RSS-bytes  vs base            │
Simple-12     374.0Mi ± 4%     375.0Mi ± 4%  ~ (p=0.216 n=10+7)

          │    old.txt    │              new.txt              │
          │ peak-VM-bytes │ peak-VM-bytes  vs base            │
Simple-12    2.594Gi ± 0%    2.593Gi ± 0%  ~ (p=0.364 n=10+7)

          │         old.txt         │                   new.txt                   │
          │ stack-bytes-from-system │ stack-bytes-from-system  vs base            │
Simple-12             2.531Mi ± 15%             2.625Mi ± 32%  ~ (p=0.757 n=10+7)

          │     old.txt     │                 new.txt                  │
          │ user+sys-sec/op │ user+sys-sec/op  vs base                 │
Simple-12        16.81 ± 1%        17.29 ± 5%  +2.89% (p=0.003 n=10+7)

@zregvart
Copy link
Member Author

zregvart commented Dec 3, 2024

Or this:

$ go run github.com/aclements/go-misc/benchplot@latest -table < old.txt < new.txt  
name    commit                                    goarch  gomaxprocs  goos   pkg                      GC bytes from system  STW ns/GC     STW ns/op  allocated bytes/op      allocs/op  bytes from system  heap bytes from system        time/op  other bytes from system  peak RSS bytes    peak VM bytes  stack bytes from system  user+sys ns/op  author date                      commit date                      branch
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks          7.388304e+06      69241  3.531315e+06     3.778012632e+09  7.4911588e+07     3.06943304e+08          2.87752192e+08  15.261476793s            1.0197176e+07  3.63954176e+08  2.781290496e+09             1.605632e+06   1.6799825e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks          7.521424e+06      74916  3.745815e+06          3.7791e+09   7.485901e+07     3.32764488e+08          3.12262656e+08  24.807957719s            1.0719416e+07  3.75721984e+08  2.781945856e+09             2.260992e+06   1.6879586e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks          7.556432e+06      68059  3.402986e+06      3.78658716e+09  7.4876489e+07     3.41939528e+08           3.2038912e+08   21.50126229s             1.147084e+07  3.75721984e+08  2.782732288e+09             2.523136e+06   1.6752205e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks          7.664976e+06      74192  3.709613e+06     3.787023712e+09  7.4888137e+07     3.52032072e+08          3.28769536e+08  17.815126363s            1.3041656e+07  3.77462784e+08  2.784436224e+09             2.555904e+06   1.6950228e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks          7.820624e+06      68220  3.479244e+06     3.790754024e+09  7.4898098e+07     3.52687432e+08          3.28679424e+08  22.304228577s            1.3565944e+07  3.92167424e+08  2.785091584e+09              2.62144e+06    1.656368e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks          7.822672e+06      74985  3.974215e+06      3.79210996e+09  7.4906908e+07     3.52949576e+08          3.28515584e+08  19.824680378s             1.382604e+07  3.92167424e+08  2.785497088e+09              2.78528e+06   1.6812701e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks          7.822672e+06      69821  3.630721e+06     3.793855408e+09  7.4914554e+07     3.53736008e+08          3.28613888e+08  21.834668714s            1.4612472e+07  3.93637888e+08   2.78628352e+09             2.686976e+06   1.6735574e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks           7.82472e+06      82286  4.361192e+06     3.797124616e+09  7.4923341e+07     3.53998152e+08          3.28548352e+08  27.378535039s            1.4872568e+07  3.93637888e+08  2.786545664e+09             2.752512e+06   1.7629466e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks          7.826768e+06      74091  3.926842e+06     3.798563712e+09   7.492748e+07     3.54260296e+08           3.2841728e+08   16.03434922s            1.5132664e+07  3.94186752e+08  2.786807808e+09             2.883584e+06    1.683912e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  b8c77a098e2e0aa661d2f61cb7d44569494fe195  amd64           12  linux  golang.org/x/benchmarks          7.802192e+06      70122  3.646345e+06     3.795470056e+09  7.4933335e+07     3.55046728e+08           3.2837632e+08   20.65151226s            1.5919096e+07  3.94186752e+08   2.78759424e+09              2.94912e+06   1.6584346e+10  2024-11-26 22:23:43 -0600 -0600  2024-11-26 22:23:43 -0600 -0600  master
Simple  2cbd256090f8ed003f34df00136a8f6af22c813d  amd64           12  linux  golang.org/x/benchmarks           7.80624e+06      72360  3.618034e+06     3.779018376e+09  7.4912535e+07     3.20181576e+08           3.0007296e+08  21.282231407s              1.04346e+07  3.77708544e+08   2.78194176e+09             1.867776e+06   1.7130636e+10  2024-12-03 13:53:59 +0100 CET    2024-12-03 16:15:31 +0100 CET    master
Simple  2cbd256090f8ed003f34df00136a8f6af22c813d  amd64           12  linux  golang.org/x/benchmarks          7.812384e+06      88067  4.315294e+06     3.782928088e+09  7.4861743e+07     3.37745224e+08            3.166208e+08  18.539786552s            1.1214888e+07  3.84495616e+08  2.782728192e+09             2.097152e+06   1.7414331e+10  2024-12-03 13:53:59 +0100 CET    2024-12-03 16:15:31 +0100 CET    master
Simple  2cbd256090f8ed003f34df00136a8f6af22c813d  amd64           12  linux  golang.org/x/benchmarks          7.814432e+06      71705  3.585256e+06     3.791234912e+09    7.48768e+07     3.46920264e+08          3.24517888e+08  22.644623917s            1.1999272e+07  3.86080768e+08  2.783657984e+09             2.588672e+06   1.7291374e+10  2024-12-03 13:53:59 +0100 CET    2024-12-03 16:15:31 +0100 CET    master
Simple  2cbd256090f8ed003f34df00136a8f6af22c813d  amd64           12  linux  golang.org/x/benchmarks          7.814432e+06      79898  4.314514e+06      3.78830704e+09  7.4888791e+07     3.47706696e+08          3.24288512e+08  23.104691628s            1.2785704e+07   3.9323648e+08  2.784444416e+09             2.818048e+06   1.8176549e+10  2024-12-03 13:53:59 +0100 CET    2024-12-03 16:15:31 +0100 CET    master
Simple  2cbd256090f8ed003f34df00136a8f6af22c813d  amd64           12  linux  golang.org/x/benchmarks          7.814432e+06      71263  3.776953e+06     3.789166608e+09  7.4897863e+07      3.4796884e+08          3.24288512e+08  26.251101656s            1.3047848e+07  4.02669568e+08   2.78470656e+09             2.818048e+06   1.7203267e+10  2024-12-03 13:53:59 +0100 CET    2024-12-03 16:15:31 +0100 CET    master
Simple  2cbd256090f8ed003f34df00136a8f6af22c813d  amd64           12  linux  golang.org/x/benchmarks          7.814432e+06      77997  4.055846e+06       3.7930422e+09  7.4904772e+07     3.48493128e+08          3.24354048e+08  23.596506182s            1.3572136e+07  4.02669568e+08  2.785230848e+09             2.752512e+06   1.7206578e+10  2024-12-03 13:53:59 +0100 CET    2024-12-03 16:15:31 +0100 CET    master
Simple  2cbd256090f8ed003f34df00136a8f6af22c813d  amd64           12  linux  golang.org/x/benchmarks           7.81648e+06      76705   3.98867e+06     3.795461016e+09   7.491587e+07     3.49017416e+08          3.23895296e+08  16.316102421s            1.4094376e+07  4.02669568e+08  2.785755136e+09             3.211264e+06   1.7484886e+10  2024-12-03 13:53:59 +0100 CET    2024-12-03 16:15:31 +0100 CET    master
$ go run github.com/aclements/go-misc/benchplot@latest < old.txt < new.txt > graph.svg

Gives:

graph

@zregvart zregvart changed the title Benchmarking Simple benchmark Dec 18, 2024
@zregvart zregvart changed the title Simple benchmark Simple macro benchmark Dec 18, 2024
Implementation of a simple macro benchmark executing `ec validate image`
with the fixed state and no external dependencies.

For this the OCI distribution registry is run in a container with the
data from the `benchmark/simple/data.tar.gz` that contains the copy of
all images/blobs that the command and the policy rules currently access
and the git repository.

The benchmark outputs in the golang standard benchmark format that can
be utilized with tools in the golang benchmarking ecosystem.

Due to the global `downloadCache` variable in
`internal/policy/source/source.go` the benchmark cannot be run in
parallel. So only invoking the benchmark once is currently possible.

Reference: https://issues.redhat.com/browse/EC-968
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.

1 participant