summaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2020-07-13 13:23:50 -0700
committergVisor bot <gvisor-bot@google.com>2020-07-13 13:29:30 -0700
commitb8d3d09bd16f1f6d684ce2ca6f16109567cb0fc2 (patch)
treebfe9865e48342ce87d7575c249502061754fb765 /scripts
parent505b4f5e5f84f5379720966b6b5adaf00178690c (diff)
Initial golang Benchmarks
PiperOrigin-RevId: 321021071
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/benchmark.sh33
-rwxr-xr-xscripts/common.sh27
-rwxr-xr-xscripts/common_build.sh2
-rwxr-xr-xscripts/packetdrill_tests.sh2
-rwxr-xr-xscripts/packetimpact_tests.sh2
5 files changed, 39 insertions, 27 deletions
diff --git a/scripts/benchmark.sh b/scripts/benchmark.sh
index e0f6df438..c49f988b8 100755
--- a/scripts/benchmark.sh
+++ b/scripts/benchmark.sh
@@ -16,30 +16,15 @@
source $(dirname $0)/common.sh
-# gcloud may be installed as a "snap". If it is, include it in PATH.
-declare -r snap="/snap/bin"
-if [[ -d "${snap}" ]]; then
- export PATH="${PATH}:${snap}"
-fi
-
-# Make sure we can find gcloud and exit if not.
-which gcloud
+make load-all-images
-# Exporting for subprocesses as GCP APIs and tools check this environmental
-# variable for authentication.
-export GOOGLE_APPLICATION_CREDENTIALS="${KOKORO_KEYSTORE_DIR}/${GCLOUD_CREDENTIALS}"
-
-gcloud auth activate-service-account \
- --key-file "${GOOGLE_APPLICATION_CREDENTIALS}"
+if [[ -z "${1:-}" ]]; then
+ target=$(query "attr(tags, manual, tests(//test/benchmarks/...))")
+else
+ target="$1"
+fi
-gcloud config set project ${PROJECT}
-gcloud config set compute/zone ${ZONE}
+install_runsc_for_benchmarks benchmark
-bazel run //benchmarks:benchmarks -- \
- --verbose \
- run-gcp \
- "(startup|absl)" \
- --internal \
- --runtime=runc \
- --runtime=runsc \
- --installers=head
+echo $target
+benchmark_runsc $target "${@:2}"
diff --git a/scripts/common.sh b/scripts/common.sh
index 3ca699e4a..36158654f 100755
--- a/scripts/common.sh
+++ b/scripts/common.sh
@@ -42,6 +42,15 @@ function test_runsc() {
test --test_arg=--runtime=${RUNTIME} "$@"
}
+function benchmark_runsc() {
+ test_runsc -c opt \
+ --nocache_test_results \
+ --test_arg=-test.bench=. \
+ --test_arg=-test.benchmem \
+ --jobs=1 \
+ "$@"
+}
+
function install_runsc_for_test() {
local -r test_name=$1
shift
@@ -63,6 +72,24 @@ function install_runsc_for_test() {
"$@"
}
+function install_runsc_for_benchmarks() {
+ local -r test_name=$1
+ shift
+ if [[ -z "${test_name}" ]]; then
+ echo "Missing mandatory test name"
+ exit 1
+ fi
+
+ # Add test to the name, so it doesn't conflict with other runtimes.
+ set_runtime $(find_branch_name)_"${test_name}"
+
+ # ${RUNSC_TEST_NAME} is set by tests (see dockerutil) to pass the test name
+ # down to the runtime.
+ install_runsc "${RUNTIME}" \
+ --TESTONLY-test-name-env=RUNSC_TEST_NAME \
+ "$@"
+}
+
# Installs the runsc with given runtime name. set_runtime must have been called
# to set runtime and logs location.
function install_runsc() {
diff --git a/scripts/common_build.sh b/scripts/common_build.sh
index 0d9a191b5..f4210a3f3 100755
--- a/scripts/common_build.sh
+++ b/scripts/common_build.sh
@@ -64,7 +64,7 @@ function run_as_root() {
}
function query() {
- QUERY_RESULT=$(bazel query "$@")
+ bazel query "$@"
}
function collect_logs() {
diff --git a/scripts/packetdrill_tests.sh b/scripts/packetdrill_tests.sh
index 727503bce..1a8181ac8 100755
--- a/scripts/packetdrill_tests.sh
+++ b/scripts/packetdrill_tests.sh
@@ -19,5 +19,5 @@ source $(dirname $0)/common.sh
make load-packetdrill
install_runsc_for_test runsc-d
-query "attr(tags, manual, tests(//test/packetdrill/...))"
+QUERY_RESULT=$(query "attr(tags, manual, tests(//test/packetdrill/...))")
test_runsc $QUERY_RESULT
diff --git a/scripts/packetimpact_tests.sh b/scripts/packetimpact_tests.sh
index 51c11f23f..77fb84bc3 100755
--- a/scripts/packetimpact_tests.sh
+++ b/scripts/packetimpact_tests.sh
@@ -19,5 +19,5 @@ source $(dirname $0)/common.sh
make load-packetimpact
install_runsc_for_test runsc-d
-query "attr(tags, packetimpact, tests(//test/packetimpact/...))"
+QUERY_RESULT=$(query "attr(tags, packetimpact, tests(//test/packetimpact/...))")
test_runsc $QUERY_RESULT