-
Notifications
You must be signed in to change notification settings - Fork 7
Add a new runkperf bench for listing configmaps #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d7d7ef1
kperf: runner: Add --total-time flag to specify the duration for the …
xinWeiWei24 f7f4306
runkper/commands/bench: Add list_configmaps benchmark command to exec…
xinWeiWei24 48956b2
fix linter error
xinWeiWei24 0a1be89
Fix wrong comment
xinWeiWei24 e547f49
Replace benchConfigmapsCase with benchListConfigmapsCase
xinWeiWei24 d79b42f
Replace RunForDuration with RunForDuration
xinWeiWei24 db990a0
Note the unit of size in usage
xinWeiWei24 c7e5e97
list_configmaps: make usage succincter
xinWeiWei24 8cd9139
list_configmaps: Add group label in selector of requests
xinWeiWei24 764d99e
list_configmaps: Just use staleList and quorumList with same shares
xinWeiWei24 6050381
list_configmaps: Set profileCfg.Spec.Total if both Total and Duration…
xinWeiWei24 729e988
list_configmaps: Set default value of total flag
xinWeiWei24 6989d12
Update contrib/cmd/runkperf/commands/bench/list_configmaps.go
xinWeiWei24 608975a
Update cmd/kperf/commands/runner/runner.go
xinWeiWei24 61c2d52
Update api/types/load_traffic.go
xinWeiWei24 35c8698
runkperf/list_configmaps: Use timeout context instead of new function
xinWeiWei24 ab86e2d
kperf/runner: Use klog to print warning message
xinWeiWei24 ae1da5f
request/random: Delete useless function
xinWeiWei24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,134 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package bench | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
internaltypes "github.com/Azure/kperf/contrib/internal/types" | ||
"github.com/Azure/kperf/contrib/log" | ||
"github.com/Azure/kperf/contrib/utils" | ||
|
||
"github.com/urfave/cli" | ||
) | ||
|
||
var benchListConfigmapsCase = cli.Command{ | ||
Name: "list_configmaps", | ||
Usage: ` | ||
|
||
The test suite is to generate configmaps in a namespace and list them. The load profile is fixed. | ||
`, | ||
Flags: []cli.Flag{ | ||
cli.IntFlag{ | ||
Name: "size", | ||
xinWeiWei24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Usage: "The size of each configmap (Unit: KiB)", | ||
Value: 100, | ||
}, | ||
cli.IntFlag{ | ||
Name: "group-size", | ||
Usage: "The size of each configmap group", | ||
Value: 100, | ||
}, | ||
cli.IntFlag{ | ||
Name: "configmap-amount", | ||
Usage: "Total amount of configmaps", | ||
Value: 1024, | ||
}, | ||
cli.IntFlag{ | ||
Name: "total", | ||
Usage: "Total requests per runner (There are 10 runners totally and runner's rate is 10)", | ||
Value: 1000, | ||
}, | ||
cli.IntFlag{ | ||
Name: "duration", | ||
Usage: "Duration of the benchmark in seconds. It will be ignored if --total is set.", | ||
Value: 0, | ||
}, | ||
}, | ||
Action: func(cliCtx *cli.Context) error { | ||
_, err := renderBenchmarkReportInterceptor( | ||
addAPIServerCoresInfoInterceptor(benchListConfigmapsRun), | ||
)(cliCtx) | ||
return err | ||
}, | ||
} | ||
|
||
var benchConfigmapNamespace = "kperf-configmaps-bench" | ||
|
||
// benchfigmapsCase is for subcommand benchConfigmapsCase. | ||
func benchListConfigmapsRun(cliCtx *cli.Context) (*internaltypes.BenchmarkReport, error) { | ||
ctx := context.Background() | ||
kubeCfgPath := cliCtx.GlobalString("kubeconfig") | ||
|
||
rgCfgFile, rgSpec, rgCfgFileDone, err := newLoadProfileFromEmbed(cliCtx, | ||
"loadprofile/list_configmaps.yaml") | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer func() { _ = rgCfgFileDone() }() | ||
|
||
// Create a namespace for the benchmark | ||
cmAmount := cliCtx.Int("configmap-amount") | ||
cmSize := cliCtx.Int("size") | ||
cmGroupSize := cliCtx.Int("group-size") | ||
|
||
err = utils.CreateConfigmaps(ctx, kubeCfgPath, cmAmount, cmSize, cmGroupSize, benchConfigmapNamespace, 0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer func() { | ||
// Delete the configmaps after the benchmark | ||
err = utils.DeleteConfigmaps(ctx, kubeCfgPath, benchConfigmapNamespace, 0) | ||
if err != nil { | ||
log.GetLogger(ctx).WithKeyValues("level", "error"). | ||
LogKV("msg", fmt.Sprintf("Failed to delete configmaps: %v", err)) | ||
} | ||
|
||
// Delete the namespace after the benchmark | ||
kr := utils.NewKubectlRunner(kubeCfgPath, benchConfigmapNamespace) | ||
err := kr.DeleteNamespace(ctx, 0, benchConfigmapNamespace) | ||
if err != nil { | ||
log.GetLogger(ctx).WithKeyValues("level", "error"). | ||
LogKV("msg", fmt.Sprintf("Failed to delete namespace: %v", err)) | ||
} | ||
}() | ||
|
||
dpCtx, dpCancel := context.WithCancel(ctx) | ||
defer dpCancel() | ||
|
||
duration := cliCtx.Duration("duration") | ||
if duration != 0 { | ||
log.GetLogger(dpCtx). | ||
WithKeyValues("level", "info"). | ||
LogKV("msg", fmt.Sprintf("Running for %v seconds", duration.Seconds())) | ||
} | ||
|
||
rgResult, derr := utils.DeployRunnerGroup(ctx, | ||
cliCtx.GlobalString("kubeconfig"), | ||
cliCtx.GlobalString("runner-image"), | ||
rgCfgFile, | ||
cliCtx.GlobalString("runner-flowcontrol"), | ||
cliCtx.GlobalString("rg-affinity"), | ||
) | ||
|
||
if derr != nil { | ||
return nil, derr | ||
} | ||
|
||
return &internaltypes.BenchmarkReport{ | ||
Description: fmt.Sprintf(` | ||
Environment: Generate %v configmaps with %v bytes each in a namespace. | ||
Workload: List all configmaps in the namespace and get the percentile latency.`, | ||
cmAmount, cmSize), | ||
|
||
LoadSpec: *rgSpec, | ||
Result: *rgResult, | ||
Info: map[string]interface{}{ | ||
"configmapSizeInBytes": cmSize, | ||
"runningTime": duration.String(), | ||
}, | ||
}, nil | ||
} |
This file contains hidden or 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 hidden or 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
20 changes: 20 additions & 0 deletions
20
contrib/internal/manifests/loadprofile/list_configmaps.yaml
This file contains hidden or 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,20 @@ | ||
count: 10 | ||
loadProfile: | ||
version: 1 | ||
description: "list configmaps" | ||
spec: | ||
rate: 10 | ||
conns: 10 | ||
client: 10 | ||
contentType: json | ||
disableHTTP2: false | ||
maxRetries: 0 | ||
requests: | ||
- staleList: | ||
version: v1 | ||
resource: configmaps | ||
shares: 100 # chance 100 / (100 + 100) | ||
- quorumList: | ||
version: v1 | ||
resource: configmaps | ||
shares: 100 # chance 100 / (100 + 100) |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.