Skip to content

Commit 207c442

Browse files
wenyihu6tbg
authored andcommitted
asim: support store_byte_capacity option with gen_cluster
This commit adds support for the store_byte_capacity option in the gen_cluster command, enabling data-driven tests to change configuration of store capacity in bytes. Epic: none Release note: none
1 parent 7e0edad commit 207c442

File tree

9 files changed

+84
-70
lines changed

9 files changed

+84
-70
lines changed

pkg/kv/kvserver/asim/gen/generator.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,14 @@ func (lc LoadedCluster) Regions() []state.Region {
187187

188188
// BasicCluster implements the ClusterGen interace.
189189
type BasicCluster struct {
190-
Nodes int
191-
StoresPerNode int
190+
Nodes int
191+
StoresPerNode int
192+
StoreByteCapacity int64
192193
}
193194

194195
func (bc BasicCluster) String() string {
195-
return fmt.Sprintf("basic cluster with nodes=%d, stores_per_node=%d", bc.Nodes, bc.StoresPerNode)
196+
return fmt.Sprintf("basic cluster with nodes=%d, stores_per_node=%d, store_byte_capacity=%d",
197+
bc.Nodes, bc.StoresPerNode, bc.StoreByteCapacity)
196198
}
197199

198200
// Generate returns a new simulator state, where the cluster is created with all
@@ -201,6 +203,7 @@ func (bc BasicCluster) String() string {
201203
// values the basic cluster generator is created with.
202204
func (bc BasicCluster) Generate(seed int64, settings *config.SimulationSettings) state.State {
203205
info := state.ClusterInfoWithStoreCount(bc.Nodes, bc.StoresPerNode)
206+
info.StoreDiskCapacityBytes = bc.StoreByteCapacity
204207
return state.LoadClusterInfo(info, settings)
205208
}
206209

pkg/kv/kvserver/asim/state/config_loader.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var AllClusterOptions = [...]string{"single_region", "single_region_multi_store"
2626
// SingleRegionConfig is a simple cluster config with a single region and 3
2727
// zones, all have the same number of nodes.
2828
var SingleRegionConfig = ClusterInfo{
29-
DiskCapacityGB: 1024,
29+
StoreDiskCapacityBytes: 1024 << 30, // 1024 GiB
3030
Regions: []Region{
3131
{
3232
Name: "US",
@@ -42,7 +42,7 @@ var SingleRegionConfig = ClusterInfo{
4242
// SingleRegionMultiStoreConfig is a simple cluster config with a single region
4343
// and 3 zones, all zones have 1 node and 6 stores per node.
4444
var SingleRegionMultiStoreConfig = ClusterInfo{
45-
DiskCapacityGB: 1024,
45+
StoreDiskCapacityBytes: 1024 << 30, // 1024 GiB
4646
Regions: []Region{
4747
{
4848
Name: "US",
@@ -57,7 +57,7 @@ var SingleRegionMultiStoreConfig = ClusterInfo{
5757

5858
// MultiRegionConfig is a perfectly balanced cluster config with 3 regions.
5959
var MultiRegionConfig = ClusterInfo{
60-
DiskCapacityGB: 2048,
60+
StoreDiskCapacityBytes: 2048 << 30, // 2048 GiB
6161
Regions: []Region{
6262
{
6363
Name: "US_East",
@@ -88,7 +88,7 @@ var MultiRegionConfig = ClusterInfo{
8888

8989
// ComplexConfig is an imbalanced multi-region cluster config.
9090
var ComplexConfig = ClusterInfo{
91-
DiskCapacityGB: 2048,
91+
StoreDiskCapacityBytes: 2048 << 30, // 2048 GiB
9292
Regions: []Region{
9393
{
9494
Name: "US_East",
@@ -276,8 +276,8 @@ type Region struct {
276276
// ClusterInfo contains cluster information needed for allocation decisions.
277277
// TODO(lidor): add cross region network latencies.
278278
type ClusterInfo struct {
279-
DiskCapacityGB int
280-
Regions []Region
279+
Regions []Region
280+
StoreDiskCapacityBytes int64
281281
}
282282

283283
func (c ClusterInfo) String() (s string) {
@@ -380,7 +380,7 @@ func LoadClusterInfo(c ClusterInfo, settings *config.SimulationSettings) State {
380380
node.NodeID(),
381381
))
382382
} else {
383-
s.SetStoreCapacity(newStore.StoreID(), int64(c.DiskCapacityGB)*1<<30)
383+
s.SetStoreCapacity(newStore.StoreID(), c.StoreDiskCapacityBytes)
384384
}
385385
}
386386
}

pkg/kv/kvserver/asim/tests/datadriven_simulation_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,14 @@ func TestDataDriven(t *testing.T) {
257257
case "gen_cluster":
258258
var nodes = 3
259259
var storesPerNode = 1
260+
var storeByteCapacity int64 = 256 << 30 /* 256 GiB */
260261
scanIfExists(t, d, "nodes", &nodes)
261262
scanIfExists(t, d, "stores_per_node", &storesPerNode)
263+
scanIfExists(t, d, "store_byte_capacity", &storeByteCapacity)
262264
clusterGen = gen.BasicCluster{
263-
Nodes: nodes,
264-
StoresPerNode: storesPerNode,
265+
Nodes: nodes,
266+
StoresPerNode: storesPerNode,
267+
StoreByteCapacity: storeByteCapacity,
265268
}
266269
return ""
267270
case "load_cluster":

pkg/kv/kvserver/asim/tests/default_settings.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import (
1515
// disabled. For instance, defaultBasicRangesGen is only used if
1616
// randOption.range is false.
1717
const (
18-
defaultNodes = 3
19-
defaultStoresPerNode = 1
18+
defaultNodes = 3
19+
defaultStoresPerNode = 1
20+
defaultStoreByteCapacity = 256 << 30 // 256 GiB
2021
)
2122

2223
const (
@@ -41,6 +42,7 @@ const (
4142
type staticOptionSettings struct {
4243
nodes int
4344
storesPerNode int
45+
storeByteCapacity int64
4446
rwRatio float64
4547
rate float64
4648
minBlock int
@@ -61,6 +63,7 @@ func getDefaultStaticOptionSettings() staticOptionSettings {
6163
return staticOptionSettings{
6264
nodes: defaultNodes,
6365
storesPerNode: defaultStoresPerNode,
66+
storeByteCapacity: defaultStoreByteCapacity,
6467
rwRatio: defaultRwRatio,
6568
rate: defaultRate,
6669
minBlock: defaultMinBlock,
@@ -80,8 +83,9 @@ func getDefaultStaticOptionSettings() staticOptionSettings {
8083

8184
func (f randTestingFramework) defaultBasicClusterGen() gen.BasicCluster {
8285
return gen.BasicCluster{
83-
Nodes: f.defaultStaticSettings.nodes,
84-
StoresPerNode: f.defaultStaticSettings.storesPerNode,
86+
Nodes: f.defaultStaticSettings.nodes,
87+
StoresPerNode: f.defaultStaticSettings.storesPerNode,
88+
StoreByteCapacity: f.defaultStaticSettings.storeByteCapacity,
8589
}
8690
}
8791

pkg/kv/kvserver/asim/tests/output.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ func printTestSettings(t testSettings, staticSettings staticOptionSettings, buf
9696
buf.WriteString(fmt.Sprintf("\t%v\n", t.clusterGen))
9797
} else {
9898
buf.WriteString(configStr("cluster", "static"))
99-
buf.WriteString(fmt.Sprintf("\tnodes=%d, stores_per_node=%d\n", staticSettings.nodes, staticSettings.storesPerNode))
99+
buf.WriteString(fmt.Sprintf("\tnodes=%d, stores_per_node=%d, store_byte_capacity=%d\n",
100+
staticSettings.nodes, staticSettings.storesPerNode, staticSettings.storeByteCapacity))
100101
}
101102

102103
if t.randOptions.ranges {

pkg/kv/kvserver/asim/tests/rand_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ const (
113113
// - nodes (default value is 3): number of nodes in the generated cluster
114114
// - storesPerNode (default value is 1): number of store per nodes in the
115115
// generated cluster
116+
// - storeByteCapacity (default value is 256 << 30): disk capacity of each
117+
// store in the generated cluster
116118
// - rwRatio (default value is 0.0): read-write ratio of the generated load
117119
// - rate (default value is 0.0): rate at which the load is generated
118120
// - minBlock (default value is 1): min size of each load event
@@ -178,6 +180,7 @@ func TestRandomized(t *testing.T) {
178180
case "change_static_option":
179181
scanIfExists(t, d, "nodes", &staticOptionSettings.nodes)
180182
scanIfExists(t, d, "stores_per_node", &staticOptionSettings.storesPerNode)
183+
scanIfExists(t, d, "store_byte_capacity", &staticOptionSettings.storeByteCapacity)
181184
scanIfExists(t, d, "rw_ratio", &staticOptionSettings.rwRatio)
182185
scanIfExists(t, d, "rate", &staticOptionSettings.rate)
183186
scanIfExists(t, d, "min_block", &staticOptionSettings.minBlock)

pkg/kv/kvserver/asim/tests/testdata/non_rand/example_fulldisk

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,46 @@ OK
1919
# store 5. This is shown below as it sheds replicas.
2020
plot stat=replicas
2121
----
22-
340 ╭╮ ╭╮╭
23-
329 ╭╭─╭──╮╭─╮╭─╮╭─╭╮╭╭╮ ╭╮ ╭╮╮╭╭─╮─╭╭╮─╭╭╮╯╭╯
24-
319 ┤ ╭╮ ╭╮ ╭╮╭╭╮╭╮ ╭╮╭────╯─╯╰╯╭╰──────╮╭╯│─╭╯│╭╯╰╮╭╯╰│─╭╯│─╭╯╰─╯─
25-
308 ┤ ╭╭──╮╭╭────╯╰╮╭─╯╰╯╰╯ ╰╯ ╰╯ ╰─╰─╯╰╰╯╯╰─╯╰╰╯ ╰╯─╯╰─╯╰╰─╯╰╯ ╰
26-
297 ┼╮────────────────╯╭╯╰╭╮─╯╯╯╰╯╰╯││
27-
286 ┤╰───────────────╮╰╯ ││ ╰╯
28-
276 ┤ │╭─╮╭╯╰
29-
265╰╯ ╰╯ │╭─╮ ╭╮ ╭╮
30-
254 ╰╯ │ ││ ││
31-
243 ╰─╯╰─╯╰
32-
233 ╭╮ ╭╮
33-
222 ╰──╮ ╭╮ │╰╮╭╯│ ╭╮
34-
211 │ ╭─╮ ╭╮│╰╮╭╯ ││ ╰─╯│ ╭╮
35-
200╰╮│ │ ╭╮ │╰╯ ╰╯ ╰╯ ╰╮ │╰╮ ╭─╮╭──╮╭─╮ │
36-
190╰╯ ╰╮╭╯╰─╯ ╰─╯ │ │ ││ ││ ╰─╯
37-
179╰╯ ╰─╯ ╰╯
22+
342╭╮╭─╮╭╭╭─╮╭
23+
331╭╮ ╭╭─╮╮╭╮╭╭╮╭╭───╮─╭──╮╮ ╭╮──╭╭───╮─╮╭──╮╯╭╯╭╰╮╭╯│╰─
24+
319 ┤ ╭╭╮╭╮─╭─╭──╯╭│╭╭─────╯╯╰─│╭╯╮╭│╰─╭╮╭───╯╭─╯│╭─╯╭─╰─╯╰╯─╰╯╭╰╰╯
25+
308 ┤ ╭───╭──────╯╯╰╰╯╰─╯╰╯ ╰╯ ╰╯ ╰╯╰──╯╰╯ ╰╰╯╯ ╰╯ ╰╯ ╰╯
26+
296 ┼───────────────╮───╯╯╯╰╯
27+
285 ┤ ╰──╮
28+
274 │╭─╮
29+
262 ╰╯ ╭╮
30+
251╰╯╰╮ ╭╮
31+
239│╭╯│ ╭─
32+
228╰╯ ╰╮╭╮ ╭╮ ╭─╮ │ │ ╭╮ ╭╮
33+
217╰╯╰───╯│╭╯ │ ╭╮ ╭╮╭╯ ╰─╯╰╮╭╯│ ╭╮
34+
205╰╯ ╰╮╭─╯╰─╯╰╯ ╰╯ ╰╮ ╭╮ ││
35+
194 ││ ╰─╯╰─╯╰╮╭╮ ╭╮ ╭╮ ╭╮
36+
182 ╰╯ ╰╯╰╮│╰╮╭╯│ │╰
37+
171╯ ╰╯ ╰─
3838
replicas
3939
initial store values: [s1=300, s2=300, s3=300, s4=300, s5=300] (stddev=0.00, mean=300.00, sum=1500)
40-
last store values: [s1=313, s2=334, s3=317, s4=340, s5=211] (stddev=47.10, mean=303.00, sum=1515)
40+
last store values: [s1=342, s2=341, s3=326, s4=328, s5=178] (stddev=62.84, mean=303.00, sum=1515)
4141

4242
# Plot the % of disk storage capacity used. We should see s5 hovering right
4343
# around 92.5-95% (the storage capacity threshold value).
4444
plot stat=disk_fraction_used
4545
----
46-
1.09╭╮ ╭╮
47-
1.02╭─╮╭╮ ╭─╮ ╭╮ ╭─ ╭╮ ╭╮ ││ │╰╮ ╭╮ ╭─╮ ╭╮ ╭╮
48-
0.95 ┤ ╭────────╮ │ ││╰───╮╭╯ ╰─╯╰╮│ ╰╮╭─╮ ╭╮│╰╮╭╯╰╮╭╯│╭╯ │ │╰╮ │ │╭╯╰╮╭╯╰╮╭
49-
0.87 ┤ ╭──────── ╰─╯ ╰╯ ╰╯ ╰╯ ╰╯ ╰─╯╯ ╰╯ ╰╯ ╰╯ ╰─╯ ╰─╯ ╰╯ ╰╯ ╰╯
50-
0.80 ┼─╯
51-
0.73
52-
0.66
53-
0.58
54-
0.51
55-
0.44
56-
0.36
57-
0.29
58-
0.22
59-
0.15 ┤
60-
0.07 ┤
61-
0.00 ┼───────────────────────────────────────────────────────────────────────────────
46+
1.10╭╮ ╭╮ ╭╮ ╭╮
47+
1.04 ╭╮ ╭╮ │╰╮ ╭││ ╭╮ ╭╮ ││ ╭╮ ╭╮ ╭─╮ │╰
48+
0.97 ╭───╮╭─╮ ╭╮│╰╮╭╯╰╮╭╮╭╮ ╭╮ │ ╰╮╭╮││ ╭╮ │╰╮╭╯╰╮╭╯╰╮ ╭╮ │╰╮││ │╰╮│ │╭╯
49+
0.91 ╭──────╯ ╰╯ ╰─╯╰╯ ╰╯ ╰╯╰╯╰─╯│╭╯ ││╰╯╰─╯│╭╯ ╰╯ ╰╯ ╰─╯╰─╯ ╰╯╰─╯ ╰╯ ╰╯
50+
0.84 ┼────╯ ╰╯ ╰╯ ╰
51+
0.78
52+
0.71
53+
0.65
54+
0.59
55+
0.52
56+
0.46
57+
0.39
58+
0.33
59+
0.26 ┤ ╭╮ ╭╮╮╭─╭╭────╮╭───────────────
60+
0.20 ┤ ╭╮╭╭────────────────────────────╯╰──╯╰────╯─╯╰─╰╯──╯
61+
0.14 ┼──────────────────╯ ╰╯╰╯
6262
disk_fraction_used
63-
initial store values: [s1=0.00, s2=0.00, s3=0.00, s4=0.00, s5=0.83] (stddev=0.33, mean=0.17, sum=1)
64-
last store values: [s1=0.00, s2=0.00, s3=0.00, s4=0.00, s5=0.97] (stddev=0.39, mean=0.19, sum=1)
63+
initial store values: [s1=0.14, s2=0.14, s3=0.14, s4=0.14, s5=0.83] (stddev=0.28, mean=0.28, sum=1)
64+
last store values: [s1=0.28, s2=0.26, s3=0.25, s4=0.25, s5=1.00] (stddev=0.30, mean=0.41, sum=2)

pkg/kv/kvserver/asim/tests/testdata/rand/default_settings

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test settings
4545
num_iterations=3 duration=10m0s
4646
----------------------------------
4747
generating cluster configurations using static option
48-
nodes=3, stores_per_node=1
48+
nodes=3, stores_per_node=1, store_byte_capacity=274877906944
4949
generating ranges configurations using static option
5050
placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
5151
generating load configurations using static option
@@ -73,23 +73,23 @@ eval verbose=(config_gen)
7373
----------------------------------
7474
sample1: start running
7575
configurations generated using seed 3440579354231278675
76-
basic cluster with nodes=3, stores_per_node=1
76+
basic cluster with nodes=3, stores_per_node=1, store_byte_capacity=274877906944
7777
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
7878
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
7979
number of mutation events=0, number of assertion events=0
8080
sample1: pass
8181
----------------------------------
8282
sample2: start running
8383
configurations generated using seed 608747136543856411
84-
basic cluster with nodes=3, stores_per_node=1
84+
basic cluster with nodes=3, stores_per_node=1, store_byte_capacity=274877906944
8585
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
8686
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
8787
number of mutation events=0, number of assertion events=0
8888
sample2: pass
8989
----------------------------------
9090
sample3: start running
9191
configurations generated using seed 5571782338101878760
92-
basic cluster with nodes=3, stores_per_node=1
92+
basic cluster with nodes=3, stores_per_node=1, store_byte_capacity=274877906944
9393
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
9494
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
9595
number of mutation events=0, number of assertion events=0
@@ -161,7 +161,7 @@ test settings
161161
num_iterations=3 duration=10m0s
162162
----------------------------------
163163
generating cluster configurations using static option
164-
nodes=3, stores_per_node=1
164+
nodes=3, stores_per_node=1, store_byte_capacity=274877906944
165165
generating ranges configurations using static option
166166
placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
167167
generating load configurations using static option
@@ -171,7 +171,7 @@ generating settings configurations using static option
171171
----------------------------------
172172
sample1: start running
173173
configurations generated using seed 3440579354231278675
174-
basic cluster with nodes=3, stores_per_node=1
174+
basic cluster with nodes=3, stores_per_node=1, store_byte_capacity=274877906944
175175
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
176176
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
177177
number of mutation events=0, number of assertion events=0
@@ -181,7 +181,7 @@ sample1: pass
181181
----------------------------------
182182
sample2: start running
183183
configurations generated using seed 608747136543856411
184-
basic cluster with nodes=3, stores_per_node=1
184+
basic cluster with nodes=3, stores_per_node=1, store_byte_capacity=274877906944
185185
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
186186
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
187187
number of mutation events=0, number of assertion events=0
@@ -191,7 +191,7 @@ sample2: pass
191191
----------------------------------
192192
sample3: start running
193193
configurations generated using seed 5571782338101878760
194-
basic cluster with nodes=3, stores_per_node=1
194+
basic cluster with nodes=3, stores_per_node=1, store_byte_capacity=274877906944
195195
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
196196
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
197197
number of mutation events=0, number of assertion events=0
@@ -211,7 +211,7 @@ test settings
211211
num_iterations=3 duration=10m0s
212212
----------------------------------
213213
generating cluster configurations using static option
214-
nodes=3, stores_per_node=1
214+
nodes=3, stores_per_node=1, store_byte_capacity=274877906944
215215
generating ranges configurations using static option
216216
placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
217217
generating load configurations using static option
@@ -221,7 +221,7 @@ generating settings configurations using static option
221221
----------------------------------
222222
sample1: start running
223223
configurations generated using seed 3440579354231278675
224-
basic cluster with nodes=3, stores_per_node=1
224+
basic cluster with nodes=3, stores_per_node=1, store_byte_capacity=274877906944
225225
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
226226
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
227227
number of mutation events=0, number of assertion events=0
@@ -236,7 +236,7 @@ sample1: pass
236236
----------------------------------
237237
sample2: start running
238238
configurations generated using seed 608747136543856411
239-
basic cluster with nodes=3, stores_per_node=1
239+
basic cluster with nodes=3, stores_per_node=1, store_byte_capacity=274877906944
240240
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
241241
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
242242
number of mutation events=0, number of assertion events=0
@@ -251,7 +251,7 @@ sample2: pass
251251
----------------------------------
252252
sample3: start running
253253
configurations generated using seed 5571782338101878760
254-
basic cluster with nodes=3, stores_per_node=1
254+
basic cluster with nodes=3, stores_per_node=1, store_byte_capacity=274877906944
255255
basic ranges with placement_type=even, ranges=10, min_key=0, max_key=200000, replication_factor=3, bytes=0
256256
basic load with rw_ratio=0.00, rate=0.00, skewed_access=false, min_block_size=1, max_block_size=1, min_key=0, max_key=200000
257257
number of mutation events=0, number of assertion events=0
@@ -279,7 +279,7 @@ test settings
279279
num_iterations=3 duration=20m0s
280280
----------------------------------
281281
generating cluster configurations using static option
282-
nodes=5, stores_per_node=5
282+
nodes=5, stores_per_node=5, store_byte_capacity=274877906944
283283
generating ranges configurations using static option
284284
placement_type=skewed, ranges=2, min_key=0, max_key=10000, replication_factor=5, bytes=2
285285
generating load configurations using static option

0 commit comments

Comments
 (0)