Skip to content

Commit

Permalink
This is an automated cherry-pick of tikv#3967
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
lhy1024 authored and ti-chi-bot committed Aug 12, 2021
1 parent f28edc8 commit 729f38b
Show file tree
Hide file tree
Showing 6 changed files with 2,334 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/mock/mockcluster/mockcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,16 @@ func (mc *Cluster) UpdateStoreLeaderWeight(storeID uint64, weight float64) {
mc.PutStore(newStore)
}

// SetStoreEvictLeader set store whether evict leader.
func (mc *Cluster) SetStoreEvictLeader(storeID uint64, enableEvictLeader bool) {
store := mc.GetStore(storeID)
if enableEvictLeader {
mc.PutStore(store.Clone(core.PauseLeaderTransfer()))
} else {
mc.PutStore(store.Clone(core.ResumeLeaderTransfer()))
}
}

// UpdateStoreRegionWeight updates store region weight.
func (mc *Cluster) UpdateStoreRegionWeight(storeID uint64, weight float64) {
store := mc.GetStore(storeID)
Expand Down
6 changes: 6 additions & 0 deletions server/schedulers/hot_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ const (
// schedulePeerPr the probability of schedule the hot peer.
var schedulePeerPr = 0.66

<<<<<<< HEAD
=======
// pendingAmpFactor will amplify the impact of pending influence, making scheduling slower or even serial when two stores are close together
var pendingAmpFactor = 2.0

>>>>>>> 11c55c2b2 (scheduler: consider evict leader when calc expect (#3967))
type hotScheduler struct {
name string
*BaseScheduler
Expand Down
29 changes: 29 additions & 0 deletions server/schedulers/hot_region_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,35 @@ import (
"github.com/unrolled/render"
)

<<<<<<< HEAD
=======
const (
// BytePriority indicates hot-region-scheduler prefer byte dim
BytePriority = "byte"
// KeyPriority indicates hot-region-scheduler prefer key dim
KeyPriority = "key"
// QueryPriority indicates hot-region-scheduler prefer query dim
QueryPriority = "query"

// Scheduling has a bigger impact on TiFlash, so it needs to be corrected in configuration items
// In the default config, the TiKV difference is 1.05*1.05-1 = 0.1025, and the TiFlash difference is 1.15*1.15-1 = 0.3225
tiflashToleranceRatioCorrection = 0.1
)

var defaultConfig = prioritiesConfig{
readLeader: []string{QueryPriority, BytePriority},
writeLeader: []string{KeyPriority, BytePriority},
writePeer: []string{BytePriority, KeyPriority},
}

// because tikv below 5.2.0 does not report query information, we will use byte and key as the scheduling dimensions
var compatibleConfig = prioritiesConfig{
readLeader: []string{BytePriority, KeyPriority},
writeLeader: []string{KeyPriority, BytePriority},
writePeer: []string{BytePriority, KeyPriority},
}

>>>>>>> 11c55c2b2 (scheduler: consider evict leader when calc expect (#3967))
// params about hot region.
func initHotRegionScheduleConfig() *hotRegionSchedulerConfig {
return &hotRegionSchedulerConfig{
Expand Down
Loading

0 comments on commit 729f38b

Please sign in to comment.