summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-31 05:11:50 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-31 05:11:50 +0000
commitf2db5208f66b3c6b47ce2cfb96aac1104e5f5cce (patch)
tree763a190cd9374dd2cb0f5d98333f2d51ac596e17 /chrome
parenta27808170ffd8b86d920bb5bbe497ffda29be796 (diff)
downloadchromium_src-f2db5208f66b3c6b47ce2cfb96aac1104e5f5cce.zip
chromium_src-f2db5208f66b3c6b47ce2cfb96aac1104e5f5cce.tar.gz
chromium_src-f2db5208f66b3c6b47ce2cfb96aac1104e5f5cce.tar.bz2
Remove DNS pre-resolution model of OS cache
Force OS to decide about doing network lookup, rather than guessing whether it is in the cache before asking the OS. This will cost more OS operations, but should roughly double the hit rate for scan based pre-resolution. r=mbelshe Review URL: http://codereview.chromium.org/19524 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9017 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/net/dns_host_info.cc20
-rw-r--r--chrome/browser/net/dns_host_info_unittest.cc7
2 files changed, 13 insertions, 14 deletions
diff --git a/chrome/browser/net/dns_host_info.cc b/chrome/browser/net/dns_host_info.cc
index 9be4b2d..844e24c 100644
--- a/chrome/browser/net/dns_host_info.cc
+++ b/chrome/browser/net/dns_host_info.cc
@@ -55,11 +55,22 @@ bool DnsHostInfo::NeedsDnsUpdate(const std::string& hostname) {
const TimeDelta DnsHostInfo::kNullDuration(TimeDelta::FromMilliseconds(-1));
-TimeDelta DnsHostInfo::kCacheExpirationDuration(TimeDelta::FromMinutes(5));
+// Common low end TTL for sites is 5 minutes. However, DNS servers give us
+// the remaining time, not the original 5 minutes. Hence it doesn't much matter
+// whether we found something in the local cache, or an ISP cache, it will
+// on average be 2.5 minutes before it expires. We could try to model this with
+// 180 seconds, but simpler is just to do the lookups all the time (wasting
+// OS calls(?)), and let that OS cache decide what to do (with TTL in hand).
+// We use a small time to help get some duplicate suppression, in case a page
+// has a TON of copies of the same domain name, so that we don't thrash the OS
+// to death. Hopefully it is small enough that we're not hurting our cache hit
+// rate (i.e., we could always ask the OS).
+TimeDelta DnsHostInfo::kCacheExpirationDuration(TimeDelta::FromSeconds(5));
const TimeDelta DnsHostInfo::kMaxNonNetworkDnsLookupDuration(
TimeDelta::FromMilliseconds(15));
+// Used by test ONLY. The value is otherwise constant.
void DnsHostInfo::set_cache_expiration(TimeDelta time) {
kCacheExpirationDuration = time;
}
@@ -152,13 +163,6 @@ bool DnsHostInfo::IsStillCached() const {
TimeDelta time_since_resolution = TimeTicks::Now() - time_;
- if (FOUND == state_ && resolve_duration_ < kMaxNonNetworkDnsLookupDuration) {
- // Since cache was warm (no apparent network activity during resolution),
- // we assume it was "really" found (via network activity) twice as long
- // ago as when we got our FOUND result.
- time_since_resolution *= 2;
- }
-
return time_since_resolution < kCacheExpirationDuration;
}
diff --git a/chrome/browser/net/dns_host_info_unittest.cc b/chrome/browser/net/dns_host_info_unittest.cc
index 79cca93..c279804 100644
--- a/chrome/browser/net/dns_host_info_unittest.cc
+++ b/chrome/browser/net/dns_host_info_unittest.cc
@@ -57,13 +57,8 @@ TEST(DnsHostInfoTest, StateChangeTest) {
info.set_cache_expiration(TimeDelta::FromMilliseconds(300));
EXPECT_FALSE(info.NeedsDnsUpdate(hostname1)) << "expiration time not honored";
- // Note that we'll actually get an expiration (effectively) of
- // 150ms, since there was no detected network activity time during lookup.
- PlatformThread::Sleep(80); // Not enough time to pass our 150ms mark.
+ PlatformThread::Sleep(80); // Not enough time to pass our 300ms mark.
EXPECT_FALSE(info.NeedsDnsUpdate(hostname1)) << "expiration time not honored";
- // Be sure we sleep (80+100) enough to pass that 150ms mark.
- PlatformThread::Sleep(100);
- EXPECT_TRUE(info.NeedsDnsUpdate(hostname1)) << "expiration time not honored";
// That was a nice life when the object was found.... but next time it won't
// be found. We'll sleep for a while, and then come back with not-found.