Skip to content

Commit

Permalink
eds_speed_test: support v2/v3 variants of config.
Browse files Browse the repository at this point in the history
This shows that the EDS onConfigUpdate() is 2-3x slower when working
with v2 config and doing version conversion with original version
recovery. Followup PRs will optimize.

Relates to envoyproxy#11362 and envoyproxy#10875.

Risk level: Low
Testing: Ran benchmark with -c opt binary.

Signed-off-by: Harvey Tuch <[email protected]>
  • Loading branch information
htuch committed Jun 8, 2020
1 parent 6679d57 commit 5292fab
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test/common/upstream/eds_speed_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Upstream {

class EdsSpeedTest {
public:
EdsSpeedTest() : api_(Api::createApiForTest(stats_)) {}
EdsSpeedTest(benchmark::State& state) : state_(state), api_(Api::createApiForTest(stats_)) {}

void resetCluster(const std::string& yaml_config, Cluster::InitializePhase initialize_phase) {
local_info_.node_.mutable_locality()->set_zone("us-east-1a");
Expand All @@ -54,7 +54,9 @@ class EdsSpeedTest {

// Set up an EDS config with multiple priorities, localities, weights and make sure
// they are loaded and reloaded as expected.
void priorityAndLocalityWeightedHelper(bool ignore_unknown_dynamic_fields, int num_hosts) {
void priorityAndLocalityWeightedHelper(bool v2_config, bool ignore_unknown_dynamic_fields,
int num_hosts) {
state_.PauseTiming();
envoy::config::endpoint::v3::ClusterLoadAssignment cluster_load_assignment;
cluster_load_assignment.set_cluster_name("fare");
resetCluster(R"EOF(
Expand Down Expand Up @@ -95,11 +97,20 @@ class EdsSpeedTest {

initialize();
Protobuf::RepeatedPtrField<ProtobufWkt::Any> resources;
resources.Add()->PackFrom(cluster_load_assignment);
auto* resource = resources.Add();
resource->PackFrom(cluster_load_assignment);
if (v2_config) {
RELEASE_ASSERT(resource->type_url() ==
"type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment",
"");
resource->set_type_url("type.googleapis.com/envoy.api.v2.ClusterLoadAssignment");
}
state_.ResumeTiming();
eds_callbacks_->onConfigUpdate(resources, "");
ASSERT(initialized_);
}

benchmark::State& state_;
bool initialized_{};
Stats::IsolatedStoreImpl stats_;
Ssl::MockContextManager ssl_context_manager_;
Expand All @@ -126,9 +137,9 @@ static void priorityAndLocalityWeighted(benchmark::State& state) {
Envoy::Logger::Context logging_state(spdlog::level::warn,
Envoy::Logger::Logger::DEFAULT_LOG_FORMAT, lock, false);
for (auto _ : state) {
Envoy::Upstream::EdsSpeedTest speed_test;
speed_test.priorityAndLocalityWeightedHelper(state.range(0), state.range(1));
Envoy::Upstream::EdsSpeedTest speed_test(state);
speed_test.priorityAndLocalityWeightedHelper(state.range(0), state.range(1), state.range(2));
}
}

BENCHMARK(priorityAndLocalityWeighted)->Ranges({{false, true}, {2000, 100000}});
BENCHMARK(priorityAndLocalityWeighted)->Ranges({{false, true}, {false, true}, {2000, 100000}});

0 comments on commit 5292fab

Please sign in to comment.