tikv / tikv/pd

client/resource_group: expose RU v1 calculation details

Open
#11,178 0 comments 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Go
Stars
1.2k
Forks
783
Avg merge
5d 21h
Merged PRs (30d)
36

Description

## Enhancement Task

TiDB currently reports the total RU consumed by a statement, but RU v1 users cannot inspect the request inputs and effective factors that produced it. This is the PD-side work for pingcap/tidb#70251.

The PD resource controller owns the authoritative RU calculation and effective configuration. Expose an optional request-scoped calculation detail from the existing KVCalculator path containing:

- the dynamic inputs used by the RU v1 calculation;
- the effective factor snapshot;
- the actual RRU and WRU results.

Downstream consumers can format these inputs as a formula and independently compare the result with the authoritative RRU and WRU values.

Requirements:

- Keep existing ResourceGroupKVInterceptor signatures unchanged.
- Preserve token accounting, limiting behavior, and RU v2 behavior.
- Avoid per-request string formatting and collection unless explicitly requested.
- Cover read, write, retry, failed-write payback, replica weighting, and paging settlement paths.

Related work:

- TiDB issue: https://github.com/pingcap/tidb/issues/70251
- PD implementation: https://github.com/tikv/pd/pull/11165
- client-go integration: https://github.com/tikv/client-go/pull/2046
- TiDB integration: https://github.com/pingcap/tidb/pull/70543

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing KVCalculator path and ResourceGroupKVInterceptor, then compare the referenced PD implementation and client-go integration. Done means an optional request-scoped detail exposes the calculation inputs, effective factors, and RRU/WRU results while preserving existing signatures, accounting, limiting, RU v2 behavior, and the listed settlement paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.