0

Add more histograms for Bidding And Auction Services performance

We need these extra histograms to get a better idea of what areas we need to focus on to improve performance.

Bug: 1481762
Change-Id: I5911722746a14485aebb34322e78c4b9e381e9e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5170446
Reviewed-by: Orr Bernstein <orrb@google.com>
Commit-Queue: Russ Hamilton <behamilton@google.com>
Cr-Commit-Position: refs/heads/main@{#1243475}
This commit is contained in:
Russ Hamilton
2024-01-05 17:34:22 +00:00
committed by Chromium LUCI CQ
parent 7978bb4913
commit 7d97ef4d2e
8 changed files with 155 additions and 4 deletions

@ -10910,6 +10910,15 @@ TEST_F(AdAuctionServiceImplBAndATest, RunBAndAAuction) {
"Ads.InterestGroup.ServerAuction.NonKAnonWinnerIsKAnon", false, 1);
hist.ExpectTotalCount("Ads.InterestGroup.ServerAuction.AuctionWithWinnerTime",
1);
hist.ExpectUniqueSample("Ads.InterestGroup.ServerAuction.KeyFetch.Cached",
false, 1);
hist.ExpectUniqueSample(
"Ads.InterestGroup.ServerAuction.KeyFetch.NetworkCached", false, 1);
hist.ExpectTotalCount("Ads.InterestGroup.ServerAuction.KeyFetch.NetworkTime",
1);
hist.ExpectTotalCount("Ads.InterestGroup.ServerAuction.KeyFetch.TotalTime",
1);
hist.ExpectTotalCount("Ads.InterestGroup.ServerAuction.ReportDelay", 1);
// There should be no on-device metrics
hist.ExpectTotalCount("Ads.InterestGroup.Auction.EndToEndTime", 0);
@ -10917,6 +10926,7 @@ TEST_F(AdAuctionServiceImplBAndATest, RunBAndAAuction) {
hist.ExpectTotalCount("Ads.InterestGroup.Auction.Result", 0);
hist.ExpectTotalCount("Ads.InterestGroup.Auction.NonKAnonWinnerIsKAnon", 0);
hist.ExpectTotalCount("Ads.InterestGroup.Auction.AuctionWithWinnerTime", 0);
hist.ExpectTotalCount("Ads.InterestGroup.Auction.ReportDelay", 0);
}
TEST_F(AdAuctionServiceImplBAndATest, RunBAndAAuctionNoBids) {

@ -6,6 +6,7 @@
#include "base/base64.h"
#include "base/json/json_reader.h"
#include "base/metrics/histogram_functions.h"
#include "base/rand_util.h"
#include "net/base/isolation_info.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
@ -131,15 +132,20 @@ void BiddingAndAuctionServerKeyFetcher::GetOrFetchKey(
if (state.keys.size() > 0 && state.expiration > base::Time::Now()) {
// Use a random key from the set to limit the server's ability to identify
// us based on the key we use.
base::UmaHistogramBoolean("Ads.InterestGroup.ServerAuction.KeyFetch.Cached",
true);
std::move(callback).Run(
state.keys[base::RandInt(0, state.keys.size() - 1)]);
return;
}
base::UmaHistogramBoolean("Ads.InterestGroup.ServerAuction.KeyFetch.Cached",
false);
state.queue.push_back(std::move(callback));
if (state.queue.size() > 1) {
return;
}
state.fetch_start = base::TimeTicks::Now();
state.keys.clear();
CHECK(!state.loader);
@ -163,11 +169,18 @@ void BiddingAndAuctionServerKeyFetcher::GetOrFetchKey(
void BiddingAndAuctionServerKeyFetcher::OnFetchKeyComplete(
url::Origin coordinator,
std::unique_ptr<std::string> response) {
fetcher_state_map_.at(coordinator).loader.reset();
PerCoordinatorFetcherState& state = fetcher_state_map_.at(coordinator);
bool was_cached = state.loader->LoadedFromCache();
state.loader.reset();
if (!response) {
FailAllCallbacks(coordinator);
return;
}
base::UmaHistogramTimes(
"Ads.InterestGroup.ServerAuction.KeyFetch.NetworkTime",
base::TimeTicks::Now() - state.fetch_start);
base::UmaHistogramBoolean(
"Ads.InterestGroup.ServerAuction.KeyFetch.NetworkCached", was_cached);
data_decoder::DataDecoder::ParseJsonIsolated(
*response,
base::BindOnce(&BiddingAndAuctionServerKeyFetcher::OnParsedKeys,
@ -227,6 +240,8 @@ void BiddingAndAuctionServerKeyFetcher::OnParsedKeys(
PerCoordinatorFetcherState& state = fetcher_state_map_.at(coordinator);
state.keys = std::move(keys);
state.expiration = base::Time::Now() + kKeyRequestInterval;
base::UmaHistogramTimes("Ads.InterestGroup.ServerAuction.KeyFetch.TotalTime",
base::TimeTicks::Now() - state.fetch_start);
while (!state.queue.empty()) {
// We call the callback *before* removing the current request from the list.

@ -91,6 +91,8 @@ class CONTENT_EXPORT BiddingAndAuctionServerKeyFetcher {
// this object.
base::Time expiration = base::Time::Min();
base::TimeTicks fetch_start;
// loader_ contains the SimpleURLLoader being used to fetch the keys.
std::unique_ptr<network::SimpleURLLoader> loader;
};

@ -973,6 +973,15 @@ void InterestGroupAuctionReporter::OnNavigateToWinningAd(
}
navigated_to_winning_ad_ = true;
base::UmaHistogramTimes(
base::StrCat(
{"Ads.InterestGroup.",
top_level_seller_winning_bid_info_.saved_response.has_value()
? "ServerAuction"
: "Auction",
".ReportDelay"}),
base::TimeTicks::Now() - start_time_);
// Send any pending reports that are gathered as reports run.
SendPendingReportsIfNavigated();
MaybeSendPrivateAggregationReports();

@ -530,6 +530,8 @@ class CONTENT_EXPORT InterestGroupAuctionReporter {
bool reporting_complete_ = false;
bool navigated_to_winning_ad_ = false;
const base::TimeTicks start_time_ = base::TimeTicks::Now();
// The current reporter phase of worklet invocation. This is never kAdNotUsed,
// but rather one of the others, depending on worklet progress. On
// destruction, if `navigated_to_winning_ad_` is true, this is the logged to

@ -161,8 +161,8 @@ ConvertOwnerJoinerPairsToDataKeys(
InterestGroupManagerImpl::ReportRequest::ReportRequest() = default;
InterestGroupManagerImpl::ReportRequest::~ReportRequest() = default;
InterestGroupManagerImpl::AdAuctionDataLoaderState::AdAuctionDataLoaderState() =
default;
InterestGroupManagerImpl::AdAuctionDataLoaderState::AdAuctionDataLoaderState()
: start_time(base::TimeTicks::Now()) {}
InterestGroupManagerImpl::AdAuctionDataLoaderState::AdAuctionDataLoaderState(
AdAuctionDataLoaderState&& state) = default;
InterestGroupManagerImpl::AdAuctionDataLoaderState::
@ -548,7 +548,11 @@ void InterestGroupManagerImpl::OnLoadedNextInterestGroupAdAuctionData(
void InterestGroupManagerImpl::OnAdAuctionDataLoadComplete(
AdAuctionDataLoaderState state) {
std::move(state.callback).Run(state.serializer.Build());
BiddingAndAuctionData data = state.serializer.Build();
base::UmaHistogramTimes(
"Ads.InterestGroup.ServerAuction.AdAuctionDataLoadTime",
base::TimeTicks::Now() - state.start_time);
std::move(state.callback).Run(std::move(data));
}
void InterestGroupManagerImpl::GetBiddingAndAuctionServerKey(

@ -451,6 +451,7 @@ class CONTENT_EXPORT InterestGroupManagerImpl : public InterestGroupManager {
AdAuctionDataLoaderState(AdAuctionDataLoaderState&& state);
BiddingAndAuctionSerializer serializer;
base::OnceCallback<void(BiddingAndAuctionData)> callback;
base::TimeTicks start_time;
};
// Callbacks for CheckPermissionsAndJoinInterestGroup(),

@ -1242,6 +1242,24 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>
<histogram name="Ads.InterestGroup.ServerAuction.AdAuctionDataLoadTime"
units="ms" expires_after="M125">
<owner>behamilton@google.com</owner>
<owner>pauljensen@chromium.org</owner>
<owner>privacy-sandbox-dev@chromium.org</owner>
<summary>
The length of time it took to load and serialize the request for a Bidding
and Auction Services auction. This includes loading the interest group data
from the database and encoding it. It does not include the time for
encryption.
See
https://github.com/WICG/turtledove/blob/main/FLEDGE_browser_bidding_and_auction_API.md
for the latest version of the Protected Audience Bidding &amp; Auction
Services explainer.
</summary>
</histogram>
<histogram name="Ads.InterestGroup.ServerAuction.EndToEndTime" units="ms"
expires_after="2024-06-02">
<owner>behamilton@google.com</owner>
@ -1280,6 +1298,77 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>
<histogram name="Ads.InterestGroup.ServerAuction.KeyFetch.Cached"
enum="Boolean" expires_after="M125">
<owner>behamilton@google.com</owner>
<owner>pauljensen@chromium.org</owner>
<owner>privacy-sandbox-dev@chromium.org</owner>
<summary>
Whether the key requested for a Bidding and Auction Services auction was
cached and returned immediately. If a fetch request for the key is already
in progress this metric is still recorded with a value of &quot;False&quot;.
See
https://github.com/WICG/turtledove/blob/main/FLEDGE_browser_bidding_and_auction_API.md
for the latest version of the Protected Audience Bidding &amp; Auction
Services explainer.
</summary>
</histogram>
<histogram name="Ads.InterestGroup.ServerAuction.KeyFetch.NetworkCached"
enum="Boolean" expires_after="M125">
<owner>behamilton@google.com</owner>
<owner>pauljensen@chromium.org</owner>
<owner>privacy-sandbox-dev@chromium.org</owner>
<summary>
Whether the fetch for the key requested for a Bidding and Auction Services
auction was served from the Network cache. This metric is only recorded on a
per-fetch level so it will not be recorded if the key is requested while
waiting for an existing fetch for the key to complete.
See
https://github.com/WICG/turtledove/blob/main/FLEDGE_browser_bidding_and_auction_API.md
for the latest version of the Protected Audience Bidding &amp; Auction
Services explainer.
</summary>
</histogram>
<histogram name="Ads.InterestGroup.ServerAuction.KeyFetch.NetworkTime"
units="ms" expires_after="M125">
<owner>behamilton@google.com</owner>
<owner>pauljensen@chromium.org</owner>
<owner>privacy-sandbox-dev@chromium.org</owner>
<summary>
The length of time it took to perform the network fetch for the key
requested for a Bidding and Auction Services auction. This metric is only
recorded on a per-fetch level so it will not be recorded if the key is
requested while waiting for an existing fetch for the key to complete.
See
https://github.com/WICG/turtledove/blob/main/FLEDGE_browser_bidding_and_auction_API.md
for the latest version of the Protected Audience Bidding &amp; Auction
Services explainer.
</summary>
</histogram>
<histogram name="Ads.InterestGroup.ServerAuction.KeyFetch.TotalTime" units="ms"
expires_after="M125">
<owner>behamilton@google.com</owner>
<owner>pauljensen@chromium.org</owner>
<owner>privacy-sandbox-dev@chromium.org</owner>
<summary>
The length of time it took to fetch and parse the key requested for a
Bidding and Auction Services auction. This metric is only recorded on a
per-fetch level so it will not be recorded if the key is requested while
waiting for an existing fetch for the key to complete.
See
https://github.com/WICG/turtledove/blob/main/FLEDGE_browser_bidding_and_auction_API.md
for the latest version of the Protected Audience Bidding &amp; Auction
Services explainer.
</summary>
</histogram>
<histogram name="Ads.InterestGroup.Update.AuctionExecutionMode"
enum="InterestGroupAdAuctionExecutionMode" expires_after="2024-06-20">
<owner>behamilton@google.com</owner>
@ -1379,6 +1468,25 @@ chromium-metrics-reviews@google.com.
</token>
</histogram>
<histogram name="Ads.InterestGroup.{AuctionType}.ReportDelay" units="ms"
expires_after="M125">
<owner>behamilton@google.com</owner>
<owner>pauljensen@chromium.org</owner>
<owner>privacy-sandbox-dev@chromium.org</owner>
<summary>
The length of time between when a {AuctionType} auction returns and
navigation occurs on the winning render URL. Only recorded for the first
navigation. Not recorded if there was no winner in the auction.
See https://github.com/WICG/turtledove/blob/main/FLEDGE.md for the latest
version of the FLEDGE explainer.
</summary>
<token key="AuctionType">
<variant name="Auction" summary="FLEDGE"/>
<variant name="ServerAuction" summary="Bidding and Auction Services"/>
</token>
</histogram>
<histogram name="Ads.InterestGroup.{AuctionType}.Result" enum="AuctionResult"
expires_after="2024-06-20">
<owner>mmenke@chromium.org</owner>