Skip to content

Commit

Permalink
FLEDGE: Parallelize wait for promises in AuctionConfig...
Browse files Browse the repository at this point in the history
... with startup of worklet process and trusted input signals wait.

(Note that this may ignore some rejected input promises if the auction failed anyway without any bidding happening or some kind of fatal error).

See WICG/turtledove#385 (comment) for background

Bug: 1394750
Change-Id: I1ffb37a43a3aa87e57d9781c7120fc16495b6b60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4111349
Reviewed-by: Russ Hamilton <behamilton@google.com>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Commit-Queue: Maks Orlovich <morlovich@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1089914}
  • Loading branch information
Maks Orlovich authored and Chromium LUCI CQ committed Jan 6, 2023
1 parent aabcb0b commit b9fa534
Show file tree
Hide file tree
Showing 7 changed files with 607 additions and 120 deletions.
25 changes: 17 additions & 8 deletions content/browser/interest_group/auction_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ std::unique_ptr<AuctionRunner> AuctionRunner::CreateAndStart(
std::move(auction_config), std::move(client_security_state),
std::move(is_interest_group_api_allowed_callback),
std::move(abort_receiver), std::move(callback)));
instance->StartAuctionIfReady();
instance->StartAuction();
return instance;
}

Expand All @@ -97,6 +97,7 @@ void AuctionRunner::ResolvedPromiseParam(

blink::AuctionConfig* config = LookupAuction(*owned_auction_config_, auction);
if (!config) {
// TODO(morlovich): Abort on these.
mojo::ReportBadMessage("Invalid auction ID in ResolvedPromiseParam");
return;
}
Expand All @@ -111,7 +112,6 @@ void AuctionRunner::ResolvedPromiseParam(
return;
}
config->non_shared_params.auction_signals = std::move(new_val);
--promise_fields_in_auction_config_;
break;

case blink::mojom::AuctionAdConfigField::kSellerSignals:
Expand All @@ -120,10 +120,22 @@ void AuctionRunner::ResolvedPromiseParam(
return;
}
config->non_shared_params.seller_signals = std::move(new_val);
--promise_fields_in_auction_config_;
break;
}
StartAuctionIfReady();
--promise_fields_in_auction_config_;
DCHECK_EQ(promise_fields_in_auction_config_,
owned_auction_config_->non_shared_params.NumPromises());

if (!auction->is_main_auction() &&
config->non_shared_params.NumPromises() == 0) {
auction_.NotifyComponentConfigPromisesResolved(
auction->get_component_auction());
}

// This may happen when updating a component auction as well.
if (promise_fields_in_auction_config_ == 0) {
auction_.NotifyConfigPromisesResolved();
}
}

void AuctionRunner::Abort() {
Expand Down Expand Up @@ -189,10 +201,7 @@ AuctionRunner::AuctionRunner(
interest_group_manager,
/*auction_start_time=*/base::Time::Now()) {}

void AuctionRunner::StartAuctionIfReady() {
if (promise_fields_in_auction_config_ > 0) {
return;
}
void AuctionRunner::StartAuction() {
auction_.StartLoadInterestGroupsPhase(
is_interest_group_api_allowed_callback_,
base::BindOnce(&AuctionRunner::OnLoadInterestGroupsComplete,
Expand Down
5 changes: 4 additions & 1 deletion content/browser/interest_group/auction_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class CONTENT_EXPORT AuctionRunner : public blink::mojom::AbortableAdAuction {
RunAuctionCallback callback);

// Tells `auction_` to start the loading interest groups phase.
void StartAuctionIfReady();
void StartAuction();

// Invoked asynchronously by `auction_` once all interest groups have loaded.
// Fails the auction if `success` is false. Otherwise, starts the bidding and
Expand Down Expand Up @@ -233,6 +233,9 @@ class CONTENT_EXPORT AuctionRunner : public blink::mojom::AbortableAdAuction {
std::unique_ptr<blink::AuctionConfig> owned_auction_config_;

RunAuctionCallback callback_;

// Number of fields in `owned_auction_config_` that are promises; decremented
// as they get resolved.
int promise_fields_in_auction_config_;

InterestGroupAuction auction_;
Expand Down
Loading

0 comments on commit b9fa534

Please sign in to comment.