Skip to content

resourcecontrol: settle batched cop tasks' execution details#2029

Draft
0xPoe wants to merge 1 commit into
tikv:masterfrom
0xPoe:poe-batched-cop-ru
Draft

resourcecontrol: settle batched cop tasks' execution details#2029
0xPoe wants to merge 1 commit into
tikv:masterfrom
0xPoe:poe-batched-cop-ru

Conversation

@0xPoe

@0xPoe 0xPoe commented Jul 23, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

MakeResponseInfo reads only the top-level execution details of a coprocessor response. A batched request (StoreBatchTasks, used by TiDB's store batching) answers several tasks in one response, and each batch response carries its own task's scan detail and process time. Those nested details are invisible to resource control settlement, so resource groups and RU-based runaway detection undercount the read bytes and KV CPU of every batched cop task.

What is changed and how does it work?

  • Sum every batch response's execution details into the ResponseInfo: read bytes from each batch response's scan detail (falling back to its data size when it carries no scan detail), and KV CPU from its time detail.
  • Extract the NextGen/legacy read-bytes selection into scanDetailReadBytes and reuse it for the top-level and the batch responses' details.

The accounting is shape-agnostic: it settles batch responses that carry data as well as ones that carry only execution details.

Note for reviewers: this corrects accounted RU upward for workloads using store batching, to the value unbatched execution of the same tasks would settle. If that increase needs gating (a config switch, or NextGen-only like the TotalVersionsSize precedent), I am happy to add it.

Tests

  • New unit test TestResponseInfoBatchedTasks covering batch responses with data+details, details only, and data only.

MakeResponseInfo read only the top-level execution details of a
coprocessor response, but a batched request (StoreBatchTasks) answers
several tasks in one response, each batch response carrying its own
task's scan detail and process time. Those details were invisible to
settlement, so resource groups and RU-based runaway detection
undercounted the read bytes and CPU of every batched cop task. Sum
every batch response's details (falling back to its data size when it
carries no scan detail) into the response info.

This corrects accounted RU upward for workloads that use store
batching, to the value unbatched execution of the same tasks would
have settled.

Signed-off-by: 0xPoe <poe.liu@pm.me>
@ti-chi-bot

ti-chi-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. labels Jul 23, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tennyzhuang for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3fbe463f-ac82-4c52-82e7-44f2257ce748

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot ti-chi-bot Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant