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

refactor: use plugin annotation types from kubernetes-configuration #6644

Merged
merged 4 commits into from
Nov 14, 2024

Conversation

pmalek
Copy link
Member

@pmalek pmalek commented Nov 8, 2024

What this PR does / why we need it:

This PR uses functions that interact with objects' plugin annotations from Kong/kubernetes-configuration#144.

Some of those introduce the usage of iterators using the iter package to prevent unnecessary allocations.

Benchmarks

go test -v -benchmem -bench BenchmarkGetPluginRelations -run ^$ -count 1 ./internal/dataplane/kongstate

Old

goos: darwin
goarch: arm64
pkg: github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/kongstate
cpu: Apple M1 Max
BenchmarkGetPluginRelations
BenchmarkGetPluginRelations-10            243942              4448 ns/op            6912 B/op         64 allocs/op
PASS
ok      github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/kongstate   1.762s

New

NOTE: the decrease in performance comes from using the interface that contains a method which returns a map vs passing just the map around like it was done previously. If the team feels this is not worth it we can change this back to previous approach. IMHO using the interface makes this more flexible and is worth the small decrease in performance.

Here's a proposal on how to optimize the functions themselves: Kong/kubernetes-configuration@d8803db

goos: darwin
goarch: arm64
pkg: github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/kongstate
cpu: Apple M1 Max
BenchmarkGetPluginRelations
BenchmarkGetPluginRelations-10            196657              5446 ns/op            9120 B/op         72 allocs/op
PASS
ok      github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/kongstate   1.849s

@pmalek pmalek added area/maintenance Cleanup, refactoring, and other maintenance improvements that don't change functionality. refactor labels Nov 8, 2024
@pmalek pmalek self-assigned this Nov 8, 2024
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.9%. Comparing base (9517268) to head (3ca92ab).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
internal/util/objectmeta.go 50.0% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #6644     +/-   ##
=======================================
+ Coverage   77.7%   78.9%   +1.1%     
=======================================
  Files        202     202             
  Lines      23758   23798     +40     
=======================================
+ Hits       18483   18794    +311     
+ Misses      4335    4052    -283     
- Partials     940     952     +12     

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

@pmalek pmalek force-pushed the kubernetes-configuration-plugins-funcs branch from aa91d31 to 8c7ae94 Compare November 13, 2024 08:59
@pmalek pmalek force-pushed the kubernetes-configuration-plugins-funcs branch from 8c7ae94 to 6bc1d31 Compare November 13, 2024 10:43
@pmalek pmalek marked this pull request as ready for review November 13, 2024 11:07
@pmalek pmalek requested a review from a team as a code owner November 13, 2024 11:07
Copy link
Contributor

@czeslavo czeslavo left a comment

Choose a reason for hiding this comment

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

IMHO using the interface makes this more flexible and is worth the small decrease in performance.

👍

pkg/apis/configuration/v1/kongconsumer_types.go Outdated Show resolved Hide resolved
pkg/apis/configuration/v1beta1/kongconsumergroup_types.go Outdated Show resolved Hide resolved
@pmalek pmalek requested a review from czeslavo November 13, 2024 14:40
@pmalek pmalek added this to the KIC v3.4.x milestone Nov 13, 2024
czeslavo
czeslavo previously approved these changes Nov 13, 2024
@czeslavo czeslavo merged commit 0a245bf into main Nov 14, 2024
42 checks passed
@czeslavo czeslavo deleted the kubernetes-configuration-plugins-funcs branch November 14, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/maintenance Cleanup, refactoring, and other maintenance improvements that don't change functionality. refactor size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants