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

[WIP] benchmark createClusterCatalog func #1651

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

Conversation

jianzhangbjz
Copy link

@jianzhangbjz jianzhangbjz commented Jan 27, 2025

Description

See more: #920

  • Serial run on AWS, Cluster version is 4.18.0-0.nightly-2025-01-25-163410
jiazha-mac:e2e jiazha$ go test -run=^$ -bench=. -count=10 -memprofile=mem.out -cpuprofile=cpu.out
goos: darwin
goarch: arm64
pkg: github.com/operator-framework/operator-controller/test/e2e
cpu: Apple M1 Pro
BenchmarkCreateClusterCatalog-10    	       1	1444716583 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 619736229 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 594375416 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 599388104 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 578713375 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 604820354 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 614665062 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 613025938 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 622365104 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 591780896 ns/op
PASS
ok  	github.com/operator-framework/operator-controller/test/e2e	18.360s
jiazha-mac:e2e jiazha$ go tool pprof mem.out 
File: e2e.test
Type: alloc_space
Time: Jan 27, 2025 at 2:00pm (CST)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 6893.09kB, 72.92% of 9453.29kB total
Showing top 10 nodes out of 93
      flat  flat%   sum%        cum   cum%
 1762.94kB 18.65% 18.65%  1762.94kB 18.65%  runtime/pprof.StartCPUProfile
  902.59kB  9.55% 28.20%  1485.59kB 15.72%  compress/flate.NewWriter
  583.01kB  6.17% 34.36%   583.01kB  6.17%  compress/flate.newDeflateFast (inline)
  548.84kB  5.81% 40.17%  1573.29kB 16.64%  k8s.io/apimachinery/pkg/runtime.(*Scheme).AddKnownTypeWithName
  532.26kB  5.63% 45.80%   532.26kB  5.63%  github.com/gogo/protobuf/proto.RegisterType
  513.50kB  5.43% 51.23%   513.50kB  5.43%  k8s.io/apimachinery/pkg/conversion.ConversionFuncs.AddUntyped
  512.75kB  5.42% 56.66%   512.75kB  5.42%  vendor/golang.org/x/crypto/cryptobyte.(*Builder).add
  512.62kB  5.42% 62.08%   512.62kB  5.42%  k8s.io/api/apps/v1beta2.addKnownTypes
  512.44kB  5.42% 67.50%   512.44kB  5.42%  sync.(*Map).dirtyLocked
  512.14kB  5.42% 72.92%   512.14kB  5.42%  k8s.io/api/resource/v1alpha3.init
(pprof) exit
jiazha-mac:e2e jiazha$ go tool pprof cpu.out 
File: e2e.test
Type: cpu
Time: Jan 27, 2025 at 2:00pm (CST)
Duration: 17.83s, Total samples = 160ms (  0.9%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 160ms, 100% of 160ms total
Showing top 10 nodes out of 93
      flat  flat%   sum%        cum   cum%
      40ms 25.00% 25.00%       40ms 25.00%  runtime.pthread_cond_signal
      40ms 25.00% 50.00%       40ms 25.00%  runtime.scanobject
      40ms 25.00% 75.00%       40ms 25.00%  syscall.syscall
      10ms  6.25% 81.25%       10ms  6.25%  crypto/internal/edwards25519/field.addMul64 (inline)
      10ms  6.25% 87.50%       10ms  6.25%  k8s.io/apimachinery/pkg/runtime.(*clientNegotiator).Decoder
      10ms  6.25% 93.75%       10ms  6.25%  runtime.pthread_kill
      10ms  6.25%   100%       10ms  6.25%  runtime.usleep
         0     0%   100%       30ms 18.75%  bufio.(*Writer).Flush
         0     0%   100%       10ms  6.25%  crypto/ecdh.(*PrivateKey).PublicKey
         0     0%   100%       10ms  6.25%  crypto/ecdh.(*PrivateKey).PublicKey.func1
(pprof) exit
  • parallel run on AWS, Cluster version is 4.18.0-0.nightly-2025-01-25-163410
jiazha-mac:e2e jiazha$ go test -run=^$ -bench=. -count=10 -memprofile=mem.out -cpuprofile=cpu.out
goos: darwin
goarch: arm64
pkg: github.com/operator-framework/operator-controller/test/e2e
cpu: Apple M1 Pro
BenchmarkCreateClusterCatalog-10    	       1	1559796167 ns/op
BenchmarkCreateClusterCatalog-10    	      12	 105038868 ns/op
BenchmarkCreateClusterCatalog-10    	      13	  88542141 ns/op
BenchmarkCreateClusterCatalog-10    	      13	  94152035 ns/op
BenchmarkCreateClusterCatalog-10    	      13	  93457205 ns/op
BenchmarkCreateClusterCatalog-10    	      13	  94673955 ns/op
BenchmarkCreateClusterCatalog-10    	      20	  62803019 ns/op
BenchmarkCreateClusterCatalog-10    	      13	  87578115 ns/op
BenchmarkCreateClusterCatalog-10    	      12	 107728125 ns/op
BenchmarkCreateClusterCatalog-10    	      12	  98580924 ns/op
PASS
ok  	github.com/operator-framework/operator-controller/test/e2e	38.984s
jiazha-mac:e2e jiazha$ go tool pprof cpu.out 
File: e2e.test
Type: cpu
Time: Jan 27, 2025 at 2:09pm (CST)
Duration: 38.06s, Total samples = 570ms ( 1.50%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 410ms, 71.93% of 570ms total
Showing top 10 nodes out of 201
      flat  flat%   sum%        cum   cum%
      70ms 12.28% 12.28%       70ms 12.28%  runtime.kevent
      70ms 12.28% 24.56%       70ms 12.28%  runtime.pthread_cond_signal
      60ms 10.53% 35.09%       60ms 10.53%  runtime.pthread_cond_wait
      60ms 10.53% 45.61%       60ms 10.53%  syscall.syscall
      50ms  8.77% 54.39%       50ms  8.77%  runtime.pthread_kill
      30ms  5.26% 59.65%       30ms  5.26%  runtime.madvise
      30ms  5.26% 64.91%       30ms  5.26%  runtime.pthread_cond_timedwait_relative_np
      20ms  3.51% 68.42%       20ms  3.51%  runtime.(*mspan).writeHeapBitsSmall
      10ms  1.75% 70.18%       10ms  1.75%  crypto/internal/bigmod.(*Nat).reset
      10ms  1.75% 71.93%       10ms  1.75%  k8s.io/apimachinery/pkg/runtime.setTargetKind
(pprof) exit
jiazha-mac:e2e jiazha$ go tool pprof mem.out 
File: e2e.test
Type: alloc_space
Time: Jan 27, 2025 at 2:09pm (CST)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 10718.54kB, 61.67% of 17380.55kB total
Showing top 10 nodes out of 166
      flat  flat%   sum%        cum   cum%
 2048.12kB 11.78% 11.78%  2048.12kB 11.78%  path.Join
 1762.94kB 10.14% 21.93%  1762.94kB 10.14%  runtime/pprof.StartCPUProfile
 1536.56kB  8.84% 30.77%  1536.56kB  8.84%  golang.org/x/net/http2.(*ClientConn).roundTrip
 1065.48kB  6.13% 36.90%  2101.58kB 12.09%  k8s.io/apimachinery/pkg/runtime.(*Scheme).AddKnownTypeWithName
 1025.38kB  5.90% 42.80%  1025.38kB  5.90%  sync.(*Pool).pinSlow
 1024.14kB  5.89% 48.69%  1536.17kB  8.84%  k8s.io/client-go/rest.(*Request).URL
  650.62kB  3.74% 52.43%   650.62kB  3.74%  compress/flate.(*compressor).init
  553.04kB  3.18% 55.62%   553.04kB  3.18%  github.com/gogo/protobuf/proto.RegisterType
  528.17kB  3.04% 58.65%   528.17kB  3.04%  regexp.(*bitState).reset
  524.09kB  3.02% 61.67%   524.09kB  3.02%  k8s.io/apimachinery/pkg/conversion.ConversionFuncs.AddUntyped
(pprof) exit

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@jianzhangbjz jianzhangbjz requested a review from a team as a code owner January 27, 2025 06:21
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 27, 2025
Copy link

netlify bot commented Jan 27, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 63ea7ea
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/679725f703b96a00085f0b0d
😎 Deploy Preview https://deploy-preview-1651--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.40%. Comparing base (a46ff7d) to head (63ea7ea).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1651      +/-   ##
==========================================
- Coverage   67.42%   67.40%   -0.03%     
==========================================
  Files          55       55              
  Lines        4632     4632              
==========================================
- Hits         3123     3122       -1     
- Misses       1284     1285       +1     
  Partials      225      225              
Flag Coverage Δ
e2e 53.29% <ø> (+0.08%) ⬆️
unit 54.42% <ø> (-0.03%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jianzhangbjz
Copy link
Author

jianzhangbjz commented Jan 27, 2025

  • parallel run on IBMCloud, Cluster version is 4.18.0-0.nightly-2025-01-25-163410
jiazha-mac:e2e jiazha$ go test -run=^$ -bench=. -count=10 -memprofile=mem.out -cpuprofile=cpu.out
goos: darwin
goarch: arm64
pkg: github.com/operator-framework/operator-controller/test/e2e
cpu: Apple M1 Pro
BenchmarkCreateClusterCatalog-10    	       1	2093042334 ns/op
BenchmarkCreateClusterCatalog-10    	       4	 611432146 ns/op
BenchmarkCreateClusterCatalog-10    	      10	 224809304 ns/op
BenchmarkCreateClusterCatalog-10    	      13	  92630189 ns/op
BenchmarkCreateClusterCatalog-10    	       6	 174559444 ns/op
BenchmarkCreateClusterCatalog-10    	      12	 107088038 ns/op
BenchmarkCreateClusterCatalog-10    	       1	1003581583 ns/op
BenchmarkCreateClusterCatalog-10    	       3	 379469264 ns/op
BenchmarkCreateClusterCatalog-10    	       2	 606936271 ns/op
BenchmarkCreateClusterCatalog-10    	       1	2773485917 ns/op
PASS
ok  	github.com/operator-framework/operator-controller/test/e2e	34.115s
jiazha-mac:e2e jiazha$ go tool pprof mem.out 
File: e2e.test
Type: alloc_space
Time: Jan 27, 2025 at 5:22pm (CST)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 8433.33kB, 62.21% of 13555.35kB total
Showing top 10 nodes out of 126
      flat  flat%   sum%        cum   cum%
 1536.16kB 11.33% 11.33%  1536.16kB 11.33%  golang.org/x/net/http2.(*ClientConn).roundTrip
 1536.09kB 11.33% 22.66%  1536.09kB 11.33%  path.Join
 1184.27kB  8.74% 31.40%  1184.27kB  8.74%  runtime/pprof.StartCPUProfile
  902.59kB  6.66% 38.06%  1553.21kB 11.46%  compress/flate.NewWriter
  650.62kB  4.80% 42.86%   650.62kB  4.80%  compress/flate.(*compressor).init
  553.04kB  4.08% 46.94%   553.04kB  4.08%  github.com/gogo/protobuf/proto.RegisterType
  528.17kB  3.90% 50.84%   528.17kB  3.90%  regexp.(*bitState).reset
  516.01kB  3.81% 54.64%   516.01kB  3.81%  google.golang.org/protobuf/internal/filedesc.(*File).initDecls
  513.69kB  3.79% 58.43%   513.69kB  3.79%  regexp.mergeRuneSets.func2
  512.69kB  3.78% 62.21%   512.69kB  3.78%  regexp/syntax.(*compiler).inst
(pprof) exit
jiazha-mac:e2e jiazha$ go tool pprof cpu.out 
File: e2e.test
Type: cpu
Time: Jan 27, 2025 at 5:22pm (CST)
Duration: 33.19s, Total samples = 380ms ( 1.14%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 310ms, 81.58% of 380ms total
Showing top 10 nodes out of 154
      flat  flat%   sum%        cum   cum%
      90ms 23.68% 23.68%       90ms 23.68%  runtime.kevent
      50ms 13.16% 36.84%       50ms 13.16%  runtime.pthread_cond_signal
      50ms 13.16% 50.00%       50ms 13.16%  syscall.syscall
      40ms 10.53% 60.53%       40ms 10.53%  runtime.pthread_cond_wait
      30ms  7.89% 68.42%       60ms 15.79%  runtime.scanobject
      10ms  2.63% 71.05%       20ms  5.26%  k8s.io/client-go/rest.(*Request).tryThrottleWithInfo
      10ms  2.63% 73.68%       10ms  2.63%  runtime.(*itabTableType).find
      10ms  2.63% 76.32%       10ms  2.63%  runtime.(*mheap).allocSpan
      10ms  2.63% 78.95%       10ms  2.63%  runtime.(*mspan).heapBitsSmallForAddr
      10ms  2.63% 81.58%       10ms  2.63%  runtime.(*unwinder).resolveInternal
(pprof) exit

}

// GetRandomString generates a random string of the given length
func getRandomString(length int) string {
Copy link
Member

Choose a reason for hiding this comment

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

k8s.io/apimachinery has a rand.String function that can be used instead of us maintaining a separate implementation. https://pkg.go.dev/k8s.io/apimachinery/pkg/util/rand#String

"time"
)

func BenchmarkCreateClusterCatalog(b *testing.B) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this benchmark tells us a whole lot because it is mostly measuring:

  • client CPU/memory used to submit a CREATE request to the apiserver
  • client CPU/memory used to submit a DELETE request to the apiserver

But it notably isn't able to account for the resources or time spent by the controller to reconcile the ClusterCatalog, which I think is what we actually want to measure.

But regardless, in my mind the biggest open question in is NOT "what machinery do we use to take measurements?". The real question is "where/how do we store/retrieve historical measurements that we can use as a baseline for comparison?"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants