-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ticdc: Fix CPU surge problem in sorter #10739
ticdc: Fix CPU surge problem in sorter #10739
Conversation
Please explain the backgorung in pr body |
Codecov Report
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## master #10739 +/- ##
================================================
+ Coverage 57.5694% 57.6751% +0.1057%
================================================
Files 851 852 +1
Lines 126793 127027 +234
================================================
+ Hits 72994 73263 +269
+ Misses 48361 48324 -37
- Partials 5438 5440 +2 |
if !ok { | ||
return | ||
} | ||
batchCh <- batchEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should an empty batchEvent be ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check whether batchEvent is empty in L395, because whether the batchEvent is empty, we have to update resolved ts.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: asddongmen, CharlesCheung96 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: close #10738
What is changed and how it works?
The problematic code snippet here:
tiflow/cdc/processor/sourcemanager/sorter/pebble/event_sorter.go
Lines 466 to 482 in e5edb19
is a busy loop that continuously polls an input channel and does some work when an item is available.
The issue here is with the 'default' clause in the select statement. If there's no item available in the 'inputCh' channel, it will immediately continue to the next iteration instead of blocking until an item is available or the 's.closed' channel is closed. This could lead to high CPU usage as the loop is continuously running.
This PR replace the 'default' clause with a ticker. This will cause the goroutine to block when there's no work to do, reducing CPU usage.
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