Skip to content

Fix performance of tracing rate limiter#1530

Open
sergeymatov wants to merge 2 commits into
mainfrom
pr/smatov/rate-limit-recover
Open

Fix performance of tracing rate limiter#1530
sergeymatov wants to merge 2 commits into
mainfrom
pr/smatov/rate-limit-recover

Conversation

@sergeymatov
Copy link
Copy Markdown
Contributor

@sergeymatov sergeymatov commented May 12, 2026

Move to own atomic operations for per-level filter for callsites. Reloading of interest is done via ArcSwap rather then RwLock

Copilot AI review requested due to automatic review settings May 12, 2026 11:47
@sergeymatov sergeymatov requested a review from a team as a code owner May 12, 2026 11:47
@sergeymatov sergeymatov requested review from daniel-noland and removed request for a team May 12, 2026 11:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces configurable rate limiting for tracing output by adding a tracing-throttle-based layer to tracectl, wiring it into dataplane startup, and exposing configuration via a new CLI argument in args.

Changes:

  • Add TracingRateLimitConfig / TracingControl::init_with_rate_limit() and initialize tracing with optional rate limiting.
  • Add --tracing-rate-limit BURST:REPLENISH_PER_SECOND parsing and propagate it into the launch configuration.
  • Add the tracing-throttle dependency to the workspace and tracectl.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tracectl/src/lib.rs Re-exports rate-limit config type from control.
tracectl/src/control.rs Adds rate-limit config + subscriber initialization changes, including throttling logic and tests.
tracectl/Cargo.toml Adds tracing-throttle dependency.
dataplane/src/main.rs Initializes tracing with optional rate limit from CLI args; adjusts default log level behavior.
Cargo.toml Adds tracing-throttle to workspace dependencies.
Cargo.lock Locks new tracing-throttle transitive dependency.
args/src/lib.rs Adds TracingRateLimit type, CLI parsing/help, and config propagation + tests.

Comment thread tracectl/src/control.rs
Comment on lines +319 to +337
// `DEBUG` level remains unthrottled if we assume that it is the most verbose level
// that users would want to enable while digging into particular issues.
fn unthrottled_level_filter<S>() -> impl Filter<S> + Send + Sync
where
S: Subscriber + for<'span> LookupSpan<'span>,
{
filter_fn(|meta| matches!(*meta.level(), Level::DEBUG))
}

fn throttled_level_filter<S>() -> impl Filter<S> + Send + Sync
where
S: Subscriber + for<'span> LookupSpan<'span>,
{
filter_fn(|meta| {
matches!(
*meta.level(),
Level::INFO | Level::TRACE | Level::ERROR | Level::WARN
)
})
Comment thread tracectl/src/control.rs
Comment on lines +319 to +320
// `DEBUG` level remains unthrottled if we assume that it is the most verbose level
// that users would want to enable while digging into particular issues.
Comment thread args/src/lib.rs
long,
value_name = "BURST:REPLENISH_PER_SECOND",
value_parser=TracingRateLimit::from_str,
help = "Optional rate limit for lower-severity tracing output. Syntax: BURST:REPLENISH_PER_SECOND.
Comment thread Cargo.toml
tracing-error = { version = "0.2.1", default-features = false, features = [] }
tracing-subscriber = { version = "0.3.23", default-features = false, features = [] }
tracing-test = { version = "0.2.6", default-features = false, features = [] }
tracing-throttle = { version = "0.4.2", default-features = false, features = [] }
@sergeymatov sergeymatov force-pushed the pr/smatov/rate-limit-recover branch from 7f3a6a7 to 0814455 Compare May 12, 2026 16:14
@mvachhar mvachhar added the dont-merge Do not merge this Pull Request label May 12, 2026
@sergeymatov sergeymatov force-pushed the pr/smatov/rate-limit-recover branch from 0814455 to 0e90334 Compare May 13, 2026 08:13
@qmonnet qmonnet marked this pull request as draft May 13, 2026 08:19
@sergeymatov sergeymatov force-pushed the pr/smatov/rate-limit-recover branch 4 times, most recently from 81f0207 to 65ae6b0 Compare May 18, 2026 12:56
@sergeymatov sergeymatov marked this pull request as ready for review May 19, 2026 09:05
@sergeymatov sergeymatov force-pushed the pr/smatov/rate-limit-recover branch from 65ae6b0 to 510ff04 Compare May 19, 2026 09:08
This reverts commit 75f964b.

Signed-off-by: Sergey Matov <sergey.matov@githedgehog.com>
@sergeymatov sergeymatov force-pushed the pr/smatov/rate-limit-recover branch from 510ff04 to c7c6cb5 Compare May 19, 2026 09:09
@sergeymatov sergeymatov changed the title DONT MERGE!! TEST ONLY: Revert "revert: feat(logging): Add configurable rate limit for logging" Fix performance of tracing rate limiter May 19, 2026
@sergeymatov sergeymatov removed the dont-merge Do not merge this Pull Request label May 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Comment thread tracectl/src/control.rs
Comment on lines +420 to +438
// `DEBUG` level remains unthrottled if we assume that it is the most verbose level
// that users would want to enable while digging into particular issues.
fn unthrottled_level_filter<S>() -> impl Filter<S> + Send + Sync
where
S: Subscriber + for<'span> LookupSpan<'span>,
{
filter_fn(|meta| matches!(*meta.level(), Level::DEBUG))
}

fn throttled_level_filter<S>() -> impl Filter<S> + Send + Sync
where
S: Subscriber + for<'span> LookupSpan<'span>,
{
filter_fn(|meta| {
matches!(
*meta.level(),
Level::INFO | Level::TRACE | Level::ERROR | Level::WARN
)
})
Comment thread Cargo.toml
Comment on lines 183 to +188
tonic = { version = "0.14.6", default-features = false, features = [] }
tracing = { version = "0.1.44", default-features = false, features = [] }
tracing = { version = "0.1.44", default-features = false, features = ["release_max_level_debug"] }
tracing-error = { version = "0.2.1", default-features = false, features = [] }
tracing-subscriber = { version = "0.3.23", default-features = false, features = [] }
tracing-test = { version = "0.2.6", default-features = false, features = [] }
tracing-throttle = { version = "0.4.2", default-features = false, features = [] }
Comment thread args/src/lib.rs
Comment on lines +1321 to +1322
help = "Optional rate limit for lower-severity tracing output. Syntax: BURST:REPLENISH_PER_SECOND.
Example: --tracing-rate-limit 50:5 allows bursts up to 50 repeated messages and replenishes 5 messages per second.
@sergeymatov sergeymatov force-pushed the pr/smatov/rate-limit-recover branch 2 times, most recently from a2bc745 to dc1c83c Compare May 19, 2026 12:42
Avoid using RwLock to reduce complexity for EnvFilter.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Sergey Matov <sergey.matov@githedgehog.com>
@sergeymatov sergeymatov force-pushed the pr/smatov/rate-limit-recover branch from dc1c83c to 55a1289 Compare May 19, 2026 13:08
Comment thread tracectl/src/control.rs Outdated
layer::{Context, Filter, Layer},
prelude::*,
registry::LookupSpan,
reload,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package implicityl has the RwLock being referenced, but it is not obvious that this is the case. Can you please expand the commit message to explain where the removed RwLock was and what was done to remove it.

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.

3 participants