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

Unified Diff: net/base/host_resolver_impl.cc

Issue 10829191: Measure DNS resolution waste from not always performing AF_UNSPEC lookups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver_impl.cc
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 9ec0a379e197f59bebc3e506545fc55a973e4f6c..01d49fca75cd7e644607c23418bdc9603787458a 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -1822,8 +1822,43 @@ bool HostResolverImpl::ServeFromCache(const Key& key,
if (!info.allow_cached_response() || !cache_.get())
return false;
- const HostCache::Entry* cache_entry = cache_->Lookup(
- key, base::TimeTicks::Now());
+ base::TimeTicks current_time = base::TimeTicks::Now();
+ const HostCache::Entry* cache_entry = cache_->Lookup(key, current_time);
+
+ bool found = cache_entry != NULL;
szym 2012/08/07 23:17:32 I suggest adding braces around this whole block so
+ bool ipv4 = key.address_family == ADDRESS_FAMILY_IPV4;
+ // If we couldn't find the desired address family, check to see if the other
+ // family is in the cache, which indicates waste, and we should fix
+ // crbug.com/139811.
+ bool found_other_family = false;
+ if (!found && default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED) {
+ Key other_family_key = key;
+ other_family_key.address_family = ipv4 ?
+ ADDRESS_FAMILY_UNSPECIFIED : ADDRESS_FAMILY_IPV4;
+ found_other_family =
+ cache_->Lookup(other_family_key, current_time) != NULL;
+ }
+ enum { // Used in HISTOGRAM_ENUMERATION.
+ CACHE_IPV4_ONLY_FOUND,
+ CACHE_IPV4_ONLY_MISS,
+ CACHE_FOUND_IPV4,
+ CACHE_FOUND_UNSPEC,
+ CACHE_WASTE_IPV4,
+ CACHE_WASTE_UNSPEC,
+ CACHE_MISS_IPV4,
+ CACHE_MISS_UNSPEC,
+ CACHE_MAX, // Bounding value.
+ } category = CACHE_MAX;
+ if (default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED)
+ category = found ? CACHE_IPV4_ONLY_FOUND : CACHE_IPV4_ONLY_MISS;
+ else if (found)
szym 2012/08/07 23:17:32 nit: Use braces whenever if has an else clause.
+ category = ipv4 ? CACHE_FOUND_IPV4 : CACHE_FOUND_UNSPEC;
+ else if (found_other_family)
+ category = ipv4 ? CACHE_WASTE_IPV4 : CACHE_WASTE_UNSPEC;
+ else
+ category = ipv4 ? CACHE_MISS_IPV4 : CACHE_MISS_UNSPEC;
+ UMA_HISTOGRAM_ENUMERATION("DNS.ResolveCacheCategory", category, CACHE_MAX);
+
if (!cache_entry)
return false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698