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 #2304

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

simonbaird
Copy link
Member

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

(Original PR at #2192)

zregvart and others added 3 commits February 7, 2025 14:54
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 Feb 7, 2025

Codecov Report

Attention: Patch coverage is 1.98020% with 594 lines in your changes missing coverage. Please review.

Project coverage is 67.69%. Comparing base (6642931) to head (3ad6b32).

Files with missing lines Patch % Lines
benchmark/internal/registry/registry.go 0.00% 94 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    #2304      +/-   ##
==========================================
- Coverage   72.79%   67.69%   -5.11%     
==========================================
  Files          89      101      +12     
  Lines        7687     8284     +597     
==========================================
+ Hits         5596     5608      +12     
- Misses       2091     2676     +585     
Flag Coverage Δ
generative 67.69% <1.98%> (-5.11%) ⬇️
integration 67.69% <1.98%> (-5.11%) ⬇️
unit 67.69% <1.98%> (-5.11%) ⬇️

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

@simonbaird
Copy link
Member Author

To try this out:

podman login quay.io && podman login registry.redhat.io # I think?
make benchmark

@simonbaird
Copy link
Member Author

What I'm getting:

make benchmark
❱ benchmark_simple
pkg: golang.org/x/benchmarks
goos: linux
goarch: amd64

driver.go:212: Benchmarking 1 iterations
ERRO[0013] fetch image: GET https://registry.access.redhat.com/v2/ubi9/ubi-micro/manifests/sha256:3313e52bb1aad4017a0c35f9f2ae35cf8526eeeb83f6ecbec449ba9c5cb9cb07: MANIFEST_UNKNOWN: manifest unknown; map[Name:ubi9/ubi-micro Revision:sha256:3313e52bb1aad4017a0c35f9f2ae35cf8526eeeb83f6ecbec449ba9c5cb9cb07]  ref="registry.access.redhat.com/ubi9/ubi-micro@sha256:3313e52bb1aad4017a0c35f9f2ae35cf8526eeeb83f6ecbec449ba9c5cb9cb07" rego=ec.oci.image_manifest
panic: error validating image quay.io/redhat-user-workloads/rhtap-contract-tenant/golden-container/golden-container@sha256:166e38c156fa81d577a7ba7a948b68c79005a06e302779d1bebc7d31e8bea315 of component golden-container: symlink /tmp/ec-work-908271679/policy/e04a4501a /tmp/ec-work-391798418/policy/e04a4501a: file exists
error validating image quay.io/redhat-user-workloads/rhtap-contract-tenant/golden-container/golden-container@sha256:33f21e83a1b2780480bac22749f56c8a2d460e853999d3b246fabd8fdbe722d9 of component golden-container-sha256:33f21e83a1b2780480bac22749f56c8a2d460e853999d3b246fabd8fdbe722d9-arm64: pulling policy: failed to resolve quay.io/enterprise-contract/ec-release-policy@sha256:1e70b8f672388838f20a7d45e145e31e99dab06cefa1c5514d6ce41c8bbea1b0: quay.io/enterprise-contract/ec-release-policy@sha256:1e70b8f672388838f20a7d45e145e31e99dab06cefa1c5514d6ce41c8bbea1b0: not found

goroutine 170 [running]:
main.ec.func1()
        /home/sbaird/c/ec/ec-cli/benchmark/simple/simple.go:114 +0x165
golang.org/x/benchmarks/driver.Parallel.func1()
        /home/sbaird/.asdf/installs/golang/1.22.7/packages/pkg/mod/golang.org/x/[email protected]/driver/driver.go:287 +0x64
created by golang.org/x/benchmarks/driver.Parallel in goroutine 1
        /home/sbaird/.asdf/installs/golang/1.22.7/packages/pkg/mod/golang.org/x/[email protected]/driver/driver.go:284 +0x8b
exit status 2
make: *** [Makefile:148: benchmark_simple] Error 1

@joejstuart
Copy link
Member

just tried from the Mac.

❱ benchmark_simple
pkg: golang.org/x/benchmarks
goos: darwin
goarch: arm64

driver.go:212: Benchmarking 1 iterations
WARN[0021] Encountered error while checking for Image Index: unable to fetch descriptior for container image quay.io/redhat-user-workloads/rhtap-contract-tenant/golden-container/golden-container@sha256:166e38c156fa81d577a7ba7a948b68c79005a06e302779d1bebc7d31e8bea315: Get "https://quay.io/v2/": tls: failed to verify certificate: x509: “benchmark.ec” certificate is not standards compliant 
panic: pulling policy: failed to resolve quay.io/enterprise-contract/ec-release-policy@sha256:64617f0c45689ef7152c5cfbd4cd5709a3126e4ab7482eb6acd994387fe2d4ba: Get "https://quay.io/v2/enterprise-contract/ec-release-policy/manifests/sha256:64617f0c45689ef7152c5cfbd4cd5709a3126e4ab7482eb6acd994387fe2d4ba": tls: failed to verify certificate: x509: “benchmark.ec” certificate is not standards compliant

goroutine 33 [running]:
main.ec.func1()
	/Users/jstuart/Documents/repos/ec-cli/benchmark/simple/simple.go:114 +0x168
golang.org/x/benchmarks/driver.Parallel.func1()
	/Users/jstuart/go/pkg/mod/golang.org/x/[email protected]/driver/driver.go:287 +0x60
created by golang.org/x/benchmarks/driver.Parallel in goroutine 1
	/Users/jstuart/go/pkg/mod/golang.org/x/[email protected]/driver/driver.go:284 +0x84
exit status 2
make: *** [Makefile:148: benchmark_simple] Error 1

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