[v17] Refactor cache to support storing resources in memory#54799
Merged
rosstimothy merged 1 commit intobranch/v17from Jun 25, 2025
Merged
[v17] Refactor cache to support storing resources in memory#54799rosstimothy merged 1 commit intobranch/v17from
rosstimothy merged 1 commit intobranch/v17from
Conversation
9ed462e to
1c8843e
Compare
kiosion
approved these changes
May 15, 2025
Contributor
Author
|
Friendly ping @espadolini @fspmarshall. I believe that we're going to have our first attempt to backport a new cache collection to a release branch with #55807. |
espadolini
approved these changes
Jun 24, 2025
fspmarshall
approved these changes
Jun 24, 2025
While the current cache storage is also in memory, it leverages the memory backend which requires converting resources to and from json. Marshaling json is suboptimal and is often a source of CPU and memory consumption. The biggest problem with json marshaling though is that it requires calling CheckAndSetDefaults. When validations enforced in CASD become stricter it can leave caches unable to become healthy when there are mixed versions within a cluster as they all might have a slightly different view of what should be allowed. As a means to solve both problems, this changes the cache to store resources received from the upstream directly in memory without doing any conversion to json. There are two gotchas with this approach, caching is no longer "free" and cloning of resources must be done diligently to avoid races. Historically the cache relied on the storage implementation in services/local to manage persisting resources in the cache's backend.Memory. However, that will no longer be the case as the cache needs to support storage directly in memory. In order to reduce the burden this may pose on developers the new collection machinery is simpler, and helpers will be added on top of sortcache.SortCache to make a second storage implementation trivial. The changes here mark the existing collections machinery as legacy and introduce new machinery to operate entirely in memory. The only resources converted over are AccessRequests and HeadlessAuthentication.
1c8843e to
b622f47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports #52210, #54637, and #54499 branch/v17