Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: net/dns/dns_session.cc

Issue 20482002: Use Histogram algorithm to calculate DNS timeout. Honor DnsConfig timeout if it exceeds 5s. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/dns/dns_session_unittest.cc » ('j') | net/dns/dns_session_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_session.cc
diff --git a/net/dns/dns_session.cc b/net/dns/dns_session.cc
index 67d5779e4d237355d4cc0d6e48d7628479b9bef2..01da93e2b1b47e4c876e8107b26906defa81b633 100644
--- a/net/dns/dns_session.cc
+++ b/net/dns/dns_session.cc
@@ -38,6 +38,8 @@ struct DnsSession::ServerStats {
ServerStats(base::TimeDelta rtt_estimate_param, RttBuckets* buckets)
: last_failure_count(0), rtt_estimate(rtt_estimate_param) {
rtt_histogram.reset(new base::SampleVector(buckets));
+ // Seed histogram with 2 samples at |rtt_estimate| timeout.
+ rtt_histogram->Accumulate(rtt_estimate.InMilliseconds(), 2);
}
// Count of consecutive failures after last success.
@@ -89,8 +91,9 @@ DnsSession::DnsSession(const DnsConfig& config,
UMA_HISTOGRAM_CUSTOM_COUNTS(
"AsyncDNS.ServerCount", config_.nameservers.size(), 0, 10, 10);
for (size_t i = 0; i < config_.nameservers.size(); ++i) {
- server_stats_.push_back(new ServerStats(config_.timeout,
- rtt_buckets_.Pointer()));
+ // Histogram-based method.
szym 2013/07/25 22:47:24 This comment can be misleading. Suggest undoing th
mef 2013/07/26 11:27:07 Done.
+ server_stats_.push_back(
+ new ServerStats(config_.timeout, rtt_buckets_.Pointer()));
}
}
@@ -209,18 +212,11 @@ void DnsSession::RecordServerStats() {
base::TimeDelta DnsSession::NextTimeout(unsigned server_index, int attempt) {
- DCHECK_LT(server_index, server_stats_.size());
-
- base::TimeDelta timeout = config_.timeout;
- // If this server has not responded successfully, then don't wait too long.
- if (server_stats_[server_index]->last_success.is_null())
- return timeout;
-
- // The timeout doubles every full round (each nameserver once).
- unsigned num_backoffs = attempt / config_.nameservers.size();
-
- return std::min(timeout * (1 << num_backoffs),
- base::TimeDelta::FromMilliseconds(kMaxTimeoutMs));
+ // Respect config timeout if it exceeds |kMaxTimeoutMs|.
+ if (config_.timeout.InMilliseconds() > kMaxTimeoutMs)
szym 2013/07/25 22:47:24 should it be >=?
mef 2013/07/26 11:27:07 Done.
+ return config_.timeout;
+ // Use Histogram to calculate next timeout.
szym 2013/07/25 22:47:24 nit: superfluous comment
mef 2013/07/26 11:27:07 Done.
+ return NextTimeoutFromHistogram(server_index, attempt);
}
// Allocate a socket, already connected to the server address.
« no previous file with comments | « no previous file | net/dns/dns_session_unittest.cc » ('j') | net/dns/dns_session_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698