-
Notifications
You must be signed in to change notification settings - Fork 37
DNM: refine dispatcher scan priority with syncpoint refine #4123
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
Draft
asddongmen
wants to merge
36
commits into
pingcap:master
Choose a base branch
from
asddongmen:0119-refine-dispatcher-scan-priority-with-syncpoint-refine
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
84dced1
improve memory control v1
asddongmen 1d6d73c
fix bug
asddongmen 381e57d
add debug log
asddongmen d2852f6
add debug log 2
asddongmen f1f9fe1
add debug log 3
asddongmen 62e1546
add debug log 4
asddongmen f714b8d
add debug log 5
asddongmen 2f04643
adjust = 0.7
asddongmen 75b2d16
adjust 5
asddongmen 8dcb0a2
for debug
asddongmen 994ef9b
adjust 7
asddongmen 4073610
fix bug
asddongmen 87c5e6f
fix bug 2
asddongmen fcf76f2
adjust 10
asddongmen 0853113
adjust 11
asddongmen 9139d93
allow scan interval grow larger
asddongmen 274878f
allow scan interval grow larger 2
asddongmen 36be880
remove verbose log
asddongmen 96b9ae8
fix bug
asddongmen fc271cd
Merge remote-tracking branch 'upstream/master' into 0119-refine-dispa…
asddongmen c9df6b0
comment hardcode scan interval
asddongmen 2ebeef6
add cool down
asddongmen abc0015
add metrics
asddongmen 3d506ab
adjust scan window algorithm
asddongmen a0febab
adjust scan window algorithm 2
asddongmen 460b74d
adjust scan window algorithm 3
asddongmen f8c34a1
add comment
asddongmen 1a86e53
remove useless codes
asddongmen 6c6babf
add ddl workload
asddongmen 6464520
remove useless code
asddongmen 730f373
refine syncpoint handle
asddongmen 1a4383c
Merge remote-tracking branch 'upstream/master' into 0119-refine-dispa…
asddongmen dcb47a8
fix bug
asddongmen d41d180
add debug log
asddongmen aeeda69
fix
asddongmen a24e5b3
add log
asddongmen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,6 +113,8 @@ type EventCollector struct { | |
| dispatcherMap sync.Map // key: dispatcherID, value: dispatcherStat | ||
| changefeedMap sync.Map // key: changefeedID.GID, value: *changefeedStat | ||
|
|
||
| lastCongestionLogTime int64 | ||
|
|
||
| mc messaging.MessageCenter | ||
|
|
||
| logCoordinatorClient *LogCoordinatorClient | ||
|
|
@@ -600,6 +602,10 @@ func (c *EventCollector) newCongestionControlMessages() map[node.ID]*event.Conge | |
| // collect path-level available memory and total available memory for each changefeed | ||
| changefeedPathMemory := make(map[common.ChangeFeedID]map[common.DispatcherID]uint64) | ||
| changefeedTotalMemory := make(map[common.ChangeFeedID]uint64) | ||
| changefeedUsedMemory := make(map[common.ChangeFeedID]uint64) | ||
| changefeedMaxMemory := make(map[common.ChangeFeedID]uint64) | ||
| totalDispatchers := 0 | ||
| dispatchersWithoutService := 0 | ||
|
|
||
| // collect from main dynamic stream | ||
| for _, quota := range c.ds.GetMetrics().MemoryControl.AreaMemoryMetrics { | ||
|
|
@@ -617,6 +623,8 @@ func (c *EventCollector) newCongestionControlMessages() map[node.ID]*event.Conge | |
| } | ||
| // store total available memory from AreaMemoryMetric | ||
| changefeedTotalMemory[cfID] = uint64(quota.AvailableMemory()) | ||
| changefeedUsedMemory[cfID] = uint64(quota.MemoryUsage()) | ||
| changefeedMaxMemory[cfID] = uint64(quota.MaxMemory()) | ||
| } | ||
|
|
||
| // collect from redo dynamic stream and take minimum | ||
|
|
@@ -643,6 +651,16 @@ func (c *EventCollector) newCongestionControlMessages() map[node.ID]*event.Conge | |
| } else { | ||
| changefeedTotalMemory[cfID] = uint64(quota.AvailableMemory()) | ||
| } | ||
| if existing, exists := changefeedUsedMemory[cfID]; exists { | ||
| changefeedUsedMemory[cfID] = min(existing, uint64(quota.MemoryUsage())) | ||
| } else { | ||
| changefeedUsedMemory[cfID] = uint64(quota.MemoryUsage()) | ||
| } | ||
| if existing, exists := changefeedMaxMemory[cfID]; exists { | ||
| changefeedMaxMemory[cfID] = min(existing, uint64(quota.MaxMemory())) | ||
| } else { | ||
| changefeedMaxMemory[cfID] = uint64(quota.MaxMemory()) | ||
| } | ||
|
Comment on lines
+654
to
+663
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| if len(changefeedPathMemory) == 0 { | ||
|
|
@@ -655,7 +673,9 @@ func (c *EventCollector) newCongestionControlMessages() map[node.ID]*event.Conge | |
| c.dispatcherMap.Range(func(k, v interface{}) bool { | ||
| stat := v.(*dispatcherStat) | ||
| eventServiceID := stat.connState.getEventServiceID() | ||
| totalDispatchers++ | ||
| if eventServiceID == "" { | ||
| dispatchersWithoutService++ | ||
| return true | ||
| } | ||
|
|
||
|
|
@@ -678,8 +698,9 @@ func (c *EventCollector) newCongestionControlMessages() map[node.ID]*event.Conge | |
|
|
||
| // build congestion control messages for each node | ||
| result := make(map[node.ID]*event.CongestionControl) | ||
| changefeedsInMessages := 0 | ||
| for nodeID, changefeedDispatchers := range nodeDispatcherMemory { | ||
| congestionControl := event.NewCongestionControl() | ||
| congestionControl := event.NewCongestionControlWithVersion(event.CongestionControlVersion2) | ||
|
|
||
| for changefeedID, dispatcherMemory := range changefeedDispatchers { | ||
| if len(dispatcherMemory) == 0 { | ||
|
|
@@ -689,11 +710,14 @@ func (c *EventCollector) newCongestionControlMessages() map[node.ID]*event.Conge | |
| // get total available memory directly from AreaMemoryMetric | ||
| totalAvailable := uint64(changefeedTotalMemory[changefeedID]) | ||
| if totalAvailable > 0 { | ||
| congestionControl.AddAvailableMemoryWithDispatchers( | ||
| congestionControl.AddAvailableMemoryWithDispatchersAndUsage( | ||
| changefeedID.ID(), | ||
| totalAvailable, | ||
| changefeedUsedMemory[changefeedID], | ||
| changefeedMaxMemory[changefeedID], | ||
| dispatcherMemory, | ||
| ) | ||
| changefeedsInMessages++ | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -702,6 +726,19 @@ func (c *EventCollector) newCongestionControlMessages() map[node.ID]*event.Conge | |
| } | ||
| } | ||
|
|
||
| nowUnix := time.Now().Unix() | ||
| lastLog := atomic.LoadInt64(&c.lastCongestionLogTime) | ||
| if nowUnix-lastLog >= int64(time.Minute.Seconds()) && | ||
| atomic.CompareAndSwapInt64(&c.lastCongestionLogTime, lastLog, nowUnix) { | ||
| log.Info("congestion control build summary", | ||
| zap.Int("dispatchers", totalDispatchers), | ||
| zap.Int("dispatchersWithoutService", dispatchersWithoutService), | ||
| zap.Int("changefeedsWithMetrics", len(changefeedPathMemory)), | ||
| zap.Int("changefeedsInMessages", changefeedsInMessages), | ||
| zap.Int("nodes", len(result)), | ||
| ) | ||
| } | ||
|
|
||
| return result | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The logic in the
defaultcase is identical to thecase heartbeatpb.Action_Pass, heartbeatpb.Action_Skip. This code duplication can be removed by combining them. You can use adefaultcase to handlePass,Skip, and any potential future actions with the same logic, which simplifies the code and improves maintainability.