diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-28 22:37:23 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-28 22:37:23 +0000 |
commit | f4ef861ba773e66d1c6e7e023a38db32afdd531d (patch) | |
tree | 6ae53ffb969fa9ddf39131deb79c15b2ae8fa592 /chrome/browser/net/url_info.cc | |
parent | 175aa689f7f9b705ee2c6eebb29aca1c93c540d5 (diff) | |
download | chromium_src-f4ef861ba773e66d1c6e7e023a38db32afdd531d.zip chromium_src-f4ef861ba773e66d1c6e7e023a38db32afdd531d.tar.gz chromium_src-f4ef861ba773e66d1c6e7e023a38db32afdd531d.tar.bz2 |
Support both preconnection, and pre-resolution for subresources
With this change, both preconnection and preresolution are
enabled when the --enable-preconnection flag is turned on.
I'm expecting to enable this feature by default soon, so
as to better tune the parameters.
BUG=42694
r=mbelshe
Review URL: http://codereview.chromium.org/3032014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/url_info.cc')
-rw-r--r-- | chrome/browser/net/url_info.cc | 124 |
1 files changed, 12 insertions, 112 deletions
diff --git a/chrome/browser/net/url_info.cc b/chrome/browser/net/url_info.cc index fab27ad..a92f5a2 100644 --- a/chrome/browser/net/url_info.cc +++ b/chrome/browser/net/url_info.cc @@ -131,11 +131,6 @@ void UrlInfo::SetFoundState() { resolve_duration_, kMaxNonNetworkDnsLookupDuration, TimeDelta::FromMinutes(15), 100); } - - // Record potential beneficial time, and maybe we'll get a cache hit. - // We keep the maximum, as the warming we did earlier may still be - // helping with a cache upstream in DNS resolution. - benefits_remaining_ = std::max(resolve_duration_, benefits_remaining_); } sequence_number_ = sequence_counter++; DLogResultsStats("DNS PrefetchFound"); @@ -147,29 +142,11 @@ void UrlInfo::SetNoSuchNameState() { resolve_duration_ = GetDuration(); if (kMaxNonNetworkDnsLookupDuration <= resolve_duration_) { DHISTOGRAM_TIMES("DNS.PrefetchNotFoundName", resolve_duration_); - // Record potential beneficial time, and maybe we'll get a cache hit. - benefits_remaining_ = std::max(resolve_duration_, benefits_remaining_); } sequence_number_ = sequence_counter++; DLogResultsStats("DNS PrefetchNotFound"); } -void UrlInfo::SetStartedState() { - DCHECK(PENDING == state_); - state_ = STARTED; - queue_duration_ = resolve_duration_ = TimeDelta(); // 0ms. - SetMotivation(NO_PREFETCH_MOTIVATION); - GetDuration(); // Set time. -} - -void UrlInfo::SetFinishedState(bool was_resolved) { - DCHECK(STARTED == state_); - state_ = was_resolved ? FINISHED : FINISHED_UNRESOLVED; - resolve_duration_ = GetDuration(); - // TODO(jar): Sequence number should be incremented in prefetched HostInfo. - DLogResultsStats("DNS HTTP Finished"); -} - void UrlInfo::SetUrl(const GURL& url) { if (url_.is_empty()) // Not yet initialized. url_ = url; @@ -195,65 +172,12 @@ bool UrlInfo::IsStillCached() const { return time_since_resolution < kCacheExpirationDuration; } -// Compare the actual navigation DNS latency found in navigation_info, to the -// previously prefetched info. -DnsBenefit UrlInfo::AccruePrefetchBenefits(UrlInfo* navigation_info) { - DCHECK(FINISHED == navigation_info->state_ || - FINISHED_UNRESOLVED == navigation_info->state_); - DCHECK(navigation_info->url() == url_); - - if ((0 == benefits_remaining_.InMilliseconds()) || - (FOUND != state_ && NO_SUCH_NAME != state_)) { - if (FINISHED == navigation_info->state_) - UMA_HISTOGRAM_LONG_TIMES("DNS.IndependentNavigation", - navigation_info->resolve_duration_); - else - UMA_HISTOGRAM_LONG_TIMES("DNS.IndependentFailedNavigation", - navigation_info->resolve_duration_); - return PREFETCH_NO_BENEFIT; - } - - TimeDelta benefit = benefits_remaining_ - navigation_info->resolve_duration_; - navigation_info->benefits_remaining_ = benefits_remaining_; - benefits_remaining_ = TimeDelta(); // We used up all our benefits here. - - navigation_info->motivation_ = motivation_; - if (LEARNED_REFERAL_MOTIVATED == motivation_ || - STATIC_REFERAL_MOTIVATED == motivation_) - navigation_info->referring_url_ = referring_url_; - - if (navigation_info->resolve_duration_ > kMaxNonNetworkDnsLookupDuration) { - // Our precache effort didn't help since HTTP stack hit the network. - UMA_HISTOGRAM_LONG_TIMES("DNS.PrefetchCacheEvictionL", resolve_duration_); - DLogResultsStats("DNS PrefetchCacheEviction"); - return PREFETCH_CACHE_EVICTION; - } - - if (NO_SUCH_NAME == state_) { - UMA_HISTOGRAM_LONG_TIMES("DNS.PrefetchNegativeHitL", benefit); - DLogResultsStats("DNS PrefetchNegativeHit"); - return PREFETCH_NAME_NONEXISTANT; - } - - DCHECK_EQ(FOUND, state_); - if (LEARNED_REFERAL_MOTIVATED == motivation_ || - STATIC_REFERAL_MOTIVATED == motivation_) { - UMA_HISTOGRAM_TIMES("DNS.PrefetchReferredPositiveHit", benefit); - DLogResultsStats("DNS PrefetchReferredPositiveHit"); - } else { - UMA_HISTOGRAM_LONG_TIMES("DNS.PrefetchPositiveHitL", benefit); - DLogResultsStats("DNS PrefetchPositiveHit"); - } - return PREFETCH_NAME_FOUND; -} - void UrlInfo::DLogResultsStats(const char* message) const { if (!detailed_logging_enabled) return; DLOG(INFO) << "\t" << message << "\tq=" << queue_duration().InMilliseconds() << "ms,\tr=" << resolve_duration().InMilliseconds() << "ms\tp=" - << benefits_remaining_.InMilliseconds() << "ms\tseq=" << sequence_number_ << "\t" << url_.spec(); } @@ -329,7 +253,7 @@ static std::string HoursMinutesSeconds(int seconds) { } // static -void UrlInfo::GetHtmlTable(const DnsInfoTable host_infos, +void UrlInfo::GetHtmlTable(const UrlInfoTable host_infos, const char* description, const bool brief, std::string* output) { @@ -344,53 +268,29 @@ void UrlInfo::GetHtmlTable(const DnsInfoTable host_infos, return; } - const char* row_format = "<tr align=right><td>%s</td>" - "<td>%d</td><td>%d</td><td>%s</td><td>%s</td></tr>"; + output->append("<br><table border=1>" + "<tr><th>Host name</th>" + "<th>How long ago<br>(HH:MM:SS)</th>" + "<th>Motivation</th>" + "</tr>"); - output->append("<br><table border=1>"); - StringAppendF(output, - "<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>", - "Host name", "Applicable Prefetch<br>Time (ms)", - "Recent Resolution<br>Time(ms)", "How long ago<br>(HH:MM:SS)", - "Motivation"); + const char* row_format = "<tr align=right><td>%s</td>" // Host name. + "<td>%s</td>" // How long ago. + "<td>%s</td>" // Motivation. + "</tr>"; // Print bulk of table, and gather stats at same time. - MinMaxAverage queue, resolve, preresolve, when; + MinMaxAverage queue, when; TimeTicks current_time = TimeTicks::Now(); - for (DnsInfoTable::const_iterator it(host_infos.begin()); + for (UrlInfoTable::const_iterator it(host_infos.begin()); it != host_infos.end(); it++) { queue.sample((it->queue_duration_.InMilliseconds())); StringAppendF(output, row_format, RemoveJs(it->url_.spec()).c_str(), - preresolve.sample((it->benefits_remaining_.InMilliseconds())), - resolve.sample((it->resolve_duration_.InMilliseconds())), HoursMinutesSeconds(when.sample( (current_time - it->time_).InSeconds())).c_str(), it->GetAsciiMotivation().c_str()); } - // Write min, max, and average summary lines. - if (host_infos.size() > 2) { - output->append("<B>"); - StringAppendF(output, row_format, - "<b>---minimum---</b>", - preresolve.minimum(), resolve.minimum(), - HoursMinutesSeconds(when.minimum()).c_str(), ""); - StringAppendF(output, row_format, - "<b>---average---</b>", - preresolve.average(), resolve.average(), - HoursMinutesSeconds(when.average()).c_str(), ""); - StringAppendF(output, row_format, - "<b>standard deviation</b>", - preresolve.standard_deviation(), - resolve.standard_deviation(), "n/a", ""); - StringAppendF(output, row_format, - "<b>---maximum---</b>", - preresolve.maximum(), resolve.maximum(), - HoursMinutesSeconds(when.maximum()).c_str(), ""); - StringAppendF(output, row_format, - "<b>-----SUM-----</b>", - preresolve.sum(), resolve.sum(), "n/a", ""); - } output->append("</table>"); #ifdef DEBUG |