Skip to content

Commit 6a031d3

Browse files
authored
feat: ycsb support request distribution (#60)
1 parent 4de75a6 commit 6a031d3

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

api/v1alpha1/ycsb_types.go

+24
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,30 @@ type YcsbSpec struct {
7272
// +optional
7373
ScanProportion int `json:"scanProportion,omitempty"`
7474

75+
// the distribution of requests accross the keyspace.
76+
// uniform: each key has an equal probability of being accessed.
77+
// sequential: keys are accessed in sequential order.
78+
// zipfian: some keys are accessed more frequently than others.
79+
// latest: the most recently inserted keys are accessed more frequently.
80+
// hotspot: a small number of keys are accessed more frequently.
81+
// exponential: keys are accessed in an exponential distribution.
82+
// +kubebuilder:validation:Enum={uniform,sequential,zipfian,latest,hotspot,exponential}
83+
// +kubebuilder:default=uniform
84+
// +optional
85+
RequestDistribution string `json:"requestDistribution,omitempty"`
86+
87+
// the distribution of scan lengths
88+
// +kubebuilder:validation:Enum={uniform,zipfian}
89+
// +kubebuilder:default=uniform
90+
// +optional
91+
ScanLengthDistribution string `json:"scanLengthDistribution,omitempty"`
92+
93+
// the distribution of field lengths
94+
// +kubebuilder:validation:Enum={constant,uniform,zipfian,histogram}
95+
// +kubebuilder:default=constant
96+
// +optional
97+
FieldLengthDistribution string `json:"fieldLengthDistribution,omitempty"`
98+
7599
// the number of threads
76100
// +kubebuilder:validation:MinItems=1
77101
// +kubebuilder:default={1}

config/crd/bases/benchmark.apecloud.io_ycsbs.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ spec:
4242
items:
4343
type: string
4444
type: array
45+
fieldLengthDistribution:
46+
default: constant
47+
enum:
48+
- constant
49+
- uniform
50+
- zipfian
51+
- histogram
52+
type: string
4553
insertProportion:
4654
default: 0
4755
maximum: 100
@@ -65,6 +73,16 @@ spec:
6573
default: 10000
6674
minimum: 1
6775
type: integer
76+
requestDistribution:
77+
default: uniform
78+
enum:
79+
- uniform
80+
- sequential
81+
- zipfian
82+
- latest
83+
- hotspot
84+
- exponential
85+
type: string
6886
resourceLimits:
6987
properties:
7088
cpu:
@@ -79,6 +97,12 @@ spec:
7997
memory:
8098
type: string
8199
type: object
100+
scanLengthDistribution:
101+
default: uniform
102+
enum:
103+
- uniform
104+
- zipfian
105+
type: string
82106
scanProportion:
83107
default: 0
84108
maximum: 100

deploy/helm/crds/benchmark.apecloud.io_ycsbs.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ spec:
4242
items:
4343
type: string
4444
type: array
45+
fieldLengthDistribution:
46+
default: constant
47+
enum:
48+
- constant
49+
- uniform
50+
- zipfian
51+
- histogram
52+
type: string
4553
insertProportion:
4654
default: 0
4755
maximum: 100
@@ -65,6 +73,16 @@ spec:
6573
default: 10000
6674
minimum: 1
6775
type: integer
76+
requestDistribution:
77+
default: uniform
78+
enum:
79+
- uniform
80+
- sequential
81+
- zipfian
82+
- latest
83+
- hotspot
84+
- exponential
85+
type: string
6886
resourceLimits:
6987
properties:
7088
cpu:
@@ -79,6 +97,12 @@ spec:
7997
memory:
8098
type: string
8199
type: object
100+
scanLengthDistribution:
101+
default: uniform
102+
enum:
103+
- uniform
104+
- zipfian
105+
type: string
82106
scanProportion:
83107
default: 0
84108
maximum: 100

internal/controller/ycsb_job.go

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ func NewYcsbPrepareJobs(cr *v1alpha1.Ycsb) []*batchv1.Job {
8282
cmd = fmt.Sprintf("%s -p recordcount=%d", cmd, cr.Spec.RecordCount)
8383
cmd = fmt.Sprintf("%s -p operationcount=%d", cmd, cr.Spec.OperationCount)
8484
cmd = fmt.Sprintf("%s -p threadcount=%d", cmd, cr.Spec.Threads[0])
85+
cmd = fmt.Sprintf("%s -p requestdistribution=%s", cmd, cr.Spec.RequestDistribution)
86+
cmd = fmt.Sprintf("%s -p scanlengthdistribution=%s", cmd, cr.Spec.ScanLengthDistribution)
87+
cmd = fmt.Sprintf("%s -p fieldlengthdistribution=%s", cmd, cr.Spec.FieldLengthDistribution)
8588
cmd = fmt.Sprintf("%s %s", cmd, strings.Join(cr.Spec.ExtraArgs, " "))
8689
cmd = fmt.Sprintf("%s 2>&1 | tee /var/log/ycsb.log", cmd)
8790

@@ -115,6 +118,9 @@ func NewYcsbRunJobs(cr *v1alpha1.Ycsb) []*batchv1.Job {
115118
cmd = fmt.Sprintf("%s %s", cmd, NewYcsbWorkloadParams(cr))
116119
cmd = fmt.Sprintf("%s -p recordcount=%d", cmd, cr.Spec.RecordCount)
117120
cmd = fmt.Sprintf("%s -p operationcount=%d", cmd, cr.Spec.OperationCount)
121+
cmd = fmt.Sprintf("%s -p requestdistribution=%s", cmd, cr.Spec.RequestDistribution)
122+
cmd = fmt.Sprintf("%s -p scanlengthdistribution=%s", cmd, cr.Spec.ScanLengthDistribution)
123+
cmd = fmt.Sprintf("%s -p fieldlengthdistribution=%s", cmd, cr.Spec.FieldLengthDistribution)
118124
cmd = fmt.Sprintf("%s %s", cmd, strings.Join(cr.Spec.ExtraArgs, " "))
119125

120126
totalProportion := cr.Spec.ReadProportion + cr.Spec.UpdateProportion + cr.Spec.InsertProportion + cr.Spec.ReadModifyWriteProportion + cr.Spec.ScanProportion

0 commit comments

Comments
 (0)