logpuller: optimize resolved-ts dispatch allocations#4698
logpuller: optimize resolved-ts dispatch allocations#4698ti-chi-bot[bot] merged 4 commits intopingcap:masterfrom
Conversation
Signed-off-by: dongmen <414110582@qq.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughCompute resolvedStates capacity from incoming region count (capped by batch size), use index-based iteration to track remaining regions, avoid unnecessary reallocation by nil-ing the slice after pushing. Add tests and benchmarks validating single-region fast-path and large-batch splitting. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request optimizes the dispatchResolvedTsEvent function by introducing a fast path for single-region events and refining memory allocation during batch processing of multi-region events. Review feedback suggests downgrading a new warning log to debug level to prevent potential log noise and further optimizing slice re-allocations by calculating a more precise capacity hint for remaining regions.
| log.Warn("region request worker receives a resolved ts event for an untracked region", | ||
| zap.Uint64("workerID", s.workerID), | ||
| zap.Uint64("subscriptionID", uint64(subscriptionID)), | ||
| zap.Uint64("regionID", regionID), | ||
| zap.Uint64("resolvedTs", resolvedTsEvent.Ts)) |
Signed-off-by: dongmen <414110582@qq.com>
Signed-off-by: dongmen <414110582@qq.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hongyunyan, lidezhu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
/test all |
|
/test all |
What problem does this PR solve?
Issue Number: close #4697
What is changed and how it works?
len(resolvedTsEvent.Regions) == 1, directly push one-state event.resolvedStatescapacity to:capHint = min(len(resolvedTsEvent.Regions), resolvedTsStateBatchSize)resolvedTsStateBatchSizeremains1024.flush, do not always allocate a new slice.region_request_worker_test.go:Benchmark Command
Average Comparison (5 runs)
SingleRegionandSmallBatchshow major CPU and allocation improvements.LargeBatchkeeps bounded memory behavior and reduces allocations;ns/opis roughly flat (+0.57%).Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note
Summary by CodeRabbit
Performance
Tests