Skip to content

Commit

Permalink
scheduler,spanz(ticdc): specify BtreeMap degree
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Shen <overvenus@gmail.com>
  • Loading branch information
overvenus committed Jan 4, 2023
1 parent fa3adac commit 1762a15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion cdc/scheduler/internal/v3/replication/replication_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ type Manager struct { //nolint:revive
func NewReplicationManager(
maxTaskConcurrency int, changefeedID model.ChangeFeedID,
) *Manager {
// degreeReadHeavy is a degree optimized for read heavy map, many Ascend.
// There may be a large number of tables.
const degreeReadHeavy = 256
return &Manager{
spans: spanz.NewBtreeMap[*ReplicationSet](),
spans: spanz.NewBtreeMapWithDegree[*ReplicationSet](degreeReadHeavy),
runningTasks: spanz.NewBtreeMap[*ScheduleTask](),
maxTaskConcurrency: maxTaskConcurrency,
changefeedID: changefeedID,
Expand Down
10 changes: 7 additions & 3 deletions pkg/spanz/btree_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ type BtreeMap[T any] struct {

// NewBtreeMap returns a new BtreeMap.
func NewBtreeMap[T any]() *BtreeMap[T] {
// Map is read heavy map, many Ascend.
const defaultDegree = 256
const defaultDegree = 16
return NewBtreeMapWithDegree[T](defaultDegree)
}

// NewBtreeMapWithDegree returns a new BtreeMap with the given degree.
func NewBtreeMapWithDegree[T any](degree int) *BtreeMap[T] {
return &BtreeMap[T]{
tree: btree.NewG(defaultDegree, lessSpanItem[T]),
tree: btree.NewG(degree, lessSpanItem[T]),
}
}

Expand Down

0 comments on commit 1762a15

Please sign in to comment.