Skip to content

perf(cdc): avoid formatting disabled watermark debug logs - #32938

Closed
XuPeng-SH wants to merge 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/32278-c28
Closed

XuPeng-SH wants to merge 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/32278-c28

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #32278 (C28).

What this PR does / why we need it:

Buffering a CDC watermark formatted the table key twice and rendered both timestamps before Debug could reject the log event. Reuse the existing metric label and build the structured log fields only when Debug is enabled.

In a local Go 1.27.1 benchmark of repeated accepted updates with Debug disabled, allocation fell from 666 to 72 B/op and from 11 to 4 allocs/op. Median time across three samples fell from 591 to 231 ns/op for that fixture.

Validation: the CDC package under the race detector and incremental SCA. With Debug enabled, the before/after structured records match apart from the wall-clock timestamp. Info emits no buffer-update event. Both levels buffer the same watermark and increment the same commit counter.

A committed CDC regression test verifies Info and Debug behavior, including first and replacement watermark fields, cached values, and the commit counter. In a local coverage run using the CI test tag, both changed coverage blocks are exercised.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is closed, so it cannot be queued. Reopen it to get the box back.

@XuPeng-SH

XuPeng-SH commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 5def69e1136a472650f12d18150acd2d94e6d4cc

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

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.

mo-bot review · mo-bot-local · review

Commit: 5def69e1136a472650f12d18150acd2d94e6d4cc

Assessment: approve

The watermark updater reuses its metric label and formats the debug fields only when the existing logger enables Debug. The probe confirmed the same buffered value, counter increments, and Debug fields on both revisions. With Debug disabled, the local fixture went from 682 to 80 B/op and from 11 to 4 allocs/op.

Model: gpt-6.2-sol / xhigh

Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3

Validation:

  • Preflight, diff hygiene, and the head-matched native build passed. See checks/1795084749395971377-4.json, checks/1795084749701570705-33.json, and checks/1795084847524131300-62.json and their retained logs.

  • The full pkg/cdc suite passed normally and with -race. See cdc-normal-clean.jsonl and cdc-race.jsonl with receipts checks/1795085164161814912-2.json and checks/1795085128233257420-2.json.

  • The corrected reviewer probe passed three times per revision. Info emitted no buffer-update event, while Debug emitted the expected fields for the initial and replacement values. The repeated accepted-update benchmark measured medians of 966.9 and 357.7 ns/op. See report-base.log and report-candidate.log with receipts checks/1795085146740232609-3.json and checks/1795085151983869642-197.json.

Limitations:

  • The timing comparison covers the local buffering method. End-to-end CDC throughput was outside the measured scope.

  • The initial reviewer probe requested a file sink that the scoped logger helper rejects. The corrected probe used the trace reporter and both revisions passed. Frozen incremental SCA was still in progress.

@XuPeng-SH

XuPeng-SH commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: be13e81a7164ea2d129099a316d1e5174c716693

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

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.

mo-bot review · mo-bot-local · review

Commit: be13e81a7164ea2d129099a316d1e5174c716693

Assessment: approve

The CDC watermark updater reuses the metric label and formats timestamps only when Debug is enabled. The regression test verifies the initial and replacement Debug records, buffered watermarks, and commit counter. The retained Info-level benchmark measured a drop from 682 to 80 B/op and from 11 to 4 allocations per update.

Model: gpt-6.2-sol / xhigh

Session: 01a1ee7f-fdcb-7b83-ad57-3b17a0e9d494 · slot 1 · generation 1

Validation:

  • Isolation preflight and frozen input checks passed. The production sources match the prior reviewed head, so the retained benchmark applies. See verify-inputs.log and receipts 1795098933021012932-2 and 1795098953637620306-2.

  • The full CDC package passed under the race detector with the CI test tag. The new regression also passed 100 focused race repetitions. See cdc-race.jsonl, logging-race.jsonl, and receipts 1795099255139759685-2 and 1795099273751518004-2.

  • Reconciled the prior benchmark receipts and all five discussion entries in receipt-reconciliation.json and discussion-assessment.json.

Limitations:

  • The benchmark measured repeated accepted updates in the local buffering method. End-to-end CDC throughput was outside its scope. Unit, SCA, and multi-CN jobs were still in progress in the frozen CI snapshot.

XuPeng-SH added a commit that referenced this pull request Nov 21, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to #32278 (C02 and C28).

## What this PR does / why we need it:

A persisted primary-key check prepared a data filter even when pruning
left no candidate blocks or the candidate count had already exceeded the
I/O budget. Check these cases first, while preserving the tombstone
check, conservative conflict result, and existing cancellation and I/O
cleanup. The 32/33-block boundary test now exercises both modified-key
and upsert checks and verifies reads and resource balance.

Buffering a CDC watermark formatted the table key twice and rendered
timestamps before a disabled Debug log could be rejected. Reuse the
metric label and prepare the structured fields only when Debug is
enabled. This PR incorporates the production change from #32938.

Local Go 1.27.1 microbenchmarks on the public conflict-check path
reduced allocations from 48 to 13 per call for a pruned object, and from
121 to 87 for an over-budget object; single-hit and 32-block controls
retained their previous allocation counts. A repeated CDC watermark
update with Debug disabled fell from 11 to 4 allocations per call. These
measure local operations, not end-to-end throughput.

Validation: focused persisted-data, tombstone, time-window, cancellation
and history tests; complete CDC and disttae package race runs; a focused
race run of the updated 32/33-block cases; go vet and incremental
golangci-lint for both packages. The CI coverage merge passed with 31/38
changed blocks covered (81.58%); the two BVT groups and Linux/arm64 SCA
also passed.


The committed CDC regression calls UpdateWatermarkOnly at Info and
Debug. It checks the buffered value and counter after each update, and
checks that the Debug event retains the key and old and new watermarks.
The performance measurements and prior CI coverage above describe the
unchanged production diff.
On the follow-up commit, both focused subtests, the full CDC package
under the race detector, go vet, molint, and incremental golangci-lint
passed. New GitHub CI runs on the updated head.

This branch was successfully deployed

No deployments
ci — be13e81a Deployed Nov 19, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants