[v11] Improve performance of ListResources#23597
Merged
rosstimothy merged 1 commit intobranch/v11from Mar 28, 2023
Merged
Conversation
51caf66 to
2d03b2e
Compare
* Add benchmark for ListNodes * Move RBAC logging to trace level BenchmarkListNodes is twice as slow when RBAC logging is enabled. By switching RBAC logging from debug to trace we can eliminate the performance hit while still providing a way for users to opt in to the behavior if they need to debug RBAC. * Intern compiled regular expressions Profiles of the benchmark test revealed that the `regexp.Compile` done within `utils.matchString` was the most cpu and memory intensive portion of the tests. By leveraging a `lru.Cache` to intern the compiled regular expressions we get quite a performance improvement. * Only fetch a single page of resources Increases the request limit prior to loading the resources from the cache so that we load enough items in a single page to determine the start key of the next page. * Remove version checking from `services.UnmarshalServer` Unmarshal directly to a `types.ServerV2` instead of first creating a `types.ResourceHeader` to inspect the version. There is only a single version for `types.ServerV2` making the check unnecessary. * Add `GetLabel` to `types.ResourceWithLables` `GetAllLabels` can be overkill if one simply needs to look up the value for a particular label. It creates a new `map[string]string` and copies all of a resources existing labels. RBAC decisions driven by labels incurred the penalty of the copy each time access was checked. The impact of the copy is much more noticeable when a resource has several labels or really long strings in the key or value. By leveraging `GetLabel` RBAC can avoid copying the labels altogether and simply lookup each label key when required.
2d03b2e to
54ed1e7
Compare
zmb3
approved these changes
Mar 27, 2023
strideynet
approved these changes
Mar 28, 2023
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.
Backport #23534 to branch/v11