Skip to content

Comments

benchmark(endpoint): endpoint benchmarks#6156

Merged
k8s-ci-robot merged 5 commits intokubernetes-sigs:masterfrom
gofogo:benchmark-endpoint-desc
Feb 12, 2026
Merged

benchmark(endpoint): endpoint benchmarks#6156
k8s-ci-robot merged 5 commits intokubernetes-sigs:masterfrom
gofogo:benchmark-endpoint-desc

Conversation

@ivankatliarchuk
Copy link
Member

@ivankatliarchuk ivankatliarchuk commented Jan 31, 2026

What does it do ?

Benchmark tests, full version here gofogo#62

The tests mimics our use case. In theory, the slice should be faster on smallet sets of properites, due to map hashing overhead and slice byt-by-byte comparison, same time technically there are all sorts of overhead

Motivation

This work related to #5814

Basically just adding benchamakrs for future. I think it is worth to keep it in the repo. And in follow-up we have baseline tests for comparison Slice vs Map

More

  • Yes, this PR title follows Conventional Commits
  • Yes, I added unit tests
  • Yes, I updated end user documentation accordingly
RandomAccess (GetProviderSpecificProperty)

Per-endpoint cost (ns/op divided by endpoint count, looking at 100k row):
  ┌────────────────┬─────────────┬───────────────────┐
  │ Properties set │ ns/endpoint │ Relative to set=0 │
  ├────────────────┼─────────────┼───────────────────┤
  │ 0              │ ~7.4 ns     │ 1.0x              │
  ├────────────────┼─────────────┼───────────────────┤
  │ 1              │ ~8.6 ns     │ 1.2x              │
  ├────────────────┼─────────────┼───────────────────┤
  │ 5              │ ~17.8 ns    │ 2.4x              │
  ├────────────────┼─────────────┼───────────────────┤
  │ 9              │ ~23.5 ns    │ 3.2x              │
  ├────────────────┼─────────────┼───────────────────┤
  │ 16             │ ~29.8 ns    │ 4.0x              │
  └────────────────┴─────────────┴───────────────────┘
  The cost scales linearly with the number of properties set — expected for a slice scan. At 16 properties the per-endpoint cost is ~4x that of an empty slice, which is the
  O(n) linear search behavior.
Delete (DeleteProviderSpecificProperty)

  1 allocation per iteration — the copy(endpoints, template) slice allocation. The delete operation itself is allocation-free (in-place slice manipulation).

  Per-endpoint cost (at 50k endpoints):
  ┌────────────────┬─────────────┬─────────────────────┐
  │ Properties set │ ns/endpoint │ Relative to props=0 │
  ├────────────────┼─────────────┼─────────────────────┤
  │ 0              │ ~5.8 ns     │ 1.0x                │
  ├────────────────┼─────────────┼─────────────────────┤
  │ 5              │ ~11.5 ns    │ 2.0x                │
  ├────────────────┼─────────────┼─────────────────────┤
  │ 10             │ ~15.9 ns    │ 2.8x                │
  └────────────────┴─────────────┴─────────────────────┘
  Same linear scan pattern — deleting from a longer slice costs proportionally more.
RandomAccess (GetProviderSpecificProperty)

ns per endpoint at each endpoint count:
  ┌───────────┬───────┬───────┬───────┬───────┬────────┐
  │ Endpoints │ set=0 │ set=1 │ set=5 │ set=9 │ set=16 │
  ├───────────┼───────┼───────┼───────┼───────┼────────┤
  │ 100       │ 6.7   │ 7.9   │ 15.0  │ 18.7  │ 24.4   │
  ├───────────┼───────┼───────┼───────┼───────┼────────┤
  │ 1,000     │ 6.7   │ 7.9   │ 15.0  │ 18.7  │ 24.5   │
  ├───────────┼───────┼───────┼───────┼───────┼────────┤
  │ 10,000    │ 6.8   │ 8.0   │ 15.1  │ 19.2  │ 25.3   │
  ├───────────┼───────┼───────┼───────┼───────┼────────┤
  │ 50,000    │ 7.1   │ 8.3   │ 16.1  │ 21.6  │ 28.1   │
  ├───────────┼───────┼───────┼───────┼───────┼────────┤
  │ 100,000   │ 7.4   │ 8.6   │ 17.8  │ 23.5  │ 29.8   │
  ├───────────┼───────┼───────┼───────┼───────┼────────┤
  │ 200,000   │ 9.4   │ 10.2  │ 19.5  │ 25.1  │ 30.2   │
  └───────────┴───────┴───────┴───────┴───────┴────────┘
  At small counts (100–10k), per-endpoint cost is flat — the working set fits in L1/L2 cache. Starting at ~50k endpoints, per-endpoint cost rises 20-40% depending on
  property count. At 200k with set=0, it's 9.4 ns vs 6.7 ns at 100 — a ~40% regression. This is cache pressure: the endpoint slice exceeds L2 cache and we start paying for L3/main memory latency.
Delete (DeleteProviderSpecificProperty)

 Delete — scaling by endpoint count

  ns per endpoint at each endpoint count:
  ┌───────────┬─────────┬─────────┬──────────┐
  │ Endpoints │ props=0 │ props=5 │ props=10 │
  ├───────────┼─────────┼─────────┼──────────┤
  │ 100       │ 6.4     │ 10.9    │ 13.6     │
  ├───────────┼─────────┼─────────┼──────────┤
  │ 300       │ 5.8     │ 10.7    │ 13.9     │
  ├───────────┼─────────┼─────────┼──────────┤
  │ 1,000     │ 5.7     │ 10.4    │ 14.0     │
  ├───────────┼─────────┼─────────┼──────────┤
  │ 10,000    │ 5.6     │ 10.0    │ 13.5     │
  ├───────────┼─────────┼─────────┼──────────┤
  │ 50,000    │ 5.8     │ 11.5    │ 15.9     │
  └───────────┴─────────┴─────────┴──────────┘
  Delete shows a flatter profile than random access. The per-endpoint cost barely changes from 100 to 50k. This is likely because the copy(endpoints, template) at the start
  of each iteration "warms" the cache — the sequential copy prefetches the memory that the subsequent delete loop will access.

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@k8s-ci-robot k8s-ci-robot added the internal Issues or PRs related to internal code label Jan 31, 2026
@k8s-ci-robot k8s-ci-robot requested review from szuecs and vflaux January 31, 2026 09:36
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 31, 2026
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk ivankatliarchuk force-pushed the benchmark-endpoint-desc branch from a0abe83 to 1bf3e63 Compare January 31, 2026 09:38
@ivankatliarchuk ivankatliarchuk marked this pull request as draft January 31, 2026 09:39
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 31, 2026
@coveralls
Copy link

coveralls commented Jan 31, 2026

Pull Request Test Coverage Report for Build 21543315090

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 79.177%

Totals Coverage Status
Change from base Build 21510752750: 0.0%
Covered Lines: 16061
Relevant Lines: 20285

💛 - Coveralls

@ivankatliarchuk ivankatliarchuk force-pushed the benchmark-endpoint-desc branch 5 times, most recently from 3020f8a to ad5334f Compare January 31, 2026 09:50
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk ivankatliarchuk force-pushed the benchmark-endpoint-desc branch from ad5334f to 850eef4 Compare January 31, 2026 09:57
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk ivankatliarchuk changed the title benchmark(endpoint): write benchmark tests for properties benchmark(endpoint): endpoint benchmark, cover empty cases for current slice Jan 31, 2026
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk ivankatliarchuk marked this pull request as ready for review January 31, 2026 10:49
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 31, 2026
@ivankatliarchuk ivankatliarchuk changed the title benchmark(endpoint): endpoint benchmark, cover empty cases for current slice benchmark(endpoint): endpoint benchmarks Feb 1, 2026
for _, setProps := range setPropsOptions {
for _, epCount := range endpointCounts {
endpoints := generateBenchmarkEndpoints(epCount, setProps)
b.Run(fmt.Sprintf("slice/set=%d/endpoints=%d", setProps, epCount), func(b *testing.B) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should not we add here a b.ResetTimer() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could add, but does not look where or not is required. Let me know, if you still this is required, I'll add it for extra protection.

The generateBenchmarkEndpoints call on line 79 is outside the b.Run sub-benchmark. Each sub-benchmark gets its own b with its own timer that starts when b.Run's function begins - so the setup cost of generateBenchmarkEndpoints is not measured.

Contrast with BenchmarkProviderSpecificDelete (line 106-107): there, generateBenchmarkEndpoints is called inside b.Run, so b.ResetTimer() is used to exclude that setup from the measurement.

@szuecs
Copy link
Contributor

szuecs commented Feb 12, 2026

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 12, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: szuecs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 12, 2026
@k8s-ci-robot k8s-ci-robot merged commit 847af6a into kubernetes-sigs:master Feb 12, 2026
18 checks passed
@ivankatliarchuk ivankatliarchuk deleted the benchmark-endpoint-desc branch February 12, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. internal Issues or PRs related to internal code lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants