Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions contrib/cmd/runkperf/commands/bench/node100_pod10k.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,20 @@ func benchNode100DeploymentNPod10KRun(cliCtx *cli.Context) (*internaltypes.Bench
// NOTE: The name pattern should be aligned with ../../../../internal/manifests/loadprofile/node100_pod10k.yaml.
deploymentNamePattern := "benchmark"

// TODO(xinwei): Implement batching support for deploying deployments after decoupling it from rolling update logic.
ruCleanupFn, err := utils.DeployDeployments(dpCtx,
kubeCfgPath, deploymentNamePattern, total, replica, paddingBytes, 10*time.Minute)
bm := utils.DeploymentBatchManager{
KubeCfgPath: kubeCfgPath,
DeploymentNamePattern: deploymentNamePattern,
DeploymentReplica: replica,
PaddingBytes: paddingBytes,
DeploymentBatchSize: 20,
}

err = bm.Add(dpCtx, total)
defer bm.CleanAll()

if err != nil {
return nil, fmt.Errorf("failed to setup workload: %w", err)
}
defer ruCleanupFn()

err = dumpDeploymentReplicas(ctx, kubeCfgPath, deploymentNamePattern, total)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- $pattern := .Values.namePattern }}
{{- $replica := int .Values.replica }}
{{- $paddingBytes := int .Values.paddingBytes }}
{{- range $index := (untilStep 0 (int .Values.total) 1) }}
{{- range $index := (untilStep (int .Values.start) (int (add (int .Values.start) (int .Values.total))) 1) }}
apiVersion: v1
kind: Namespace
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ namePattern: "benchmark"
total: 5
replica: 2000
paddingBytes: 0
start: 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove that last char.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the last char after '0'? Or move the '0' char?

3 changes: 2 additions & 1 deletion contrib/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func DeployDeployments(
ctx context.Context,
kubeCfgPath string,
releaseName string,
total, replica, paddingBytes int,
total, replica, paddingBytes, start int,
deployTimeout time.Duration,
) (cleanupFn func(), retErr error) {
infoLogger := log.GetLogger(ctx).WithKeyValues("level", "info")
Expand All @@ -148,6 +148,7 @@ func DeployDeployments(
fmt.Sprintf("total=%d", total),
fmt.Sprintf("replica=%d", replica),
fmt.Sprintf("paddingBytes=%d", paddingBytes),
fmt.Sprintf("start=%d", start),
),
)
if err != nil {
Expand Down
40 changes: 40 additions & 0 deletions contrib/utils/utils_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package utils

import (
"context"
"fmt"
"time"
)

Expand Down Expand Up @@ -61,5 +63,43 @@ func WithJobWaitTimeoutOpt(to time.Duration) JobTimeoutOpt {
func WithJobDeleteTimeoutOpt(to time.Duration) JobTimeoutOpt {
return func(jto *jobsTimeoutOption) {
jto.deleteTimeout = to

}
}

type DeploymentBatchManager struct {
KubeCfgPath string
DeploymentNamePattern string
DeploymentReplica int
PaddingBytes int
DeploymentBatchSize int
cleanups []func()
}

func (bm *DeploymentBatchManager) Add(ctx context.Context, total int) error {
for start := 0; start < total; start += bm.DeploymentBatchSize {
// Create a unique name for each deployment batch
namePattern := fmt.Sprintf("%s-%d", bm.DeploymentNamePattern, start/bm.DeploymentBatchSize)

// Calculate the current batch size, ensuring it does not exceed the total
currentBatchSize := bm.DeploymentBatchSize
if start+currentBatchSize > total {
currentBatchSize = total - start
}

cleanup, err := DeployDeployments(ctx, bm.KubeCfgPath, namePattern, currentBatchSize, bm.DeploymentReplica,
bm.PaddingBytes, start, 10*time.Minute)
if err != nil {
return err
}
// Store the cleanup function to be called later
bm.cleanups = append(bm.cleanups, cleanup)
}
return nil
}

func (bm *DeploymentBatchManager) CleanAll() {
for i := len(bm.cleanups) - 1; i >= 0; i-- {
bm.cleanups[i]()
}
}
Loading