mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
scheduler_perf: create sleep operation
This commit is contained in:
parent
7bde4baac4
commit
b7b94b6b39
@ -60,6 +60,7 @@ const (
|
|||||||
createPodSetsOpcode = "createPodSets"
|
createPodSetsOpcode = "createPodSets"
|
||||||
churnOpcode = "churn"
|
churnOpcode = "churn"
|
||||||
barrierOpcode = "barrier"
|
barrierOpcode = "barrier"
|
||||||
|
sleepOpcode = "sleep"
|
||||||
extensionPointsLabelName = "extension_point"
|
extensionPointsLabelName = "extension_point"
|
||||||
|
|
||||||
// Two modes supported in "churn" operator.
|
// Two modes supported in "churn" operator.
|
||||||
@ -208,7 +209,7 @@ func (op *op) UnmarshalJSON(b []byte) error {
|
|||||||
&createPodSetsOp{},
|
&createPodSetsOp{},
|
||||||
&churnOp{},
|
&churnOp{},
|
||||||
&barrierOp{},
|
&barrierOp{},
|
||||||
// TODO(#93793): add a sleep timer op to simulate waiting?
|
&sleepOp{},
|
||||||
// TODO(#94601): add a delete nodes op to simulate scaling behaviour?
|
// TODO(#94601): add a delete nodes op to simulate scaling behaviour?
|
||||||
}
|
}
|
||||||
var firstError error
|
var firstError error
|
||||||
@ -511,6 +512,44 @@ func (bo barrierOp) patchParams(w *workload) (realOp, error) {
|
|||||||
return &bo, nil
|
return &bo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sleepOp defines an op that can be used to sleep for a specified amount of time.
|
||||||
|
// This is useful in simulating workloads that require some sort of time-based synchronisation.
|
||||||
|
type sleepOp struct {
|
||||||
|
// Must be "sleep".
|
||||||
|
Opcode string
|
||||||
|
// duration of sleep.
|
||||||
|
Duration time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
func (so *sleepOp) UnmarshalJSON(data []byte) (err error) {
|
||||||
|
var tmp struct {
|
||||||
|
Opcode string
|
||||||
|
Duration string
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(data, &tmp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
so.Opcode = tmp.Opcode
|
||||||
|
so.Duration, err = time.ParseDuration(tmp.Duration)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (so *sleepOp) isValid(_ bool) error {
|
||||||
|
if so.Opcode != sleepOpcode {
|
||||||
|
return fmt.Errorf("invalid opcode %q; expected %q", so.Opcode, sleepOpcode)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (so *sleepOp) collectsMetrics() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (so sleepOp) patchParams(_ *workload) (realOp, error) {
|
||||||
|
return &so, nil
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkPerfScheduling(b *testing.B) {
|
func BenchmarkPerfScheduling(b *testing.B) {
|
||||||
testCases, err := getTestCases(configFile)
|
testCases, err := getTestCases(configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -809,6 +848,11 @@ func runWorkload(b *testing.B, tc *testCase, w *workload) []DataItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case *sleepOp:
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
case <-time.After(concreteOp.Duration):
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
b.Fatalf("op %d: invalid op %v", opIndex, concreteOp)
|
b.Fatalf("op %d: invalid op %v", opIndex, concreteOp)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user