Commit 37aed95e authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Add more UMA for resource loading hints experiment

Add more UMA to track the performance and correctness
of the resource loading hints experiment. Specifically,
this CL records UMA on how many page hints are
received via component updater, and how frequently
were the resource hints available at the time
of page commit.

Bug: 878129
Change-Id: I8bc3dd1e6d7c80e4cefc34ebb6119665d5fbee5e
Reviewed-on: https://chromium-review.googlesource.com/1197108
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587944}
parent 1aca949a
...@@ -326,6 +326,8 @@ IN_PROC_BROWSER_TEST_F(ResourceLoadingHintsBrowserTest, ...@@ -326,6 +326,8 @@ IN_PROC_BROWSER_TEST_F(ResourceLoadingHintsBrowserTest,
RetryForHistogramUntilCountReached( RetryForHistogramUntilCountReached(
&histogram_tester, "ResourceLoadingHints.CountBlockedSubresourcePatterns", &histogram_tester, "ResourceLoadingHints.CountBlockedSubresourcePatterns",
1); 1);
histogram_tester.ExpectUniqueSample(
"ResourceLoadingHints.ResourcePatternsAvailableAtCommit", 1, 1);
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"Previews.EligibilityReason.ResourceLoadingHints", "Previews.EligibilityReason.ResourceLoadingHints",
static_cast<int>(previews::PreviewsEligibilityReason::ALLOWED), 1); static_cast<int>(previews::PreviewsEligibilityReason::ALLOWED), 1);
...@@ -344,6 +346,8 @@ IN_PROC_BROWSER_TEST_F(ResourceLoadingHintsBrowserTest, ...@@ -344,6 +346,8 @@ IN_PROC_BROWSER_TEST_F(ResourceLoadingHintsBrowserTest,
RetryForHistogramUntilCountReached( RetryForHistogramUntilCountReached(
&histogram_tester, "ResourceLoadingHints.CountBlockedSubresourcePatterns", &histogram_tester, "ResourceLoadingHints.CountBlockedSubresourcePatterns",
2); 2);
histogram_tester.ExpectUniqueSample(
"ResourceLoadingHints.ResourcePatternsAvailableAtCommit", 1, 2);
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"Previews.EligibilityReason.ResourceLoadingHints", "Previews.EligibilityReason.ResourceLoadingHints",
static_cast<int>(previews::PreviewsEligibilityReason::ALLOWED), 2); static_cast<int>(previews::PreviewsEligibilityReason::ALLOWED), 2);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/loader/chrome_navigation_data.h" #include "chrome/browser/loader/chrome_navigation_data.h"
#include "chrome/browser/previews/previews_service.h" #include "chrome/browser/previews/previews_service.h"
#include "chrome/browser/previews/previews_service_factory.h" #include "chrome/browser/previews/previews_service_factory.h"
...@@ -77,6 +78,9 @@ void ResourceLoadingHintsWebContentsObserver::SendResourceLoadingHints( ...@@ -77,6 +78,9 @@ void ResourceLoadingHintsWebContentsObserver::SendResourceLoadingHints(
GetResourceLoadingHintsResourcePatternsToBlock( GetResourceLoadingHintsResourcePatternsToBlock(
navigation_handle->GetURL()); navigation_handle->GetURL());
UMA_HISTOGRAM_BOOLEAN(
"ResourceLoadingHints.ResourcePatternsAvailableAtCommit", !hints.empty());
if (hints.empty()) if (hints.empty())
return; return;
for (const std::string& hint : hints) for (const std::string& hint : hints)
......
...@@ -177,6 +177,7 @@ std::unique_ptr<PreviewsHints> PreviewsHints::CreateFromConfig( ...@@ -177,6 +177,7 @@ std::unique_ptr<PreviewsHints> PreviewsHints::CreateFromConfig(
// Process hint configuration. // Process hint configuration.
for (const auto hint : config.hints()) { for (const auto hint : config.hints()) {
// We only support host suffixes at the moment. Skip anything else. // We only support host suffixes at the moment. Skip anything else.
// One |hint| applies to one host URL suffix.
if (hint.key_representation() != optimization_guide::proto::HOST_SUFFIX) if (hint.key_representation() != optimization_guide::proto::HOST_SUFFIX)
continue; continue;
...@@ -218,6 +219,8 @@ std::unique_ptr<PreviewsHints> PreviewsHints::CreateFromConfig( ...@@ -218,6 +219,8 @@ std::unique_ptr<PreviewsHints> PreviewsHints::CreateFromConfig(
// Cache hints that have PageHints. // Cache hints that have PageHints.
if (ShouldProcessPageHints() && !hint.page_hints().empty()) { if (ShouldProcessPageHints() && !hint.page_hints().empty()) {
UMA_HISTOGRAM_COUNTS("ResourceLoadingHints.ResourceHints.ProcessedCount",
hint.page_hints().size());
hints->initial_hints_.push_back(hint); hints->initial_hints_.push_back(hint);
} }
} }
......
...@@ -636,6 +636,7 @@ void PreviewsOptimizationGuideTest::InitializeResourceLoadingHints() { ...@@ -636,6 +636,7 @@ void PreviewsOptimizationGuideTest::InitializeResourceLoadingHints() {
} }
TEST_F(PreviewsOptimizationGuideTest, MaybeLoadOptimizationHints) { TEST_F(PreviewsOptimizationGuideTest, MaybeLoadOptimizationHints) {
base::HistogramTester histogram_tester;
base::test::ScopedFeatureList scoped_list; base::test::ScopedFeatureList scoped_list;
scoped_list.InitAndEnableFeature(features::kResourceLoadingHints); scoped_list.InitAndEnableFeature(features::kResourceLoadingHints);
...@@ -654,6 +655,8 @@ TEST_F(PreviewsOptimizationGuideTest, MaybeLoadOptimizationHints) { ...@@ -654,6 +655,8 @@ TEST_F(PreviewsOptimizationGuideTest, MaybeLoadOptimizationHints) {
base::DoNothing())); base::DoNothing()));
RunUntilIdle(); RunUntilIdle();
histogram_tester.ExpectUniqueSample(
"ResourceLoadingHints.ResourceHints.ProcessedCount", 2, 1);
// Verify loaded hint data for www.somedomain.org // Verify loaded hint data for www.somedomain.org
EXPECT_EQ(GURL("https://www.somedomain.org/news/football"), EXPECT_EQ(GURL("https://www.somedomain.org/news/football"),
......
...@@ -84459,6 +84459,16 @@ uploading your change for review. ...@@ -84459,6 +84459,16 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="ResourceLoadingHints.ResourceHints.ProcessedCount"
units="pattern count">
<owner>tbansal@chromium.org</owner>
<summary>
The count of resource loading blocking patterns received by the browser from
the component updater. Recorded every time a non-empty page hint is received
by the browser from the optimization guide service.
</summary>
</histogram>
<histogram name="ResourceLoadingHints.ResourceLoadingBlocked" <histogram name="ResourceLoadingHints.ResourceLoadingBlocked"
units="loading blocked"> units="loading blocked">
<owner>tbansal@chromium.org</owner> <owner>tbansal@chromium.org</owner>
...@@ -84493,6 +84503,15 @@ uploading your change for review. ...@@ -84493,6 +84503,15 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="ResourceLoadingHints.ResourcePatternsAvailableAtCommit"
enum="BooleanAvailable">
<owner>tbansal@chromium.org</owner>
<summary>
Records if the resource patterns were available at the time of page commit
if the committed previews type was RESOURCE_LOADING_HINTS.
</summary>
</histogram>
<histogram name="ResourcePrefetchPredictor.CachePattern" <histogram name="ResourcePrefetchPredictor.CachePattern"
enum="HttpCachePattern"> enum="HttpCachePattern">
<obsolete> <obsolete>
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