-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
rlqs: Fix matcher-tree creation happening per filter instance #37797
Conversation
…th every instance of the rate_limit_quota filter Signed-off-by: Brian Surber <[email protected]>
c622a7d
to
bb9a277
Compare
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, modulo some nits.
/wait
if (callbacks_ != nullptr) { | ||
data_ptr_ = std::make_unique<Http::Matching::HttpMatchingDataImpl>(callbacks_->streamInfo()); | ||
} else { | ||
if (!data_ptr_) { |
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.
i actually prefer data_ptr == nullptr
style throughout this file. That is more readable for pointer type.
} | ||
|
||
return [&, config = std::move(config), config_with_hash_key, tls_store, | ||
matcher](Http::FilterChainFactoryCallbacks& callbacks) -> void { |
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.
for the matcher
shared pointer here, you only need to make copy (i.e., increase ref count once) once.
For example, in the RateLimitQuotaFilter constructor, it is passed by value which will achieve the need of copy above. Other places can just be move
@bsurber I will merge this PR first, could you please address the those nit comments in a follow-up PR? |
Signed-off-by: Brian Surber <[email protected]>
Signed-off-by: Brian Surber <[email protected]>
Commit Message: - Nit 1: Lambda capture for the RLQS filter factory callback should move shared_ptrs instead of copying. This only saves a shared_ptr copy op per var but is still good practice. - Nit 2: Replace instances of if-conditions `(!ptr)` / `(ptr)` with `(ptr == nullptr)` / `(ptr != nullptr)` to conform to existing code. Risk Level: minimal Testing: unit testing Docs Changes: Release Notes: Platform Specific Features: Fixes commit #37797 Signed-off-by: Brian Surber <[email protected]>
Commit Message: Move matcher-tree creation to config.cc so that it isn't recreated with every instance of the rate_limit_quota filter
Additional Description:
Risk Level:
Testing: Manual testing in-progress
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
Fixes #37534