-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add DeepEquals generated code #11435
Conversation
Please set the appropriate release note label. |
Commit ccb77b6a40bf494b049a515bbb44b530d223154c does not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
Please set the appropriate release note label. |
61b629a
to
2a0db53
Compare
Commit ccb77b6a40bf494b049a515bbb44b530d223154c does not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
2a0db53
to
540476e
Compare
test-me-please |
540476e
to
1cab767
Compare
test-me-please |
1cab767
to
af84424
Compare
test-me-please |
af84424
to
8a5a586
Compare
test-me-please |
8a5a586
to
2df1a56
Compare
test-me-please |
e2a3ada
to
0b62d22
Compare
test-me-please |
retest-runtime |
retest-runtime |
0b62d22
to
0cb36ab
Compare
test-me-please |
0cb36ab
to
babc8ff
Compare
test-me-please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff! One question inline, one GH issue to create.
@@ -33,6 +33,25 @@ type CIDR struct { | |||
*net.IPNet | |||
} | |||
|
|||
func (in *CIDR) DeepEqual(other *CIDR) bool { | |||
if other == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also check for in
being nil here (Like in CiliumNetworkPolicy
below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's up to the caller to check for the receiver to be nil.
pkg/policy/api/selector.go
Outdated
case (in == nil) && (other == nil): | ||
return true | ||
} | ||
// Once k8s upstream library supports DeepEqual we can remove this reflect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have a gh issue tracking that.
babc8ff
to
61e3eb7
Compare
test-me-please |
61e3eb7
to
7721d00
Compare
test-me-please |
a4630ab
to
17d6403
Compare
test-me-please |
Signed-off-by: André Martins <[email protected]>
Not relying on reflect.DeepEquals improves the DeepEqual performance logic a lot. As an example, a benchmark was written for SpecEquals and this commit was able to reduce the number of allocations and bytes per operation to 0. ``` BenchmarkSpecEquals/Reflected_SpecEquals-8 98300 12325 ns/op 3117 B/op 68 allocs/op BenchmarkSpecEquals/Generated_SpecEquals-8 2628786 452 ns/op 0 B/op 0 allocs/op ``` Unfortunately the api/v1/models markers had to be put manually. Signed-off-by: André Martins <[email protected]>
This commit uses the deepqual code generated in the previous code. Signed-off-by: André Martins <[email protected]>
17d6403
to
609bdcc
Compare
test-me-please |
retest-net-next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Not relying on reflect.DeepEquals improves the DeepEqual performance
logic a lot. As an example, a benchmark was written for SpecEquals and
this commit was able to reduce the number of allocations and bytes per
operation to 0.
Note for reviewers: I had this sitting on my side for a while, I didn't submitted because of k8s structures but since we now control the k8s structures we can use these generated methods in our advantage.