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

fqdn: Fix benchmarking for fqdn cache test #32276

Merged
merged 1 commit into from
May 13, 2024
Merged

Conversation

joestringer
Copy link
Member

@joestringer joestringer commented Apr 30, 2024

Requires: #32013

Rather than testing a number of iterations of the core update function
here, the test was varying the data input size. This was violating the
recommendations from the Go docs, which state:

The benchmark function must run the target code b.N times. During
benchmark execution, b.N is adjusted until the benchmark function
lasts long enough to be timed reliably.

This could lead to unreliable benchmarking numbers. Fix it.

Example run:

$ go test ./pkg/fqdn -bench BenchmarkFqdnCache
...
goos: linux
goarch: amd64
pkg: github.com/cilium/cilium/pkg/fqdn
cpu: 13th Gen Intel(R) Core(TM) i7-1365U
BenchmarkFqdnCache-12                100         110924076 ns/op
PASS
ok      github.com/cilium/cilium/pkg/fqdn       11.505s

@joestringer joestringer added release-note/ci This PR makes changes to the CI. area/fqdn Affects the FQDN policies feature labels Apr 30, 2024
@joestringer joestringer added the dont-merge/blocked Another PR must be merged before this one. label Apr 30, 2024
@joestringer joestringer force-pushed the pr/joe/fqdn-conn-timeouts branch 2 times, most recently from 4aedd54 to 795d80b Compare May 6, 2024 17:19
Base automatically changed from pr/joe/fqdn-conn-timeouts to main May 6, 2024 21:11
Rather than testing a number of iterations of the core update function
here, the test was varying the data input size. This was violating the
recommendations from the Go docs, which state:

    The benchmark function must run the target code b.N times. During
    benchmark execution, b.N is adjusted until the benchmark function
    lasts long enough to be timed reliably.

This could lead to unreliable benchmarking numbers. Fix it.

Example run:

    $ go test ./pkg/fqdn -bench BenchmarkFqdnCache
    ...
    goos: linux
    goarch: amd64
    pkg: github.com/cilium/cilium/pkg/fqdn
    cpu: 13th Gen Intel(R) Core(TM) i7-1365U
    BenchmarkFqdnCache-12                100         110924076 ns/op
    PASS
    ok      github.com/cilium/cilium/pkg/fqdn       11.505s

Suggested-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
Signed-off-by: Joe Stringer <joe@cilium.io>
@joestringer joestringer removed the dont-merge/blocked Another PR must be merged before this one. label May 9, 2024
@joestringer
Copy link
Member Author

/test

@joestringer joestringer marked this pull request as ready for review May 9, 2024 17:42
@joestringer joestringer requested a review from a team as a code owner May 9, 2024 17:42
@joestringer joestringer requested a review from doniacld May 9, 2024 17:42
@joestringer
Copy link
Member Author

btw this one may make sense to rebalance back to @pippolo84 since it was his suggestion, cc @doniacld

Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

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

Thanks! 💯

I've also pushed a similar PR for BenchmarkNotifyOnDNSMsg.

@joestringer joestringer added this pull request to the merge queue May 13, 2024
Merged via the queue into main with commit ae9036c May 13, 2024
269 of 270 checks passed
@joestringer joestringer deleted the pr/joe/fqdn-benchmark branch May 13, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/fqdn Affects the FQDN policies feature release-note/ci This PR makes changes to the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants