Commit 03b5ecd 1 parent 24682c1 commit 03b5ecd Copy full SHA for 03b5ecd
File tree 3 files changed +17
-9
lines changed
downstreamadapter/dispatcher
3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -223,9 +223,11 @@ func NewDispatcherEvent(event commonEvent.Event) *DispatcherEvent {
223
223
}
224
224
switch event .GetType () {
225
225
case commonEvent .TypeResolvedEvent :
226
+ dispatcherEvent .isBatchable = true
226
227
case commonEvent .TypeDMLEvent :
227
228
dispatcherEvent .isBatchable = true
228
229
case commonEvent .TypeDDLEvent :
230
+ dispatcherEvent .isBatchable = false
229
231
case commonEvent .TypeSyncPointEvent :
230
232
dispatcherEvent .isBatchable = false
231
233
default :
@@ -240,7 +242,7 @@ var dispatcherEventsDynamicStreamOnce sync.Once
240
242
func GetDispatcherEventsDynamicStream () dynstream.DynamicStream [common.DispatcherID , DispatcherEvent , * Dispatcher ] {
241
243
if dispatcherEventsDynamicStream == nil {
242
244
dispatcherEventsDynamicStreamOnce .Do (func () {
243
- dispatcherEventsDynamicStream = dynstream .NewDynamicStream (& DispatcherEventsHandler {})
245
+ dispatcherEventsDynamicStream = dynstream .NewDynamicStream (& DispatcherEventsHandler {}, dynstream . NewOptionWithBatchSize ( 128 ) )
244
246
dispatcherEventsDynamicStream .Start ()
245
247
})
246
248
}
Original file line number Diff line number Diff line change @@ -116,6 +116,12 @@ func NewOption() Option {
116
116
}
117
117
}
118
118
119
+ func NewOptionWithBatchSize (batchSize int ) Option {
120
+ opt := NewOption ()
121
+ opt .BatchSize = batchSize
122
+ return opt
123
+ }
124
+
119
125
func (o * Option ) fix () {
120
126
if o .StreamCount == 0 {
121
127
o .StreamCount = runtime .NumCPU ()
Original file line number Diff line number Diff line change @@ -344,19 +344,19 @@ Loop:
344
344
// which is possible when the path is removed or recovered from blocked.
345
345
break
346
346
}
347
- // If the event is non-batchable, we should handle it singly.
348
- // The non-batchable event should be the only event in a batch.
349
- if ! e .IsBatchable () {
347
+
348
+ if e .IsBatchable () {
349
+ signal .pathInfo .pendingQueue .PopFront ()
350
+ eventBuf = append (eventBuf , e )
351
+ } else {
352
+ // If the event is non-batchable, we should handle it singly.
353
+ // The non-batchable event should be the only event in a batch.
350
354
if i == 0 {
351
355
eventBuf = append (eventBuf , e )
352
356
signal .pathInfo .pendingQueue .PopFront ()
353
- break
354
- } else {
355
- break
356
357
}
358
+ break
357
359
}
358
- signal .pathInfo .pendingQueue .PopFront ()
359
- eventBuf = append (eventBuf , e )
360
360
}
361
361
362
362
actualCount := len (eventBuf )
You can’t perform that action at this time.
0 commit comments