LAC: smoothing tokens request and keep in high level (#10997) - #11015
LAC: smoothing tokens request and keep in high level (#10997)#11015ti-chi-bot wants to merge 3 commits into
Conversation
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
|
This cherry pick PR is for a release branch and has not yet been approved by triage owners. To merge this cherry pick:
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@JaySon-Huang This PR has conflicts, I have hold it. |
|
@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesResource-group token refill
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant LocalAdmissionController
participant ResourceGroup
participant TokenBucket
participant GAC
LocalAdmissionController->>ResourceGroup: check refill eligibility
ResourceGroup->>TokenBucket: read capacity and token state
LocalAdmissionController->>GAC: request refill tokens
GAC-->>LocalAdmissionController: return capacity
LocalAdmissionController->>ResourceGroup: record GAC capacity
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
dbms/src/Flash/ResourceControl/LocalAdmissionController.h (1)
185-189: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse DB numeric aliases in the new public interfaces.
Use
Float64andUInt32in these declarations and matching definitions.
dbms/src/Flash/ResourceControl/LocalAdmissionController.h#L185-L189: replace newdoubleanduint32_tAPI types withFloat64andUInt32.dbms/src/Flash/ResourceControl/TokenBucket.h#L97-L97: returnFloat64fromgetCapacity().dbms/src/Flash/ResourceControl/LocalAdmissionController.cpp#L153-L171: match the updatedFloat64andUInt32declaration types.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@dbms/src/Flash/ResourceControl/LocalAdmissionController.h` around lines 185 - 189, Replace the new public numeric types in LocalAdmissionController.h#L185-L189 with Float64 and UInt32, update the matching definitions in LocalAdmissionController.cpp#L153-L171, and change TokenBucket.h#L97 getCapacity() to return Float64. Ensure all declarations and definitions remain type-consistent.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@dbms/src/Flash/ResourceControl/LocalAdmissionController.cpp`:
- Around line 460-468: Resolve the conflict in the affected loop by removing all
merge markers and retaining the local-branch `iter` and
`local_low_token_resource_groups` symbols. Update `need_fetch_token` to also
include `iter.second->shouldRefillToken(current_tick)`, while keeping
`need_report` based on `iter.second->shouldReportRUConsumption(current_tick)`.
In `@dbms/src/Flash/ResourceControl/tests/gtest_local_admission_controller.cpp`:
- Around line 98-100: Update the affected tests to match the available
resource-group API: remove the keyspace_id assertion from the GACRequestInfo
checks, and construct ResourceGroup using the existing
resource_manager::ResourceGroup plus SteadyClock::time_point constructor instead
of the unsupported NullspaceID overload.
---
Nitpick comments:
In `@dbms/src/Flash/ResourceControl/LocalAdmissionController.h`:
- Around line 185-189: Replace the new public numeric types in
LocalAdmissionController.h#L185-L189 with Float64 and UInt32, update the
matching definitions in LocalAdmissionController.cpp#L153-L171, and change
TokenBucket.h#L97 getCapacity() to return Float64. Ensure all declarations and
definitions remain type-consistent.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 93af541b-c6a0-4c15-a4aa-4925176796aa
📒 Files selected for processing (4)
dbms/src/Flash/ResourceControl/LocalAdmissionController.cppdbms/src/Flash/ResourceControl/LocalAdmissionController.hdbms/src/Flash/ResourceControl/TokenBucket.hdbms/src/Flash/ResourceControl/tests/gtest_local_admission_controller.cpp
Keep the release-8.5 LAC API while retaining shouldRefillToken, and adapt the new unit tests away from master keyspace-only helpers.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Cherry-pick conflicts appear resolved; removing the |
Signed-off-by: JaySon-Huang <tshent@qq.com>
|
/test pull-integration-test |
This is an automated cherry-pick of #10997
What problem does this PR solve?
Issue Number: close #10996
Summary
This change improves TiFlash Local Admission Controller token refill behavior to keep the local token bucket near a high watermark without requesting a large amount of tokens in a single GAC request.
Problem
The previous acquire calculation was based only on predicted consumption:
When the smoothed consumption speed was underestimated, a small positive token balance could make
acquire_tokenszero. The local balance would then remain low and could be exhausted by a traffic burst, causing unexpected throttling.Always refilling directly to the full bucket capacity would avoid this problem, but could transfer and retain too many tokens in TiFlash at once, reducing the tokens available to other clients such as TiDB.
Changes
fill_rateis used as the local high watermark.has_gac_capacitystate to distinguish the global Resource Group burst limit from the capacity assigned to the local client.TokenBucket::getCapacity()accessor.Resulting Behavior
##Test

During bench tpch workload, after acquire tokens from GAC, the
remaining_tokenskeeps close to the high watermark.Check List
Tests
Side effects
Documentation
Release note
Summary by CodeRabbit
Improvements
Tests