Skip to content
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

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

bsurber
Copy link
Contributor

@bsurber bsurber commented Dec 23, 2024

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

Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #37797 was opened by bsurber.

see: more, trace.

…th every instance of the rate_limit_quota filter

Signed-off-by: Brian Surber <[email protected]>
@bsurber bsurber force-pushed the fix-matcher-build-rlqs branch from c622a7d to bb9a277 Compare December 24, 2024 01:19
@bsurber bsurber marked this pull request as ready for review December 24, 2024 02:11
Copy link
Member

@tyxia tyxia left a 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_) {
Copy link
Member

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 {
Copy link
Member

@tyxia tyxia Dec 24, 2024

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

@tyxia tyxia self-assigned this Dec 27, 2024
@tyxia tyxia changed the title Fix matcher-tree creation happening per filter instance rlqs: Fix matcher-tree creation happening per filter instance Dec 27, 2024
@tyxia tyxia enabled auto-merge (squash) December 27, 2024 16:20
@tyxia tyxia removed the waiting label Dec 27, 2024
@tyxia
Copy link
Member

tyxia commented Dec 27, 2024

@bsurber I will merge this PR first, could you please address the those nit comments in a follow-up PR?

@tyxia tyxia merged commit 52e1e93 into envoyproxy:main Dec 27, 2024
24 checks passed
bsurber added a commit to bsurber/envoy that referenced this pull request Jan 2, 2025
bsurber added a commit to bsurber/envoy that referenced this pull request Jan 2, 2025
tyxia pushed a commit that referenced this pull request Jan 6, 2025
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance becomes very bad when we use xds matcher in http_filters.
2 participants