Skip to content

txnkv: add readPoolTaskDetails to SnapshotRuntimeStats - #2025

Merged
ti-chi-bot[bot] merged 1 commit into
tikv:masterfrom
lcwangchao:poll_task_details
Jul 24, 2026
Merged

txnkv: add readPoolTaskDetails to SnapshotRuntimeStats#2025
ti-chi-bot[bot] merged 1 commit into
tikv:masterfrom
lcwangchao:poll_task_details

Conversation

@lcwangchao

@lcwangchao lcwangchao commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref https://github.com/tidbcloud/cloud-storage-engine/issues/5480

Problem Summary:

TiKV/CSE can now return optional request-level read-pool scheduling and execution metrics in ExecDetailsV2.read_pool_task_details. client-go currently drops these details, so TiDB and other downstream consumers cannot include read-pool queueing, wakeup, dispatch/poll, and CPU/wall-time breakdowns in snapshot runtime diagnostics.

What is changed and how it works?

  • Bump kvproto to the revision that adds PoolTaskDetails to ExecDetailsV2.
  • Add util.PoolTaskDetails to aggregate reported task samples, including:
    • task, poll, and dispatch counts;
    • task wall time, queue wait, wake wait, and poll CPU/wall time;
    • total, minimum, and maximum values;
    • fair-queue waited-task-slice statistics.
  • Merge read_pool_task_details from responses into SnapshotRuntimeStats.
  • Support cloning, merging, empty checks, and compact string formatting for the aggregate.
  • Expose GetReadPoolTaskDetails() as a defensive copy so callers cannot mutate the stored runtime stats.
  • Keep the field lazy and backward-compatible: responses from older servers do not allocate or print empty read-pool statistics.
  • Refresh root, integration-test, and example module metadata for the new kvproto revision.

The aggregation operates on reported response samples because the protobuf currently carries no task identity or delta information.

Check List

  • Unit tests
    • go test ./util ./txnkv/txnsnapshot
    • go test --tags=intest ./util ./txnkv/txnsnapshot
  • Backward compatibility
    • The protobuf field is additive and optional.
    • Existing behavior is unchanged when read_pool_task_details is absent.

Related changes

Summary by CodeRabbit

  • New Features
    • Enhanced snapshot runtime statistics to include read-pool task details (poll/dispatch and related timing/wait metrics).
    • Added aggregation support so read-pool details can be merged, cloned, formatted, and retrieved from runtime stats.
  • Maintenance
    • Bumped Go toolchain and refreshed several indirect module versions across examples and integration.
    • Updated the primary kv-proto dependency revision.
  • Tests
    • Added unit and integration test coverage for read-pool metric aggregation, formatting, merge/clone behavior, and empty-state handling.

@ti-chi-bot ti-chi-bot Bot added the dco-signoff: yes Indicates the PR's author has signed the dco. label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dfe2f528-c8ae-4823-a80f-3c15adf9b136

📥 Commits

Reviewing files that changed from the base of the PR and between 8863e20 and e4c4f91.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • integration_tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (14)
  • examples/gcworker/go.mod
  • examples/rawkv/go.mod
  • examples/txnkv/1pc_txn/go.mod
  • examples/txnkv/async_commit/go.mod
  • examples/txnkv/delete_range/go.mod
  • examples/txnkv/go.mod
  • examples/txnkv/pessimistic_txn/go.mod
  • examples/txnkv/unsafedestoryrange/go.mod
  • go.mod
  • integration_tests/go.mod
  • integration_tests/snapshot_test.go
  • txnkv/txnsnapshot/snapshot.go
  • util/execdetails.go
  • util/execdetails_test.go
🚧 Files skipped from review as they are similar to previous changes (13)
  • go.mod
  • integration_tests/go.mod
  • examples/rawkv/go.mod
  • examples/txnkv/pessimistic_txn/go.mod
  • examples/txnkv/go.mod
  • examples/txnkv/async_commit/go.mod
  • examples/txnkv/1pc_txn/go.mod
  • examples/txnkv/delete_range/go.mod
  • examples/txnkv/unsafedestoryrange/go.mod
  • examples/gcworker/go.mod
  • util/execdetails.go
  • util/execdetails_test.go
  • txnkv/txnsnapshot/snapshot.go

📝 Walkthrough

Walkthrough

The change adds read-pool task metric aggregation and exposes it through snapshot runtime statistics. It also updates Go 1.25.10 and refreshes kvproto, PD client, gRPC, protobuf, and genproto versions across modules.

Changes

Read-pool statistics

Layer / File(s) Summary
Pool-task aggregation and validation
util/execdetails.go, util/execdetails_test.go
Adds protobuf merging, aggregate merging, min/max handling, cloning, emptiness checks, formatting, and comprehensive tests for PoolTaskDetails.
Snapshot runtime integration
txnkv/txnsnapshot/snapshot.go, integration_tests/snapshot_test.go
Propagates read-pool details through snapshot merging and cloning, includes them in string output, adds a cloned accessor, and verifies formatted output.
Go and dependency version refresh
go.mod, integration_tests/go.mod, examples/*/go.mod
Updates Go to 1.25.10 and refreshes pinned kvproto, PD client, gRPC, protobuf, and genproto dependencies.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ExecDetailsV2
  participant mergeExecDetail
  participant SnapshotRuntimeStats
  ExecDetailsV2->>mergeExecDetail: provide readPoolTaskDetails
  mergeExecDetail->>SnapshotRuntimeStats: merge read-pool metrics
  SnapshotRuntimeStats->>SnapshotRuntimeStats: clone, merge, and format details
Loading

Possibly related PRs

Suggested reviewers: ekexium, cfzjywx, ekexium

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main change: adding readPoolTaskDetails support to SnapshotRuntimeStats in txnkv.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
examples/gcworker/go.mod

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

examples/rawkv/go.mod

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

examples/txnkv/1pc_txn/go.mod

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

  • 7 others

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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 `@examples/gcworker/go.mod`:
- Line 3: Update the Go version from 1.25.10 to 1.25.12 in the module directives
at examples/gcworker/go.mod:3-3, examples/rawkv/go.mod:3-3,
examples/txnkv/1pc_txn/go.mod:3-3, examples/txnkv/async_commit/go.mod:3-3,
examples/txnkv/delete_range/go.mod:3-3, examples/txnkv/go.mod:3-3,
examples/txnkv/pessimistic_txn/go.mod:3-3, and
examples/txnkv/unsafedestoryrange/go.mod:3-3; if retaining 1.25.10 instead,
document the intentional pin at every affected module.

In `@txnkv/txnsnapshot/snapshot.go`:
- Around line 951-956: Add focused _test.go coverage in txnkv/txnsnapshot for
mergeExecDetail’s read-pool task details path, SnapshotRuntimeStats.Merge and
Clone behavior, String output, and GetReadPoolTaskDetails. Verify
initialization, merging, cloning independence, and expected formatted output
using the existing symbols and test conventions.
🪄 Autofix (Beta)

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6da3f9eb-4d5b-4d36-b5bb-8804ec55d5ec

📥 Commits

Reviewing files that changed from the base of the PR and between 3d4b3ea and 8863e20.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • integration_tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (13)
  • examples/gcworker/go.mod
  • examples/rawkv/go.mod
  • examples/txnkv/1pc_txn/go.mod
  • examples/txnkv/async_commit/go.mod
  • examples/txnkv/delete_range/go.mod
  • examples/txnkv/go.mod
  • examples/txnkv/pessimistic_txn/go.mod
  • examples/txnkv/unsafedestoryrange/go.mod
  • go.mod
  • integration_tests/go.mod
  • txnkv/txnsnapshot/snapshot.go
  • util/execdetails.go
  • util/execdetails_test.go

Comment thread examples/gcworker/go.mod
Comment thread txnkv/txnsnapshot/snapshot.go
Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
Comment thread util/execdetails.go
hadTaskWallTimeSamples := d.TaskWallTimeSampleCount > 0
hadTasks := d.TaskCount > 0

d.TaskCount++

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PoolTaskDetails is a cumulative snapshot of one physical read-pool task, but batch_get_command can attach successive snapshots of the same shared task to multiple child responses.

Incrementing the TaskCount and summing each snapshot here therefore double-counts task/poll/time totals and may attribute earlier children’s work to later requests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This aggregation is intended for request-latency diagnostics rather than de-duplicated physical task accounting. Each response contributes one task observation. For a child response from batch_get_command, the cumulative snapshot intentionally includes work performed before that child becomes visible, because that work contributes to its observed latency. Totals are sums across reported observations and are primarily used to calculate averages; overlapping or shared physical read-pool tasks are not de-duplicated. We will clarify this behavior in the field and merge documentation.

We could alternatively report statistics based on distinct physical tasks by de-duplicating shared execution on the TiKV side. However, doing so would require substantially more changes, such as introducing task identity and snapshot semantics across kvproto, TiKV, and client-go, and retaining that identity during aggregation. We need to evaluate whether the additional complexity is justified. In practice, a single SQL statement only encounters this distinction in a limited set of cases, such as multiple UNION branches that each perform a point get.

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jul 23, 2026
@ti-chi-bot ti-chi-bot Bot added the lgtm label Jul 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, zyguan

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

The pull request process is described 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

@ti-chi-bot ti-chi-bot Bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-07-23 10:16:12.989872468 +0000 UTC m=+1486359.025967514: ☑️ agreed by cfzjywxk.
  • 2026-07-24 02:37:05.421013389 +0000 UTC m=+1545211.457108445: ☑️ agreed by zyguan.

@ti-chi-bot
ti-chi-bot Bot merged commit 61ecd7c into tikv:master Jul 24, 2026
13 checks passed
@lcwangchao
lcwangchao deleted the poll_task_details branch July 24, 2026 02:41
@lcwangchao

Copy link
Copy Markdown
Contributor Author

/cherry-pick release-nextgen-202603

@ti-chi-bot

Copy link
Copy Markdown
Member

@lcwangchao: new pull request created to branch release-nextgen-202603: #2030.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherry-pick release-nextgen-202603

Instructions 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.

lcwangchao added a commit to ti-chi-bot/client-go that referenced this pull request Jul 24, 2026
ref tidbcloud/cloud-storage-engine#5480

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
lcwangchao added a commit to ti-chi-bot/client-go that referenced this pull request Jul 24, 2026
ref tidbcloud/cloud-storage-engine#5480

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
ti-chi-bot Bot pushed a commit that referenced this pull request Jul 24, 2026
ref tidbcloud/cloud-storage-engine#5480\n\nSigned-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>\nSigned-off-by: Chao Wang <cclcwangchao@hotmail.com>\n\nCo-authored-by: Chao Wang <cclcwangchao@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants