-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restore: auto tune concurrency configuration when using new mode rest…
- Loading branch information
Showing
12 changed files
with
196 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2024 PingCAP, Inc. Licensed under Apache-2.0. | ||
package config | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/docker/go-units" | ||
) | ||
|
||
type ConfigTerm[T uint | uint64] struct { | ||
Value T | ||
Modified bool | ||
} | ||
|
||
type KVConfig struct { | ||
ImportGoroutines ConfigTerm[uint] | ||
MergeRegionSize ConfigTerm[uint64] | ||
MergeRegionKeyCount ConfigTerm[uint64] | ||
} | ||
|
||
func ParseImportThreadsFromConfig(resp []byte) (uint, error) { | ||
type importer struct { | ||
Threads uint `json:"num-threads"` | ||
} | ||
|
||
type config struct { | ||
Import importer `json:"import"` | ||
} | ||
var c config | ||
e := json.Unmarshal(resp, &c) | ||
if e != nil { | ||
return 0, e | ||
} | ||
|
||
return c.Import.Threads, nil | ||
} | ||
|
||
func ParseMergeRegionSizeFromConfig(resp []byte) (uint64, uint64, error) { | ||
type coprocessor struct { | ||
RegionSplitSize string `json:"region-split-size"` | ||
RegionSplitKeys uint64 `json:"region-split-keys"` | ||
} | ||
|
||
type config struct { | ||
Cop coprocessor `json:"coprocessor"` | ||
} | ||
var c config | ||
e := json.Unmarshal(resp, &c) | ||
if e != nil { | ||
return 0, 0, e | ||
} | ||
rs, e := units.RAMInBytes(c.Cop.RegionSplitSize) | ||
if e != nil { | ||
return 0, 0, e | ||
} | ||
urs := uint64(rs) | ||
return urs, c.Cop.RegionSplitKeys, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.