Skip to content

Commit

Permalink
cmd: add roachprod-microbench command
Browse files Browse the repository at this point in the history
Add command roachprod-microbench to the cmd package. This command depends on the
portable test binaries outputted from the dev test-binaries command.

In order to run multiple microbenchmark iterations with an acceptable overall
duration the roachprod-microbench command distributes microbenchmark executions
at a per microbenchmark function level to a roachprod cluster.

The command also handles the orchestration of copying and extracting the
portable binaries to the cluster. Failures and results are logged for each
microbenchmark. On completion a report is generated for further analysis.
Results from microbenchmarks are also sanitized to remove any noise in the log
output.

Additionally, comparisons to previous runs can be made. Google cloud storage can
be used to store the results of previous runs. The internal Go tooling is used
to do the comparison and output a Google Sheet to Google Drive for further
inspection.

Resolves: cockroachdb#90958
See also: cockroachdb#90837

Epic: CRDB-20903

Release note: None
  • Loading branch information
herkolategan committed Feb 6, 2023
1 parent ac65603 commit 9571e98
Show file tree
Hide file tree
Showing 17 changed files with 1,891 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
/pkg/cmd/returncheck/ @cockroachdb/dev-inf
/pkg/cmd/roachprod/ @cockroachdb/test-eng
/pkg/cmd/roachprod/vm/azure/auth.go @cockroachdb/test-eng @cockroachdb/prodsec
/pkg/cmd/roachprod-microbench/ @cockroachdb/test-eng
/pkg/cmd/roachprod-stress/ @cockroachdb/test-eng
/pkg/cmd/roachtest/ @cockroachdb/test-eng
/pkg/cmd/label-merged-pr/ @cockroachdb/dev-inf
Expand Down
9 changes: 9 additions & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ ALL_TESTS = [
"//pkg/cmd/reduce/reduce/reducesql:reducesql_test",
"//pkg/cmd/reduce/reduce:reduce_test",
"//pkg/cmd/release:release_test",
"//pkg/cmd/roachprod-microbench:roachprod-microbench_test",
"//pkg/cmd/roachtest/clusterstats:clusterstats_test",
"//pkg/cmd/roachtest/roachtestutil/mixedversion:mixedversion_test",
"//pkg/cmd/roachtest/tests:tests_test",
Expand Down Expand Up @@ -999,6 +1000,11 @@ GO_TARGETS = [
"//pkg/cmd/release:release_test",
"//pkg/cmd/returncheck:returncheck",
"//pkg/cmd/returncheck:returncheck_lib",
"//pkg/cmd/roachprod-microbench/cluster:cluster",
"//pkg/cmd/roachprod-microbench/google:google",
"//pkg/cmd/roachprod-microbench:roachprod-microbench",
"//pkg/cmd/roachprod-microbench:roachprod-microbench_lib",
"//pkg/cmd/roachprod-microbench:roachprod-microbench_test",
"//pkg/cmd/roachprod-stress:roachprod-stress",
"//pkg/cmd/roachprod-stress:roachprod-stress_lib",
"//pkg/cmd/roachprod:roachprod",
Expand Down Expand Up @@ -2479,6 +2485,9 @@ GET_X_DATA_TARGETS = [
"//pkg/cmd/release:get_x_data",
"//pkg/cmd/returncheck:get_x_data",
"//pkg/cmd/roachprod:get_x_data",
"//pkg/cmd/roachprod-microbench:get_x_data",
"//pkg/cmd/roachprod-microbench/cluster:get_x_data",
"//pkg/cmd/roachprod-microbench/google:get_x_data",
"//pkg/cmd/roachprod-stress:get_x_data",
"//pkg/cmd/roachtest:get_x_data",
"//pkg/cmd/roachtest/cluster:get_x_data",
Expand Down
71 changes: 36 additions & 35 deletions pkg/cmd/dev/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,41 +73,42 @@ func makeBuildCmd(runE func(cmd *cobra.Command, args []string) error) *cobra.Com

// buildTargetMapping maintains shorthands that map 1:1 with bazel targets.
var buildTargetMapping = map[string]string{
"bazel-remote": bazelRemoteTarget,
"buildifier": "@com_github_bazelbuild_buildtools//buildifier:buildifier",
"buildozer": "@com_github_bazelbuild_buildtools//buildozer:buildozer",
"cockroach": "//pkg/cmd/cockroach:cockroach",
"cockroach-sql": "//pkg/cmd/cockroach-sql:cockroach-sql",
"cockroach-oss": "//pkg/cmd/cockroach-oss:cockroach-oss",
"cockroach-short": "//pkg/cmd/cockroach-short:cockroach-short",
"crlfmt": "@com_github_cockroachdb_crlfmt//:crlfmt",
"dev": devTarget,
"docgen": "//pkg/cmd/docgen:docgen",
"docs-issue-gen": "//pkg/cmd/docs-issue-generation:docs-issue-generation",
"execgen": "//pkg/sql/colexec/execgen/cmd/execgen:execgen",
"gofmt": "@com_github_cockroachdb_gostdlib//cmd/gofmt:gofmt",
"goimports": "@com_github_cockroachdb_gostdlib//x/tools/cmd/goimports:goimports",
"label-merged-pr": "//pkg/cmd/label-merged-pr:label-merged-pr",
"geos": geosTarget,
"langgen": "//pkg/sql/opt/optgen/cmd/langgen:langgen",
"libgeos": geosTarget,
"obsservice": "//pkg/obsservice/cmd/obsservice:obsservice",
"optgen": "//pkg/sql/opt/optgen/cmd/optgen:optgen",
"optfmt": "//pkg/sql/opt/optgen/cmd/optfmt:optfmt",
"oss": "//pkg/cmd/cockroach-oss:cockroach-oss",
"reduce": "//pkg/cmd/reduce:reduce",
"roachprod": "//pkg/cmd/roachprod:roachprod",
"roachprod-stress": "//pkg/cmd/roachprod-stress:roachprod-stress",
"roachtest": "//pkg/cmd/roachtest:roachtest",
"short": "//pkg/cmd/cockroach-short:cockroach-short",
"smith": "//pkg/cmd/smith:smith",
"smithcmp": "//pkg/cmd/smithcmp:smithcmp",
"smithtest": "//pkg/cmd/smithtest:smithtest",
"staticcheck": "@co_honnef_go_tools//cmd/staticcheck:staticcheck",
"stress": stressTarget,
"swagger": "@com_github_go_swagger_go_swagger//cmd/swagger:swagger",
"tests": "//pkg:all_tests",
"workload": "//pkg/cmd/workload:workload",
"bazel-remote": bazelRemoteTarget,
"buildifier": "@com_github_bazelbuild_buildtools//buildifier:buildifier",
"buildozer": "@com_github_bazelbuild_buildtools//buildozer:buildozer",
"cockroach": "//pkg/cmd/cockroach:cockroach",
"cockroach-sql": "//pkg/cmd/cockroach-sql:cockroach-sql",
"cockroach-oss": "//pkg/cmd/cockroach-oss:cockroach-oss",
"cockroach-short": "//pkg/cmd/cockroach-short:cockroach-short",
"crlfmt": "@com_github_cockroachdb_crlfmt//:crlfmt",
"dev": devTarget,
"docgen": "//pkg/cmd/docgen:docgen",
"docs-issue-gen": "//pkg/cmd/docs-issue-generation:docs-issue-generation",
"execgen": "//pkg/sql/colexec/execgen/cmd/execgen:execgen",
"gofmt": "@com_github_cockroachdb_gostdlib//cmd/gofmt:gofmt",
"goimports": "@com_github_cockroachdb_gostdlib//x/tools/cmd/goimports:goimports",
"label-merged-pr": "//pkg/cmd/label-merged-pr:label-merged-pr",
"geos": geosTarget,
"langgen": "//pkg/sql/opt/optgen/cmd/langgen:langgen",
"libgeos": geosTarget,
"obsservice": "//pkg/obsservice/cmd/obsservice:obsservice",
"optgen": "//pkg/sql/opt/optgen/cmd/optgen:optgen",
"optfmt": "//pkg/sql/opt/optgen/cmd/optfmt:optfmt",
"oss": "//pkg/cmd/cockroach-oss:cockroach-oss",
"reduce": "//pkg/cmd/reduce:reduce",
"roachprod": "//pkg/cmd/roachprod:roachprod",
"roachprod-stress": "//pkg/cmd/roachprod-stress:roachprod-stress",
"roachprod-microbench": "//pkg/cmd/roachprod-microbench:roachprod-microbench",
"roachtest": "//pkg/cmd/roachtest:roachtest",
"short": "//pkg/cmd/cockroach-short:cockroach-short",
"smith": "//pkg/cmd/smith:smith",
"smithcmp": "//pkg/cmd/smithcmp:smithcmp",
"smithtest": "//pkg/cmd/smithtest:smithtest",
"staticcheck": "@co_honnef_go_tools//cmd/staticcheck:staticcheck",
"stress": stressTarget,
"swagger": "@com_github_go_swagger_go_swagger//cmd/swagger:swagger",
"tests": "//pkg:all_tests",
"workload": "//pkg/cmd/workload:workload",
}

// allBuildTargets is a sorted list of all the available build targets.
Expand Down
51 changes: 51 additions & 0 deletions pkg/cmd/roachprod-microbench/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
name = "roachprod-microbench_lib",
srcs = [
"benchmark.go",
"compare.go",
"main.go",
"metadata.go",
"report.go",
"storage.go",
],
importpath = "github.com/cockroachdb/cockroach/pkg/cmd/roachprod-microbench",
visibility = ["//visibility:private"],
deps = [
"//pkg/cmd/roachprod-microbench/cluster",
"//pkg/cmd/roachprod-microbench/google",
"//pkg/roachprod",
"//pkg/roachprod/logger",
"//pkg/roachprod/ssh",
"//pkg/roachprod/vm",
"//pkg/util/syncutil",
"//pkg/util/timeutil",
"@com_github_cockroachdb_errors//:errors",
"@com_github_klauspost_compress//gzip",
"@com_google_cloud_go_storage//:storage",
"@org_golang_x_perf//benchstat",
"@org_golang_x_perf//storage/benchfmt",
],
)

go_binary(
name = "roachprod-microbench",
embed = [":roachprod-microbench_lib"],
visibility = ["//visibility:public"],
)

go_test(
name = "roachprod-microbench_test",
srcs = ["benchmark_test.go"],
args = ["-test.timeout=295s"],
data = glob(["testdata/**"]),
embed = [":roachprod-microbench_lib"],
deps = [
"//pkg/testutils/datapathutils",
"@com_github_cockroachdb_datadriven//:datadriven",
],
)

get_x_data(name = "get_x_data")
40 changes: 40 additions & 0 deletions pkg/cmd/roachprod-microbench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Name
**roachprod-microbench** - Execute microbenchmarks across a `roachprod` cluster

## Synopsis
**roachprod-microbench** `<working dir> [<flags>] -- [<test args>]`

## Examples
> **roachprod-microbench** ./artifacts/log -binaries=bin.tar.gz -cluster=user-bench -- -test.benchtime=1ns
Execute microbenchmarks present in the `bin.tar.gz` archive across the `user-bench` roachprod cluster.

Pass the additional test argument `-test.benchtime=1ns` to all executions.

Microbenchmark results are written to the `./artifacts/log` directory. This directory will also contain logs for any failures that occurred.

> **roachprod-microbench** ./artifacts/log -binaries=bin.tar.gz -cluster=user-bench -publishdir=gs://microbench/2042
Publish the logs captured from the microbenchmarks in the `<working dir>` `./artifacts/log` to a GCS bucket `gs://microbench/2042`.

> **roachprod-microbench** ./artifacts/log -binaries=bin.tar.gz -cluster=user-bench -comparedir=gs://microbench/1899
Compare the logs captured from the microbenchmarks in the `<working dir>` `./artifacts/log` to a GCS bucket `gs://microbench/1899` of a previously published **roachprod-microbench** run.

## Description

The **roachprod-microbench** command operates on a portable test binaries archive that has been built with the `dev test-binaries` tooling.
Compressed and uncompressed `tar` archives are supported, since the `dev` tooling can produce both.
It should be noted that the archive has to adhere to a specific layout and contains `run.sh` scripts for each package, which facilitates execution.
This tool only supports binaries archives produced in this format by the `dev test-binaries` tooling.

As part of the orchestration, test binaries are copied to the target cluster and extracted.
Once the cluster is ready, the tool will first probe for all microbenchmarks available and then execute the microbenchmarks according to any flags that have been set.

The `<working dir>` must always be specified and all results from the microbenchmarks will be captured to this directory, including any errors.
If the `publishdir` or `comparedir` flags are specified these will also use the `<working dir>` to publish from or compare against.

The publish functionality is used to store the results of a run to a specified location.
On a subsequent run the compare functionality can then be pointed to that same location to do a comparison which will publish Google sheets for further inspection.

For additional information on flags, run the **roachprod-microbench** command without any arguments to display a helpful message.
Loading

0 comments on commit 9571e98

Please sign in to comment.