resource_group: set FillRate in non-trickle token bucket responses#10322
resource_group: set FillRate in non-trickle token bucket responses#10322JmPotato wants to merge 1 commit intotikv:masterfrom
Conversation
When the server grants tokens in non-trickle mode (capacity sufficient), the response previously carried FillRate=0. This caused the client limiter to have fillRate=0, making durationFromTokens() return InfDuration after the granted tokens were depleted, resulting in ~1s latency spikes. Set FillRate on all three non-trickle return paths in the server: 1. No-slot path in request() — initial periodic report with no slot yet 2. requiredToken<=0 path in assignSlotTokens() — zero-demand requests 3. Full-satisfy path in assignSlotTokens() — capacity covers demand Trickle paths are intentionally left unchanged to avoid double-counting with the client's own trickle-based fill rate calculation. Close tikv#10251 Signed-off-by: JmPotato <github@ipotato.me>
|
[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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe pull request ensures Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
@JmPotato: The following tests failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: Close #10251
When the resource group FillRate is much larger than actual consumption (e.g., FillRate=1,000,000 vs consumption≈200 RU/s), requests experience ~1s latency spikes.
Root cause: The server's
request()andassignSlotTokens()never setFillRatein non-trickle responses. The client'smodifyTokenCounterusescfg.newFillRate = float64(bucket.GetSettings().FillRate), which gets 0. After the granted tokens are depleted,durationFromTokens()returnsInfDuration, causing all subsequentOnRequestWaitcalls to fail withErrClientResourceGroupThrottledorcontext.DeadlineExceeded.What is changed and how does it work?
Set
FillRateon all three non-trickle return paths in the server so the client limiter can refill tokens locally:request()— when the slot doesn't exist (initial periodic report withrequiredToken=0), returnFillRate = gtb.getFillRate()(group-level fill rate).requiredToken<=0path inassignSlotTokens()— when the slot exists but no tokens are requested, returnFillRate = ts.fillRate(per-slot fill rate).assignSlotTokens()— when the slot has enough capacity to fully satisfy the request, returnFillRate = ts.fillRate(per-slot fill rate).Trickle paths are intentionally left unchanged to avoid double-counting with the client's own trickle-based fill rate calculation (
cfg.newFillRate = FillRate + granted/trickleTime).Check List
Tests
Code changes
Side effects
Release note
Summary by CodeRabbit
Bug Fixes