-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fqdn: clean up regex cache #40365
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
Merged
Merged
fqdn: clean up regex cache #40365
Conversation
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
/test |
tklauser
approved these changes
Jul 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice improvement!
Some very nit-picky comments inline.
aanm
approved these changes
Jul 4, 2025
HadrienPatte
approved these changes
Jul 4, 2025
/test |
giorio94
approved these changes
Jul 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm for the sig-agent changes.
Switch the regex cache to the maintained (and already imported) hashicorp/go-lru package. Initialize the cache in `init()`, rather than requiring every single test and binary to initialize it. One nice property of go-lru is that it doesn't initially allocate a buffer of the given size, so we don't need to restrict the size to 1 for one-off CLI programs. The default size is fine. This allows us to remove the initialization code from lots and lots and lots of unit tests. Hooray. Signed-off-by: Casey Callendrello <cdc@isovalent.com>
/test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kind/cleanup
This includes no functional changes.
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
release-note/misc
This PR makes changes that have no direct user impact.
sig/policy
Impacts whether traffic is allowed or denied based on user-defined policies.
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.
This code path has always annoyed me. It has led to bugs before such as #37355. We have a global singleton that needs explicit initialization, always a recipe for errors.
Switch the regex cache to the maintained (and already imported) hashicorp/go-lru package. Initialize the cache in
init()
, rather than requiring every single test and binary to initialize it.One nice property of go-lru is that it doesn't initially allocate a buffer of the given size, so we don't need to restrict the size to 1 for one-off CLI programs. The default size is fine.
This allows us to remove the initialization code from lots and lots and lots of unit tests. Hooray.