Commit ca618664 authored by tburkard@chromium.org's avatar tburkard@chromium.org

Add a PLT histogram for prerender local predictor prefetches.

R=jkarlin@chromium.org, asvitkine@chromium.org

Review URL: https://codereview.chromium.org/495953003

Cr-Commit-Position: refs/heads/master@{#291413}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291413 0039d316-1c4b-4281-b951-d872f2087c98
parent 8b48e9d4
......@@ -455,24 +455,51 @@ class PrerenderLocalPredictor::PrefetchList {
return_value = true;
}
// If the item has been seen in both the history and in tab contents,
// erase it from the map to make room for new prefetches.
if (it->second->seen_tabcontents_ && it->second->seen_history_)
// and the page load time has been recorded, erase it from the map to
// make room for new prefetches.
if (it->second->seen_tabcontents_ && it->second->seen_history_ &&
it->second->seen_plt_) {
entries_.erase(url.spec().c_str());
}
return return_value;
}
// Marks the PLT for the provided UR as seen. Returns true
// iff the item is currently in the list and the PLT had not been seen
// before, i.e. the sighting was successful.
bool MarkPLTSeen(const GURL& url, base::TimeDelta plt) {
ExpireOldItems();
base::hash_map<string, ListEntry*>::iterator it =
entries_.find(url.spec().c_str());
if (it == entries_.end() || it->second->seen_plt_ ||
it->second->add_time_ > GetCurrentTime() - plt) {
return false;
}
it->second->seen_plt_ = true;
// If the item has been seen in both the history and in tab contents,
// and the page load time has been recorded, erase it from the map to
// make room for new prefetches.
if (it->second->seen_tabcontents_ && it->second->seen_history_ &&
it->second->seen_plt_) {
entries_.erase(url.spec().c_str());
}
return true;
}
private:
struct ListEntry {
explicit ListEntry(const string& url)
: url_(url),
add_time_(GetCurrentTime()),
seen_tabcontents_(false),
seen_history_(false) {
seen_history_(false),
seen_plt_(false) {
}
std::string url_;
base::Time add_time_;
bool seen_tabcontents_;
bool seen_history_;
bool seen_plt_;
};
void ExpireOldItems() {
......@@ -1119,6 +1146,14 @@ void PrerenderLocalPredictor::Init() {
void PrerenderLocalPredictor::OnPLTEventForURL(const GURL& url,
base::TimeDelta page_load_time) {
if (prefetch_list_->MarkPLTSeen(url, page_load_time)) {
UMA_HISTOGRAM_CUSTOM_TIMES("Prerender.LocalPredictorPrefetchMatchPLT",
page_load_time,
base::TimeDelta::FromMilliseconds(10),
base::TimeDelta::FromSeconds(60),
100);
}
scoped_ptr<PrerenderProperties> prerender;
if (DoesPrerenderMatchPLTRecord(last_swapped_in_prerender_.get(),
url, page_load_time)) {
......@@ -1338,8 +1373,19 @@ void PrerenderLocalPredictor::IssuePrerender(
CandidatePrerenderInfo* info,
LocalPredictorURLInfo* url_info) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (prefetch_list_->AddURL(url_info->url))
if (prefetch_list_->AddURL(url_info->url)) {
RecordEvent(EVENT_PREFETCH_LIST_ADDED);
// If we are prefetching rather than prerendering, now is the time to launch
// the prefetch.
if (IsLocalPredictorPrerenderPrefetchEnabled()) {
// Obtain the render frame host that caused this prefetch.
RenderFrameHost* rfh = RenderFrameHost::FromID(info->render_process_id_,
info->render_frame_id_);
// If it is still alive, launch the prefresh.
if (rfh)
rfh->Send(new PrefetchMsg_Prefetch(rfh->GetRoutingID(), url_info->url));
}
}
PrerenderProperties* prerender_properties =
GetIssuedPrerenderSlotForPriority(url_info->url, url_info->priority);
if (!prerender_properties) {
......@@ -1395,16 +1441,6 @@ void PrerenderLocalPredictor::IssuePrerender(
new_prerender_handle->OnCancel();
RecordEvent(EVENT_ISSUE_PRERENDER_CANCELLED_OLD_PRERENDER);
}
// If we are prefetching rather than prerendering, now is the time to launch
// the prefetch.
if (IsLocalPredictorPrerenderPrefetchEnabled()) {
// Obtain the render frame host that caused this prefetch.
RenderFrameHost* rfh = RenderFrameHost::FromID(info->render_process_id_,
info->render_frame_id_);
// If it is still alive, launch the prefresh.
if (rfh)
rfh->Send(new PrefetchMsg_Prefetch(rfh->GetRoutingID(), url));
}
}
RecordEvent(EVENT_ADD_VISIT_PRERENDERING);
......
......@@ -23956,6 +23956,18 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
<histogram name="Prerender.LocalPredictorPrefetchMatchPLT" units="milliseconds">
<owner>tburkard@chromium.org</owner>
<summary>
The PrerenderLocalPredictor uses local browsing history and the prerender
service to predict pages likely visited soon. Some of these URLs are
prefetched. When such prefetched likely next pages are visited, this
histogram records the PLT for such pages. In particular, this also happens
if prefetch is actually disabled, allowing (by pivoting on whether or not
prefetch is enabled) to compare the effect of prefetch on PLT.
</summary>
</histogram>
<histogram name="Prerender.LocalPredictorServiceLookupTime"
units="milliseconds">
<owner>tburkard@chromium.org</owner>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment