-
Notifications
You must be signed in to change notification settings - Fork 727
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
pd-simulator: update import-data case #2741
Changes from 6 commits
17f6b0a
f71f6fc
18f0f41
47d1699
ef22f6a
10bb4d0
3f48876
730ad0f
ff4ad2e
45496fc
3b41894
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,8 @@ func newImportData() *Case { | |
}) | ||
} | ||
|
||
storeIDs := rand.Perm(3) | ||
for i := 0; i < 40; i++ { | ||
for i := 0; i < 10000; i++ { | ||
storeIDs := rand.Perm(10) | ||
peers := []*metapb.Peer{ | ||
{Id: IDAllocator.nextID(), StoreId: uint64(storeIDs[0] + 1)}, | ||
{Id: IDAllocator.nextID(), StoreId: uint64(storeIDs[1] + 1)}, | ||
|
@@ -63,23 +63,15 @@ func newImportData() *Case { | |
e := &WriteFlowOnSpotDescriptor{} | ||
table2 := string(codec.EncodeBytes(codec.GenerateTableKey(2))) | ||
table3 := string(codec.EncodeBytes(codec.GenerateTableKey(3))) | ||
table5 := string(codec.EncodeBytes(codec.GenerateTableKey(5))) | ||
e.Step = func(tick int64) map[string]int64 { | ||
if tick < 100 { | ||
return map[string]int64{ | ||
table3: 4 * MB, | ||
table5: 32 * MB, | ||
} | ||
} | ||
return map[string]int64{ | ||
table2: 2 * MB, | ||
table3: 4 * MB, | ||
table5: 16 * MB, | ||
table2: 32 * MB, | ||
} | ||
} | ||
simCase.Events = []EventDescriptor{e} | ||
|
||
// Checker description | ||
checkCount := uint64(0) | ||
simCase.Checker = func(regions *core.RegionsInfo, stats []info.StoreStats) bool { | ||
leaderDist := make(map[uint64]int) | ||
peerDist := make(map[uint64]int) | ||
|
@@ -120,21 +112,28 @@ func newImportData() *Case { | |
regionTotal := regions.GetRegionCount() | ||
totalLeaderLog := fmt.Sprintf("%d leader:", regionTotal) | ||
totalPeerLog := fmt.Sprintf("%d peer:", regionTotal*3) | ||
isEnd := true | ||
isEnd := checkCount > 1000 | ||
var regionProps []float64 | ||
for storeID := uint64(1); storeID <= 10; storeID++ { | ||
regions.GetStoreRegionCount(storeID) | ||
totalLeaderLog = fmt.Sprintf("%s [store %d]:%.2f%%", totalLeaderLog, storeID, float64(regions.GetStoreLeaderCount(storeID))/float64(regionTotal)*100) | ||
regionProp := float64(regions.GetStoreRegionCount(storeID)) / float64(regionTotal*3) * 100 | ||
if regionProp > 13.8 { | ||
isEnd = false | ||
} | ||
regionProps = append(regionProps, regionProp) | ||
totalPeerLog = fmt.Sprintf("%s [store %d]:%.2f%%", totalPeerLog, storeID, regionProp) | ||
} | ||
simutil.Logger.Info("import data information", | ||
zap.String("table-leader", tableLeaderLog), | ||
zap.String("table-peer", tablePeerLog), | ||
zap.String("total-leader", totalLeaderLog), | ||
zap.String("total-peer", totalPeerLog)) | ||
checkCount++ | ||
dev := 0.0 | ||
for _, p := range regionProps { | ||
dev += (p - 10) * (p - 10) / 100 | ||
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. will it still be 10 after region num is configured? 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. It means if balanced, store each get 10 % of data, no matter what the total is. 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. OK |
||
} | ||
if dev > 0.005 { | ||
simutil.Logger.Warn("Not balanced, consider higher store limit", zap.Float64("dev score", dev)) | ||
} | ||
return isEnd | ||
} | ||
return &simCase | ||
|
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.
can it be configured?
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.
Changed to configurable.