resourcecontrol: add PredictedReadBytes hint to RequestInfo#1944
resourcecontrol: add PredictedReadBytes hint to RequestInfo#1944YuhaoZhang00 wants to merge 4 commits intotikv:masterfrom
Conversation
Extract PagingSizeBytes from coprocessor requests and expose it via the RequestInfo interface. This enables the PD resource controller to pre-charge byte-budget RU in Phase 1 for RC paging. Also adds RU v2 TiKV-side weight calculation, TiFlash RU tracking, stale bucket metrics, and region cache improvements. Signed-off-by: JmPotato <github@ipotato.me>
Signed-off-by: JmPotato <github@ipotato.me>
Signed-off-by: JmPotato <github@ipotato.me>
Add a client-go-internal PredictedReadBytes field on tikvrpc.Request so the caller (e.g. TiDB, maintaining a per-logical-scan EMA across paging cop RPCs) can supply a learned estimate of how many bytes the request will read. MakeRequestInfo propagates this into RequestInfo, and the new RequestInfo.PredictedReadBytes() getter satisfies the optional predictedReadBytesProvider interface that PD's resource_group/controller checks via type assertion. When the hint is > 0, PD uses it as the byte basis for RC paging pre-charge, overriding PagingSizeBytes (which remains the worst-case cap and the fallback for cold-start / unset hint cases). The field is kept out of the proto because it is purely a client-side estimate consumed before the RPC is sent - TiKV neither needs nor reads it. Signed-off-by: Yuhao Zhang <yhzhang00@outlook.com>
|
[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 |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
Summary
Add a client-go-internal
PredictedReadBytesfield ontikvrpc.Requestsothe caller (e.g. TiDB, maintaining a per-logical-scan EMA across paging cop
RPCs) can supply a learned estimate of how many bytes the request will
read.
MakeRequestInfopropagates this intoRequestInfo, and the newRequestInfo.PredictedReadBytes()getter satisfies the optionalpredictedReadBytesProviderinterface that PD's resource_group/controllerchecks via type assertion.
The field is kept out of kvproto because it is purely a client-side
estimate consumed before the RPC is sent — TiKV neither needs nor reads it.
Why
This hint lets PD replace the current fixed 4 MiB paging pre-charge with a
learned estimate, without changing kvproto or TiKV behavior. See the PD
companion PR for the consumer-side logic.
Status
Draft. Part of a stacked change:
tikv/pd#10599: consumes the hint inBeforeKVRequest/AfterKVRequestpingcap/tidb: produces the hint from a per-scan TAEMA maintained oncopTaskNot yet ready for review; e2e validation on the simulation cluster is pending.
Test plan
internal/resourcecontrol/resource_control_test.go