Skip to content

benchmark: add ring hash benchmarks#2550

Merged
ggreenway merged 3 commits intomasterfrom
ring_hash_benchmark
Feb 8, 2018
Merged

benchmark: add ring hash benchmarks#2550
ggreenway merged 3 commits intomasterfrom
ring_hash_benchmark

Conversation

@mattklein123
Copy link
Copy Markdown
Member

Convert ring hash creation and choose host benchmarks to the BM framework.
This will set us up for comparing Maglev.

Risk Level: None
Testing: Test/benchmark code
Docs Changes: N/A
Release Notes: N/A

Convert ring hash creation and choose host benchmarks to the BM framework.
This will set us up for comparing Maglev.

Signed-off-by: Matt Klein <mklein@lyft.com>
@mattklein123
Copy link
Copy Markdown
Member Author

Sample output:

mklein@localhost:~/Source/envoy-private$ bazel-bin/external/envoy/test/common/upstream/load_balancer_benchmark
2018-02-07 17:11:43
Run on (4 X 3095.48 MHz CPU s)
CPU Caches:
  L1 Data 32K (x4)
  L1 Instruction 32K (x4)
  L2 Unified 256K (x4)
  L3 Unified 8192K (x4)
-------------------------------------------------------------------------------------------
Benchmark                                                    Time           CPU Iterations
-------------------------------------------------------------------------------------------
BM_RingHashLoadBalancerBuildRing/100/65536                   9 ms          9 ms         68
BM_RingHashLoadBalancerBuildRing/200/65536                   9 ms          9 ms         71
BM_RingHashLoadBalancerBuildRing/500/65536                   9 ms          9 ms         69
BM_RingHashLoadBalancerBuildRing/100/256000                 37 ms         37 ms         19
BM_RingHashLoadBalancerBuildRing/200/256000                 36 ms         36 ms         19
BM_RingHashLoadBalancerBuildRing/500/256000                 40 ms         40 ms         18
BM_RingHashLoadBalancerChooseHost/100/65536/100000          24 ms         24 ms         26 mean_hits=1000 relative_stddev_hits=0.0490922 stddev_hits=49.0922
BM_RingHashLoadBalancerChooseHost/200/65536/100000          25 ms         25 ms         26 mean_hits=500 relative_stddev_hits=0.0691101 stddev_hits=34.555
BM_RingHashLoadBalancerChooseHost/500/65536/100000          29 ms         29 ms         27 mean_hits=200 relative_stddev_hits=0.114192 stddev_hits=22.8385
BM_RingHashLoadBalancerChooseHost/100/256000/100000         44 ms         44 ms         20 mean_hits=1000 relative_stddev_hits=0.0374598 stddev_hits=37.4598
BM_RingHashLoadBalancerChooseHost/200/256000/100000         48 ms         47 ms         14 mean_hits=500 relative_stddev_hits=0.0541956 stddev_hits=27.0978
BM_RingHashLoadBalancerChooseHost/500/256000/100000         42 ms         42 ms         12 mean_hits=200 relative_stddev_hits=0.0843214 stddev_hits=16.8643

@jmarantz
Copy link
Copy Markdown
Contributor

jmarantz commented Feb 7, 2018

Was the benchmark sample run with "-c opt"?

@mattklein123
Copy link
Copy Markdown
Member Author

Was the benchmark sample run with "-c opt"?

Yes. Ring hash build is very slow. :)

Copy link
Copy Markdown
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really nice. Just some style questions for you to decide.


HostVector hosts;
for (uint64_t i = 0; i < num_hosts; i++) {
hosts.push_back(makeTestHost(info_, fmt::format("tcp://10.0.{}.{}:6379", i / 256, i % 256)));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add assert that num_hosts<65536 above.

hosts.push_back(makeTestHost(info_, fmt::format("tcp://10.0.{}.{}:6379", i / 256, i % 256)));
}
HostVectorConstSharedPtr updated_hosts{new HostVector(hosts)};
host_set.updateHosts(updated_hosts, updated_hosts, nullptr, nullptr, hosts, {});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt of commenting the formal names for the nullptrs and {} ? I don't see this a lot in the codebase but it sometimes helps readability without having to refer back to the .h.

come to think of it, since updated_hosts is passed twice, indicating the formal for those actuals would be nice too.

up to you, obviously

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I feel that with a decent editor it doesn't add that much value, but happy to do it if preferable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll try to confer with others locally about how to get some kind of TAGS thing set up for Envoy. But it's not just the editor; it's also the code review tool, which ideally should have hot-links for all referenced types to their declaration, but github doesn't. Or is there a way to get github to light up some links in the review tool?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't think GH does this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, np. It's not a big deal to poke around and find the formals when I need to know them; just an idea.

state.PauseTiming();
double mean = 0;
std::for_each(hit_counter.begin(), hit_counter.end(),
[&mean](const auto pair) { mean += pair.second; });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Envoy, is this preferred to

  for (const auto pair : hit_counter) {
     mean += pair.second;
  }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied this code from elsewhere. Will fix.

double variance = 0;
std::for_each(hit_counter.begin(), hit_counter.end(), [&variance, mean](const auto pair) {
variance += std::pow(pair.second - mean, 2);
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
@ggreenway ggreenway merged commit a34eeca into master Feb 8, 2018
@mattklein123 mattklein123 deleted the ring_hash_benchmark branch February 11, 2018 18:49
jpsim pushed a commit that referenced this pull request Nov 28, 2022
modifying the NetworkConfigurationFilter to do asynchronous DNS lookups for non-IP-address proxies.
If address resolution fails, the request will be short circuited by sendLocalReply rather than being sent upstream without being proxied.

This PR also changes ConnectivityManager to have a pure API and an Impl for testing.

Risk Level: low
Testing: unit tests, integration test
Docs Changes: n/a
Release Notes: n/a
part of #1622
fixes #2532

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
modifying the NetworkConfigurationFilter to do asynchronous DNS lookups for non-IP-address proxies.
If address resolution fails, the request will be short circuited by sendLocalReply rather than being sent upstream without being proxied.

This PR also changes ConnectivityManager to have a pure API and an Impl for testing.

Risk Level: low
Testing: unit tests, integration test
Docs Changes: n/a
Release Notes: n/a
part of #1622
fixes #2532

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: JP Simard <jp@jpsim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants