Skip to content

Disable StorageNamespaceIndex feature gate when BtreeWatchCache enabled and deprecate it#129933

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
serathius:deprecate-namespace-index
Feb 11, 2025
Merged

Disable StorageNamespaceIndex feature gate when BtreeWatchCache enabled and deprecate it#129933
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
serathius:deprecate-namespace-index

Conversation

@serathius
Copy link
Copy Markdown
Contributor

Previously, the cache used a map keyed by the full object key, requiring iteration and filtering by namespace for namespace-scoped requests. This index allowed for faster responses by avoiding this iteration.

With the introduction of the BtreeWatchCache, this optimization is no longer necessary. The B-tree structure allows efficient prefix-based searches, including fetching objects by namespace.
Furthermore, the B-tree returns elements ordered by key, eliminating the need for separate sorting.

Performance improvements with the BtreeWatchCache have been validated through benchmarks matching K8s scalability dimentions (see table below). These results demonstrate that the B-tree approach provides comparable or better performance than the map with index. Therefore, the StorageNamespaceIndex feature flag can be safely flipped to false and subsequently deprecated.

Benchmark Btree with Index (current) Btree without Index Map with Index Map without Index (sanity check)
StoreList (10k Namespaces, 150k Pods, 5k Nodes, RV=, Namespace Scope) 20.77µs ± 10% 20.14µs ± 13% (~0%) 19.73µs ± 6% (~0%) 1067.34µs ± 10% (+5037.73%)
StoreList (10k Namespaces, 150k Pods, 5k Nodes, RV=NotOlderThan, Namespace Scope) 3.943µs ± 6% 3.928µs ± 6% (~0%) 3.665µs ± 3% (-7.05%) 944.641µs ± 1% (+23857.41%)
StoreList (50 Namespaces, 150k Pods, 5k Nodes, RV=, Namespace Scope) 303.3µs ± 2% 258.2µs ± 2% (-14.85%) 340.1µs ± 3% (+12.15%) 1668.6µs ± 4% (+450.23%)
StoreList (50 Namespaces, 150k Pods, 5k Nodes, RV=NotOlderThan, Namespace Scope) 286.2µs ± 3% 234.7µs ± 1% (-17.99%) 326.9µs ± 2% (+14.22%) 1347.7µs ± 4% (+370.91%)
StoreList (100 Namespaces, 110k Pods, 1k Nodes, RV=, Namespace Scope) 125.3µs ± 2% 112.3µs ± 5% (-10.38%) 137.5µs ± 2% (+9.81%) 1395.1µs ± 8% (+1013.78%)
StoreList (100 Namespaces, 110k Pods, 1k Nodes, RV=NotOlderThan, Namespace Scope) 120.6µs ± 2% 113.2µs ± 1% (-6.13%) 133.8µs ± 1% (+10.92%) 1719.1µs ± 5% (+1325.35%)
Geometric Mean 68.94µs 62.73µs (-9.02%) 72.72µs (+5.48%) 1.326ms (+1823.40%)

/kind cleanup
Fixes #129189

Flip StorageNamespaceIndex feature gate to false and deprecate it

/assign @deads2k @jpbetz @wojtek-t

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jan 31, 2025
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Jan 31, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 31, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Jan 31, 2025
Comment thread pkg/features/versioned_kube_features.go Outdated
@serathius serathius force-pushed the deprecate-namespace-index branch from 5ede387 to 28adb5f Compare February 4, 2025 05:15
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. sig/node Categorizes an issue or PR as relevant to SIG Node. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 4, 2025
@serathius serathius force-pushed the deprecate-namespace-index branch from 28adb5f to 9eea5fc Compare February 4, 2025 05:17
@serathius serathius changed the title Flip StorageNamespaceIndex feature gate to false and deprecate it Disable StorageNamespaceIndex feature gate when BtreeWatchCache enabled and deprecate it Feb 4, 2025
@serathius serathius force-pushed the deprecate-namespace-index branch from 9eea5fc to fbcae06 Compare February 4, 2025 05:37
…abled and deprecate it

Previously, the cache used a map keyed by the full object key,
requiring iteration and filtering by namespace for namespace-scoped requests.
This index allowed for faster responses by avoiding this iteration.

With the introduction of the BtreeWatchCache, this optimization is no longer necessary.
The B-tree structure allows efficient prefix-based searches,
including fetching objects by namespace.
Furthermore, the B-tree returns elements ordered by key, eliminating the need for separate sorting.

Performance improvements with the BtreeWatchCache have been validated through benchmarks matching K8s scalability dimentions (see table below).
These results demonstrate that the B-tree approach provides comparable or better performance than the map with index.
Therefore, the StorageNamespaceIndex feature flag can be safely flipped to false and subsequently deprecated.

| Benchmark                                                                         | Btree with Index (current) | Btree without Index    | Map with Index         | Map without Index (sanity check) |
| --------------------------------------------------------------------------------- | -------------------------- | ---------------------- | ---------------------- | -------------------------------- |
| StoreList (10k Namespaces, 150k Pods, 5k Nodes, RV=, Namespace Scope)             | 20.77µs ± 10%              | 20.14µs ± 13% (~0%)    | 19.73µs ± 6% (~0%)     | 1067.34µs ± 10% (+5037.73%)      |
| StoreList (10k Namespaces, 150k Pods, 5k Nodes, RV=NotOlderThan, Namespace Scope) | 3.943µs ± 6%               | 3.928µs ± 6% (~0%)     | 3.665µs ± 3% (-7.05%)  | 944.641µs ± 1% (+23857.41%)      |
| StoreList (50 Namespaces, 150k Pods, 5k Nodes, RV=, Namespace Scope)              | 303.3µs ± 2%               | 258.2µs ± 2% (-14.85%) | 340.1µs ± 3% (+12.15%) | 1668.6µs ± 4% (+450.23%)         |
| StoreList (50 Namespaces, 150k Pods, 5k Nodes, RV=NotOlderThan, Namespace Scope)  | 286.2µs ± 3%               | 234.7µs ± 1% (-17.99%) | 326.9µs ± 2% (+14.22%) | 1347.7µs ± 4% (+370.91%)         |
| StoreList (100 Namespaces, 110k Pods, 1k Nodes, RV=, Namespace Scope)             | 125.3µs ± 2%               | 112.3µs ± 5% (-10.38%) | 137.5µs ± 2% (+9.81%)  | 1395.1µs ± 8% (+1013.78%)        |
| StoreList (100 Namespaces, 110k Pods, 1k Nodes, RV=NotOlderThan, Namespace Scope) | 120.6µs ± 2%               | 113.2µs ± 1% (-6.13%)  | 133.8µs ± 1% (+10.92%) | 1719.1µs ± 5% (+1325.35%)        |
| Geometric Mean                                                                    | 68.94µs                    | 62.73µs (-9.02%)       | 72.72µs (+5.48%)       | 1.326ms (+1823.40%)              |
@serathius serathius force-pushed the deprecate-namespace-index branch from fbcae06 to b1ad53c Compare February 5, 2025 09:49
@serathius
Copy link
Copy Markdown
Contributor Author

/retest

@MadhavJivrajani
Copy link
Copy Markdown
Contributor

/cc

@serathius
Copy link
Copy Markdown
Contributor Author

/cc @wojtek-t

@wojtek-t
Copy link
Copy Markdown
Member

/lgtm
/approve

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

LGTM label has been added.

DetailsGit tree hash: a838bfecbed8fd5873c59fa9afd6532ad0218109

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: serathius, wojtek-t

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 11, 2025
@k8s-ci-robot k8s-ci-robot merged commit 7a8a4c2 into kubernetes:master Feb 11, 2025
@k8s-ci-robot k8s-ci-robot added this to the v1.33 milestone Feb 11, 2025
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

Development

Successfully merging this pull request may close these issues.

Don't use namespace index when btree is enabled

7 participants