-
Notifications
You must be signed in to change notification settings - Fork 89
Dockerized benchmarking framework #337
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 all commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
7e2c064
Request header option: fix a bug in handling ':'
oschaaf a750487
WIP: extend benchmarking tests
oschaaf dbd8aaa
Merge remote-tracking branch 'upstream/master' into extend-benchmarking
oschaaf 8304ee2
Fix import path in nighthawk_grpc_service.py
oschaaf c1b2660
Save state on Envoy CI integration work
oschaaf c0f7eb2
minimize diff
oschaaf 740fc59
update benchmark/README.md
oschaaf 0971a8d
update benchmark/README.md
oschaaf 82160ab
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf dfed07c
benchmarking: save state on running with docker and inject Envoy
oschaaf 46f1a42
Expectation for changed host & multiserver feature
oschaaf 0387f47
Leanify benchmarks/ BUILD. Update README.md
oschaaf 6ff475a
remove docker volume we don't need
oschaaf c2b34c5
save state on structing output layout in tmp
oschaaf 14e6ee2
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf 1fd2b8b
Save state: small cleanup & simplification
oschaaf 74578ca
save state on some small cleanup
oschaaf 7d428b7
Fixes for running benchmark directly via bazel test...
oschaaf f955a1f
Save state.
oschaaf 7bdb4b5
Save state
oschaaf 0ae0c60
Save state
oschaaf 1ba6686
format & dump nighthawk outputs to disk
oschaaf 748d770
Fix python requirements
oschaaf 1dd5448
Initial dockerization of benchmarks
oschaaf d3ccf66
Improve runfiles path handling
oschaaf fe55e0f
Fix sni config paths
oschaaf 666902f
Docker build: flatten symlinks
oschaaf 1b373a3
Add ENV var defaults, fix typo in env var name.
oschaaf 32f4024
Save fully dockerized example sourcing external benchmarks.
oschaaf fd436bd
Update readme
oschaaf 0e4c9ec
fix for moved test file
oschaaf 2ecd622
dump html output
oschaaf 80fd30a
add html
oschaaf a96d9ce
A round of feedback procaessing
oschaaf 06bb404
Review feedback. Also drop software versions into test output.
oschaaf 901b461
Merge branch 'ci-profiling-dump-html' into ci-integration
oschaaf fa76428
Review feedback + small cleanup
oschaaf b06cedf
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf 6a18c37
Review feedback & diff minimizations
oschaaf 605e5ce
Back out yaml parsing for cert substitution
oschaaf 637c318
Attempt CI benchmark test with own binaries
oschaaf b11b1c1
Tweak CI benchmark task
oschaaf 2664210
Tweak CI benchmark task II
oschaaf 0fbea04
Attempt to get benchmarks artifacts uploaded
oschaaf c86048d
Clean up artifacts dir before upload
oschaaf cc2ec03
Debug why cleanup does not delete tmp.*
oschaaf 70258af
Fix cleanup & tighten up bash options in do_ci.sh
oschaaf 01e7aa6
Fixes for unbound variables
oschaaf 5b5b64d
Less strict asserts in benchmarks. Add trap for cleaning up.
oschaaf b558a75
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf 611c9b3
Remove test.sh & remove reference to my personal home dir
oschaaf 413a531
Review feedback + small enhancements
oschaaf 6425d23
Update README.md
oschaaf cc14e9f
simple_plot.html: add bar chars for count
oschaaf 7c637f9
Update visual example from CI grabbed sample
oschaaf 345972b
Inline ssl cert injection into yaml configs
oschaaf 2576517
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf be72bdd
Merge remote-tracking branch 'origin/master' into ci-integration
oschaaf 6de8c06
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf 6304653
Save state
oschaaf 85334fb
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf c24062f
Review feedback + docker run fix
oschaaf fa75665
Formatting fix & make proxy_config private
oschaaf 08fb5d8
Review feedback: EnvoyProxy - point out an example
oschaaf 8caf8d5
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf 9f61f72
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf b1d5634
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf a294f29
Review feedback
oschaaf 23d9090
Merge remote-tracking branch 'upstream/master' into ci-integration
oschaaf 9e10892
Expose nighthawk_client_path as we need it now
oschaaf 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 @@ | ||
| tmp/* |
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 |
|---|---|---|
| @@ -1,21 +1,38 @@ | ||
| load("@rules_python//python:defs.bzl", "py_test") | ||
| load( | ||
| "@envoy//bazel:envoy_build_system.bzl", | ||
| "envoy_package", | ||
| ) | ||
| load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") | ||
|
|
||
| licenses(["notice"]) # Apache 2 | ||
|
|
||
| envoy_package() | ||
| py_binary( | ||
| name = "benchmarks", | ||
| srcs = [ | ||
| "benchmarks.py", | ||
| ], | ||
| deps = [ | ||
| ":benchmarks_envoy_proxy_lib", | ||
| "//test/integration:integration_test_base_lean", | ||
| ], | ||
| ) | ||
|
|
||
| py_test( | ||
| name = "benchmarks", | ||
| name = "test_benchmarks", | ||
| srcs = [ | ||
| "benchmarks.py", | ||
| "test_benchmark.py", | ||
| "test/test_discovery.py", | ||
| ], | ||
| main = "benchmarks.py", | ||
| deps = [ | ||
| ":benchmarks_envoy_proxy_lib", | ||
| "//test/integration:integration_test_base", | ||
| "//test/integration:test_integration_basics_lib", | ||
| ], | ||
| ) | ||
|
|
||
| py_library( | ||
| name = "benchmarks_envoy_proxy_lib", | ||
| srcs = [ | ||
| "envoy_proxy.py", | ||
| ], | ||
| data = [ | ||
| "configurations/envoy_proxy.yaml", | ||
| "test/templates/simple_plot.html", | ||
| ], | ||
| ) |
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,130 @@ | ||
| # Benchmarking testsuite | ||
|
|
||
| The NH benchmark test suite builds on top Nighthawk's integration test framework, and | ||
| can be used to scaffold tests and obtain latency reports as well as flamegraphs. | ||
|
|
||
| ## Immediate goals | ||
|
|
||
| The goal is to be able to: | ||
|
|
||
| - facilitate integration into CI flows (via fully dockerized flow) | ||
| - facilitate A/B testing by developers | ||
| - run the suite against arbitrary Envoy revisions | ||
| - persist profile dumps, flamegraphs, and latency numbers per test | ||
| - offer stock tests, but also allow scaffolding consumer-specific tests | ||
|
|
||
| ## Example output visualization | ||
|
|
||
| The benchmark will drop a visual in each test directory. | ||
|
|
||
|  | ||
|
|
||
| ## Example: Docker based execution, scavaging benchmark/ | ||
|
|
||
| This scripts shows how to use the benchmarking suite. | ||
| It will run a selection of an example [benchmarks](test/test_discovery.py) | ||
| extracted from `/benchmarks`, which injects Envoy between the benchmark client and test server. | ||
|
|
||
| ```bash | ||
| git clone https://github.com/oschaaf/nighthawk.git benchmark-test | ||
| cd benchmark-test | ||
| bazel build //benchmarks:benchmarks | ||
|
|
||
| # Specify the ip address family we'll be using. [v4only|v6only|all] | ||
| export ENVOY_IP_TEST_VERSIONS=v4only | ||
| # Explicit tmpdir for OSX Docker, to make sure we'll use a volume that works when | ||
| export TMPDIR="$(pwd)/benchmarks/tmp" | ||
| # Nighthawk tools will be sourced from this Docker image | ||
| export NH_DOCKER_IMAGE="envoyproxy/nighthawk-dev:latest" | ||
| # Envoy Docker image that we'll use to inject the Envoy proxy | ||
| export ENVOY_DOCKER_IMAGE_TO_TEST="envoyproxy/envoy-dev:74290ef76a76fbbf50f072dc33438791f93f68c7" | ||
| # Envoy is called 'Envoy' in the Envoy Docker image. | ||
| export ENVOY_PATH="envoy" | ||
|
|
||
| # run all tests starting with test_http_h1_small in benchmarks/ | ||
| bazel-bin/benchmarks/benchmarks --log-cli-level=info -vvvv -k test_http_h1_small benchmarks/ | ||
| ``` | ||
|
|
||
| ## Example: running with binaries | ||
|
|
||
| This will build the Nighthawk binaries from the C++ code, and use those to | ||
| execute the benchmarks. Environment variable `ENVOY_PATH` can be used to | ||
| specify a custom Envoy binary to use to inject as a proxy between the test | ||
| client and server. If not set, the benchmark suite will fall back to configuring | ||
| Nighthawk's test server for that. Note that the build can be a lengthy process. | ||
|
|
||
| ```bash | ||
| git clone https://github.com/oschaaf/nighthawk.git benchmark-test | ||
| cd benchmark-test | ||
| bazel test \ | ||
| --test_summary=detailed \ | ||
| --test_output=all \ | ||
| --test_arg=--log-cli-level=info \ | ||
| --test_env=ENVOY_IP_TEST_VERSIONS=v4only \ | ||
| --test_env=HEAPPROFILE= \ | ||
| --test_env=HEAPCHECK= \ | ||
| --cache_test_results=no \ | ||
| --compilation_mode=opt \ | ||
| --cxxopt=-g \ | ||
| --cxxopt=-ggdb3 \ | ||
| //benchmarks:* | ||
| ``` | ||
|
|
||
| ## Example: fully dockerized flow | ||
|
|
||
| The framework can be run via Docker and used that way to execute | ||
| Python benchmarks scripts not sourced from this repository, but | ||
| elsewhere. An example: | ||
|
|
||
| ```bash | ||
| # This script runs the dockerized benchmarking framework, which in | ||
| # turn will pull Nighthawk and Envoy in via Docker. | ||
|
|
||
| set -eo pipefail | ||
| set +x | ||
| set -u | ||
|
|
||
| # The benchmark logs and artifacts will be dropped here | ||
| OUTDIR="/my-artifacts-dir/" | ||
| # Used to map the test that we want to see executed into the Docker container | ||
| # Note: the contents could be fetched via http, for example. | ||
| TEST_DIR="/dir-that-has-my-tests/" | ||
|
|
||
| # Rebuild the Docker in case something changed. | ||
| ./docker_build.sh && | ||
| docker run -it --rm \ | ||
| -v "/var/run/docker.sock:/var/run/docker.sock:rw" \ | ||
| -v "${OUTDIR}:${OUTDIR}:rw" \ | ||
| -v "${TEST_DIR}:/usr/local/bin/benchmarks/benchmarks.runfiles/nighthawk/benchmarks/external_tests/" \ | ||
| --network=host \ | ||
| --env NH_DOCKER_IMAGE="envoyproxy/nighthawk-dev:latest" \ | ||
| --env ENVOY_DOCKER_IMAGE_TO_TEST="envoyproxy/envoy-dev:f61b096f6a2dd3a9c74b9a9369a6ea398dbe1f0f" \ | ||
oschaaf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --env TMPDIR="${OUTDIR}" \ | ||
| oschaaf/benchmark-dev:latest ./benchmarks --log-cli-level=info -vvvv | ||
| ``` | ||
|
|
||
| # TODOs | ||
|
|
||
| - Copy out the artifacts and push those to a gcp bucket. Current status: | ||
| - cpu profiles are dumped to tmp per test (named according to the test). ideally we'd | ||
| also dump flamegraph svg's | ||
| - Enhance the UI. Currently we rely on CircleCI to directory-list our artifacts. This is | ||
| is pretty bare-bones, ideally we'd have something more fancy and we would be able to | ||
| visualize test data historically. | ||
| - Use taskset/cpuset when starting processes. | ||
| - Offer a docker image with binaries pre-built for profiling + the python test framework. | ||
| - Multi-origin support. The integration tests support it, but this isn't fitted into | ||
| the benchmark framework yet. This _might_ just be a doc issue. | ||
|
|
||
| # FUTURE | ||
|
|
||
| - The current status can collect CPU profiles, but these are useless | ||
| without access to the binary & libs that have been involved in producing them. | ||
| - profiling / flamegraphing via perf/bcc tools | ||
| - Allow injection of other proxies: nginx, haproxy | ||
| - Allow using alt clients, like Fortio & wrk2 | ||
| - An app that integrates fortios UI, pprof's web UI | ||
| - Have a mode where nighthawk_test_server provides high-res control timings in its | ||
| access logs | ||
| - The ability to repeat the runs multiple times and obtain stats, e.g. how much variance there is, mean, etc. | ||
| - The ability to do A/B testing, similar to https://github.com/envoyproxy/envoy-perf/blob/master/siege/siege.py#L3. | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
|---|---|---|
| @@ -1,24 +1,13 @@ | ||
| #!/usr/bin/env python3 | ||
| """@package integration_test.py | ||
| Entry point for our integration testing | ||
| """@package benchmarks. | ||
|
|
||
| Entry point for benchmark execution. | ||
| """ | ||
| import logging | ||
| import os | ||
| import sys | ||
| import pytest | ||
|
|
||
| if __name__ == '__main__': | ||
| path = os.path.dirname(os.path.realpath(__file__)) | ||
| test_selection_arg = sys.argv[1] if len(sys.argv) > 1 else "" | ||
| r = pytest.main([ | ||
| "--rootdir=" + path, | ||
| "-vvvv", | ||
| "--showlocals", # Don't abbreviate/truncate long values in asserts. | ||
| "-p", | ||
| "no:cacheprovider", # Avoid a bunch of warnings on readonly filesystems | ||
| "-x", | ||
| path, | ||
| "--log-cli-level", | ||
| "info" | ||
| ]) | ||
| r = pytest.main(["--rootdir=" + path, "-x", path, "-p", "no:cacheprovider", *sys.argv]) | ||
| exit(r) |
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,42 @@ | ||
| admin: | ||
| access_log_path: $tmpdir/envoyproxy-admin-access.log | ||
| profile_path: $tmpdir/envoyproxy.prof | ||
| address: | ||
| socket_address: { address: $proxy_ip, port_value: 0 } | ||
| static_resources: | ||
| listeners: | ||
| - address: | ||
| socket_address: | ||
| address: $proxy_ip | ||
| port_value: 0 | ||
| filter_chains: | ||
| - filters: | ||
| - name: envoy.http_connection_manager | ||
| config: | ||
| generate_request_id: false | ||
| codec_type: auto | ||
| stat_prefix: ingress_http | ||
| route_config: | ||
| name: local_route | ||
| virtual_hosts: | ||
| - name: service | ||
| domains: | ||
| - "*" | ||
| routes: | ||
| - match: | ||
| prefix: / | ||
| route: | ||
| cluster: local_service | ||
| http_filters: | ||
| - name: envoy.router | ||
| config: | ||
| dynamic_stats: false | ||
| clusters: | ||
| - name: local_service | ||
| connect_timeout: 0.25s | ||
| type: strict_dns | ||
| lb_policy: round_robin | ||
| hosts: | ||
| - socket_address: | ||
| address: $server_ip | ||
| port_value: $server_port |
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,14 @@ | ||
| FROM frolvlad/alpine-python3 | ||
|
|
||
| RUN apk add docker openrc | ||
| RUN rc-update add docker boot | ||
|
|
||
| ADD benchmarks /usr/local/bin/benchmarks | ||
|
|
||
| WORKDIR /usr/local/bin/benchmarks | ||
|
|
||
| ENV ENVOY_PATH="envoy" \ | ||
| RUNFILES_DIR="/usr/local/bin/benchmarks/benchmarks.runfiles/" \ | ||
| ENVOY_IP_TEST_VERSIONS="v4only" | ||
|
|
||
| CMD ["./benchmarks", "--help"] |
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,39 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Builds a docker image nighthawk-dev:latest containing the stripped binaries | ||
| # based on a pre-build bazel-bin directory (with "-c opt" set). | ||
|
|
||
| set -eo pipefail | ||
| set +x | ||
| set -u | ||
|
|
||
| # NOTE: explicit no -x for verbose commands. Because this is run in CI, doing so may result in | ||
| # publishing sensitive information into public CI logs if someone makes a change in a | ||
| # consuming script that is off guard. | ||
|
|
||
| DOCKER_NAME="benchmark" | ||
| DOCKER_IMAGE_PREFIX="${USER}/${DOCKER_NAME}" | ||
| BAZEL_BIN="$(bazel info bazel-bin)" | ||
| WORKSPACE="$(bazel info workspace)" | ||
| bazel build //benchmarks:benchmarks | ||
htuch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| TMP_DIR="$(mktemp -d)" | ||
| PUSH=${PUSH:-0} | ||
|
|
||
| echo "Preparing docker build context in ${TMP_DIR}" | ||
| # We flatten any symlinks to make this work on Linux (OSX doesn't need this) | ||
| cp -Lr "${WORKSPACE}/benchmarks/docker/" "${TMP_DIR}/" | ||
| cp -Lr "${BAZEL_BIN}/benchmarks" "${TMP_DIR}/" | ||
|
|
||
|
|
||
| cd "${TMP_DIR}" | ||
| echo "running docker build ... " | ||
| docker build -f "${TMP_DIR}/docker/Dockerfile-${DOCKER_NAME}" -t "${DOCKER_IMAGE_PREFIX}-dev:latest" . | ||
| rm -rf "${TMP_DIR}" | ||
| echo "docker build finished" | ||
|
|
||
| if [[ $PUSH == "1" ]]; then | ||
| echo "pushing ${DOCKER_IMAGE_PREFIX}-dev:latest .." | ||
| docker tag "${DOCKER_IMAGE_PREFIX}-dev:latest" "${DOCKER_IMAGE_PREFIX}-dev:latest" | ||
| docker push "${DOCKER_IMAGE_PREFIX}-dev:latest" | ||
| echo "docker image pushed" | ||
| fi | ||
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.