forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eds: decrease computational complexity of updates (envoyproxy#11442)
Makes BaseDynamicClusterImpl::updateDynamicHostList O(n) rather than O(n^2) Instead of calling .erase() on list iterators as we find them, we swap with the end of the list and erase after iterating over the list. This shows a ~3x improvement in execution time in the included benchmark test. Risk Level: Medium. No reordering happens to the endpoint list. Not runtime guarded. Testing: New benchmark, existing unit tests pass (and cover the affected function). Docs Changes: N/A Release Notes: N/A Relates to envoyproxy#2874 envoyproxy#11362 Signed-off-by: Phil Genera <[email protected]> Signed-off-by: scheler <[email protected]>
- Loading branch information
Showing
6 changed files
with
155 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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,4 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# Set the benchmark time to 0 to just verify that the benchmark runs to completion. | ||
"${TEST_SRCDIR}/envoy/$@" --benchmark_min_time=0 | ||
# Set the benchmark time to 0 to just verify that the benchmark runs to | ||
# completion. We're interacting with two different flag parsers, so the order | ||
# of flags and the -- matters. | ||
"${TEST_SRCDIR}/envoy/$@" --skip_expensive_benchmarks -- --benchmark_min_time=0 |
This file contains 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 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 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,16 +1,40 @@ | ||
// NOLINT(namespace-envoy) | ||
// This is an Envoy driver for benchmarks. | ||
#include "test/benchmark/main.h" | ||
|
||
#include "test/test_common/environment.h" | ||
|
||
#include "benchmark/benchmark.h" | ||
#include "tclap/CmdLine.h" | ||
|
||
static bool skip_expensive_benchmarks = false; | ||
|
||
// Boilerplate main(), which discovers benchmarks and runs them. | ||
// Boilerplate main(), which discovers benchmarks and runs them. This uses two | ||
// different flag parsers, so the order of flags matters: flags defined here | ||
// must be passed first, and flags defined in benchmark::Initialize second, | ||
// separated by --. | ||
// TODO(pgenera): convert this to abseil/flags/ when benchmark also adopts abseil. | ||
int main(int argc, char** argv) { | ||
Envoy::TestEnvironment::initializeTestMain(argv[0]); | ||
|
||
benchmark::Initialize(&argc, argv); | ||
if (benchmark::ReportUnrecognizedArguments(argc, argv)) { | ||
return 1; | ||
// NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) | ||
TCLAP::CmdLine cmd("envoy-benchmark-test", ' ', "0.1"); | ||
TCLAP::SwitchArg skip_switch("s", "skip_expensive_benchmarks", | ||
"skip or minimize expensive benchmarks", cmd, false); | ||
|
||
cmd.setExceptionHandling(false); | ||
try { | ||
cmd.parse(argc, argv); | ||
} catch (const TCLAP::ExitException& e) { | ||
// parse() throws an ExitException with status 0 after printing the output | ||
// for --help and --version. | ||
return 0; | ||
} | ||
|
||
skip_expensive_benchmarks = skip_switch.getValue(); | ||
|
||
benchmark::Initialize(&argc, argv); | ||
benchmark::RunSpecifiedBenchmarks(); | ||
} | ||
|
||
bool Envoy::benchmark::skipExpensiveBenchmarks() { return skip_expensive_benchmarks; } |
This file contains 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,13 @@ | ||
#pragma once | ||
|
||
/** | ||
* Benchmarks can use this to skip or hurry through long-running tests in CI. | ||
*/ | ||
|
||
namespace Envoy { | ||
namespace benchmark { | ||
|
||
bool skipExpensiveBenchmarks(); | ||
|
||
} | ||
} // namespace Envoy |
This file contains 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