Skip to content

util: expose IA scan detail fields#2015

Open
Connor1996 wants to merge 1 commit into
tikv:masterfrom
Connor1996:codex/ia-scan-detail-fields
Open

util: expose IA scan detail fields#2015
Connor1996 wants to merge 1 commit into
tikv:masterfrom
Connor1996:codex/ia-scan-detail-fields

Conversation

@Connor1996

@Connor1996 Connor1996 commented Jul 2, 2026

Copy link
Copy Markdown
Member

What changed

This exposes IA scan detail counters from kvrpcpb.ScanDetailV2 through util.ScanDetail and includes them in merge and string formatting. It also bumps github.com/pingcap/kvproto to a version that already contains the IA fields from pingcap/kvproto#1438.

Validation

The util package tests pass. Full-tree tests are currently blocked by an existing tikv mockstore panic that reproduces on upstream/master.

Summary by CodeRabbit

  • New Features

    • Added more detailed scan statistics in query output, including cache hits, remote segment reads, bytes read, and wait time.
    • Scan details now display these extra metrics when present, giving clearer insight into read behavior.
  • Bug Fixes

    • Improved aggregation of scan statistics so combined results now include the new remote-read metrics correctly.

Signed-off-by: Connor1996 <zbk602423539@gmail.com>
@ti-chi-bot

ti-chi-bot Bot commented Jul 2, 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 2, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 2, 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 nrc 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 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds IA (remote read segment) statistics tracking to ScanDetail in util/execdetails.go: four new fields for cache hits, remote read segment count/bytes, and wait duration, with corresponding merge and string formatting logic, populated from a new kvrpcpb.ScanDetailV2 protobuf fields. Unit tests are added, and the kvproto dependency is bumped.

Changes

ScanDetail IA metrics

Layer / File(s) Summary
ScanDetail struct fields, merge, and string formatting
util/execdetails.go
Adds four IA fields to ScanDetail (cache hit count, remote read segment count/bytes, wait duration), aggregates them in Merge, and conditionally renders an ia: {...} section in String.
Populate IA fields from protobuf and dependency bump
util/execdetails.go, go.mod
Updates MergeFromScanDetailV2 to populate IA fields from new protobuf fields (converting nanos to time.Duration), and bumps github.com/pingcap/kvproto to a newer revision.
Tests for IA metrics
util/execdetails_test.go
Adds tests validating IA field population via MergeFromScanDetailV2, correct String() output, and IA field aggregation in Merge.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 clearly matches the main change: exposing new IA scan detail fields in util.ScanDetail.
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

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 2, 2026
@Connor1996 Connor1996 marked this pull request as ready for review July 3, 2026 00:49
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 3, 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.

🧹 Nitpick comments (1)
util/execdetails.go (1)

544-570: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Ia formatting logic is correct but duplicates the trailing-comma-trim pattern.

The new ia block reuses the same trim-trailing-comma idiom already present in the rocksdb/block sections. Since this pattern now appears three times in String(), consider extracting a small helper (e.g. trimTrailingComma(buf *bytes.Buffer)) to reduce repetition. Not blocking, purely a maintainability nit.

♻️ Optional helper extraction
+func trimTrailingComma(buf *bytes.Buffer) {
+	if buf.Len() >= 2 && buf.Bytes()[buf.Len()-2] == ',' {
+		buf.Truncate(buf.Len() - 2)
+	}
+}

Then replace each inline if buf.Bytes()[buf.Len()-2] == ',' { buf.Truncate(buf.Len() - 2) } occurrence with trimTrailingComma(buf).

🤖 Prompt for 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.

In `@util/execdetails.go` around lines 544 - 570, The String() formatting in
execdetails.go repeats the same trailing-comma trimming logic across the
rocksdb, block, and new ia sections. Extract that repeated buf truncation
pattern into a small helper such as trimTrailingComma used by String() to keep
the formatting code maintainable. Update the existing inline comma-trim checks
in the relevant sections to call the helper instead of duplicating the same
logic.
🤖 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.

Nitpick comments:
In `@util/execdetails.go`:
- Around line 544-570: The String() formatting in execdetails.go repeats the
same trailing-comma trimming logic across the rocksdb, block, and new ia
sections. Extract that repeated buf truncation pattern into a small helper such
as trimTrailingComma used by String() to keep the formatting code maintainable.
Update the existing inline comma-trim checks in the relevant sections to call
the helper instead of duplicating the same logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6df27cc6-64eb-4c2f-891f-b9ab087ea821

📥 Commits

Reviewing files that changed from the base of the PR and between 00f57d8 and b40f674.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod
  • util/execdetails.go
  • util/execdetails_test.go

@ti-chi-bot

ti-chi-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

@Connor1996: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-integration-test-nextgen b40f674 link false /test pull-integration-test-nextgen

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

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