feat: refactor ratelimit to ratelimiter and improve BBR adaptive rate limiter#1672
Merged
feat: refactor ratelimit to ratelimiter and improve BBR adaptive rate limiter#1672
Conversation
… limiter - Rename `ratelimit` module to `ratelimiter` for clearer naming convention. - Refactor BBR rolling window to remove per-sample timestamps and rely on ring buffer eviction for expiration, simplifying `Sample` struct and `get_stats` logic. - Add `bucket_count` field and accessor to `RollingWindow` for use in estimated limit calculation. - Integrate `OverloadCollector` with container-aware CPU/memory sampling and background collection loop with graceful shutdown support. - Add `RequestGuard` RAII pattern for automatic metric recording and in-flight counter management. - Move container detection logic from `cpu.rs`/`memory.rs` cgroup methods up to `OverloadCollector`, removing redundant `is_running_in_container` checks in `get_cgroup_stats`. - Reduce CPU cgroup refresh interval from 1s to 500ms for more responsive overload detection. - Use `Self` constructor shorthand in `GC::new`. Signed-off-by: Gaius <gaius.qi@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1672 +/- ##
==========================================
- Coverage 50.83% 50.44% -0.39%
==========================================
Files 83 83
Lines 20029 20157 +128
==========================================
- Hits 10182 10169 -13
- Misses 9847 9988 +141
🚀 New features to boost your workflow:
|
CormickKneey
approved these changes
Feb 9, 2026
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.
ratelimitmodule toratelimiterfor clearer naming convention.Samplestruct andget_statslogic.bucket_countfield and accessor toRollingWindowfor use in estimated limit calculation.OverloadCollectorwith container-aware CPU/memory sampling and background collection loop with graceful shutdown support.RequestGuardRAII pattern for automatic metric recording and in-flight counter management.cpu.rs/memory.rscgroup methods up toOverloadCollector, removing redundantis_running_in_containerchecks inget_cgroup_stats.Selfconstructor shorthand inGC::new.Description
This pull request introduces several improvements and code cleanups across the
dragonfly-client-utilanddragonfly-clientcrates. The most significant changes involve renaming a module for clarity, optimizing CPU refresh intervals, and simplifying cgroup resource checks for CPU and memory statistics.Module renaming and code cleanup:
ratelimitmodule toratelimiterindragonfly-client-util/src/lib.rsfor consistency and clarity.Resource statistics logic simplification:
is_running_in_container) from cgroup CPU and memory statistics retrieval, allowing stats to be fetched regardless of container status indragonfly-client-util/src/sysinfo/cpu.rsanddragonfly-client-util/src/sysinfo/memory.rs. [1] [2]Performance improvements:
dragonfly-client-util/src/sysinfo/cpu.rsfor more frequent updates.Minor code style improvements:
dragonfly-client/src/gc/mod.rsto useSelfinstead of explicit struct name for idiomatic Rust style.Related Issue
Motivation and Context
Screenshots (if appropriate)