Skip to content

Commit

Permalink
sorter: reduce memory malloc to avoid too much CPU overhead (#1854) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot committed May 27, 2021
1 parent 5069d1d commit 669c904
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cdc/puller/sorter/heap_sorter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

const (
flushRateLimitPerSecond = 10
sortHeapCapacity = 32
)

type flushTask struct {
Expand Down Expand Up @@ -86,7 +87,7 @@ func newHeapSorter(id int, out chan *flushTask) *heapSorter {
id: id,
inputCh: make(chan *model.PolymorphicEvent, 1024*1024),
outputCh: out,
heap: make(sortHeap, 0, 65536),
heap: make(sortHeap, 0, sortHeapCapacity),
canceller: new(asyncCanceller),
}
}
Expand Down Expand Up @@ -159,7 +160,7 @@ func (h *heapSorter) flush(ctx context.Context, maxResolvedTs uint64) error {
return nil
}
oldHeap = h.heap
h.heap = make(sortHeap, 0, 65536)
h.heap = make(sortHeap, 0, sortHeapCapacity)
} else {
task.dealloc = func() error {
task.markDeallocated()
Expand Down

0 comments on commit 669c904

Please sign in to comment.