Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further work on promise handling: #655

Merged
merged 9 commits into from
Jun 30, 2023
Merged

Conversation

morlovich
Copy link
Collaborator

@morlovich morlovich commented Jun 21, 2023

  1. Convert the other fields (except resolveToConfig, which is special) to behave the way perBuyerSignals does, simplifying the language some and making them more web-y.
  2. Make perBuyerCurrencies handle promises as well.
  3. Hopefully fix a bug where we weren't actually waiting on promises for top-level config in a 2-level auction.

Preview | Diff

Maks Orlovich added 2 commits June 21, 2023 14:30
1. Convert the other fields (except resolveToConfig, which is special)
   to behave the way perBuyerSignals does, simplifying the language some
   and making them more web-y.
2. Make perBuyerCurrencies handle promises as well.
3. Hopefully fix a bug where we weren't actually waiting on promises for
   top-level config in a 2-level auction.
@morlovich morlovich added the spec Relates to the spec label Jun 21, 2023
@morlovich morlovich requested a review from jyasskin June 21, 2023 18:38
spec.bs Show resolved Hide resolved
spec.bs Outdated
@@ -837,6 +838,7 @@ To <dfn>generate and score bids</dfn> given an [=auction config=] |auctionConfig
|auctionConfig|, |global|, and |settings|.
1. If |compWinner| is failure, return failure.
1. If |compWinner| is not null:
1. If [=waiting until configuration input promises resolve=] given |auctionConfig| returns failure, return failure.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this inside a parallel queue will mean that all subsequent steps get delayed. That's probably fine in this case since the wait has the same condition for all of them, and so subsequent ones won't wait anymore, but that means you can probably move it up in front of the overall loop so that future reviewers don't worry about this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unclear as to what you mean by subsequent here given the, well, parallelism.

What this is trying to achieve, at any rate, is this:

  1. Component auctions only need to wait for their own configuration to resolve to start bidding process.
  2. Top-level auction needs the whole hierarchy before starting its scoring, but its own scoring happens after a component makes a bid (before this change, it could still have some promises hanging out).
    We do not want to delay Can COWL be useful for ths use case? #1 for promises in top-level config, which is what I think your suggestion would do?

Actually, mistake #1: the top-level needs all component auctions to have a complete configuration, not just the one who bid its considering, since it needs to pass an entire AuctionConfig to scoreAd.

Mistake #2: we do wait for configs for nested auctions even if they did not actually make a bid in top-level auction, in order to type-check them (though that can race with other reasons for auction to fail).

... Working on fixing these...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...And hopefully done.

spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
@@ -722,6 +692,7 @@ To <dfn>validate and convert auction ad config</dfn> given an {{AuctionAdConfig}
1. If |config|["{{AuctionAdConfig/resolveToConfig}}"] [=map/exists=]:
1. Let |auctionConfig|'s [=auction config/resolve to config=] be
|config|["{{AuctionAdConfig/resolveToConfig}}"].
1. TODO: What should happen if this rejects?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can either pretend it wasn't passed or reject the whole auction, right? It looks like other rejected promises bubble up to failing the whole auction, so this one probably should too. But no need to do that in this PR.

I'm actually surprised this needs to be async, since it affects the return type of runAdAuction(). Isn't the expected return type compiled into the code statically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typedef (USVString or FencedFrameConfig) UrnOrConfig;
Promise<UrnOrConfig?> runAdAuction(AuctionAdConfig config);

Yeah, impl-wise rejecting this also aborts the whole auction, which I guess could be done by setting this to failure and checking for that when accessing it, just like for others (unless we totally change the approach).

... This one promise is a bit different since it's needed much, much, later than others, hence the "input promise" terminology in my helpers

@@ -836,6 +807,7 @@ To <dfn>generate and score bids</dfn> given an [=auction config=] |auctionConfig
1. Let |compWinner| be the result of running [=generate and score bids=] with |component|,
|auctionConfig|, |global|, and |settings|.
1. If |compWinner| is failure, return failure.
1. If [=recursively wait until configuration input promises resolve=] given |auctionConfig| returns failure, return failure.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should either remove the parallel queue, and write:

[=list/For each=] |component| in |auctionConfig|'s [=auction config/component auctions=],
run the following steps [=in parallel=]:

Or move this to before "If auctionConfig’s component auctions are not empty:".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would run into trouble with concurrently trying to update leadingBidInfo. It may be reasonable to split [=score and rank a bid=] into two parts, one functional (scoring), and one for updating leadingBidInfo ("ranking"), in which case all the scoring could be parallel, and then ranking be done on collected results...

... but at any rate, I would prefer if that wasn't part of this particular CL. As is, this line is a correctness fix...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to make this part of #662 instead of this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still prefer this line here --- it's imperfect, but it makes the spec run correct auctions correctly but slower-than-necessary rather than crash.

spec.bs Outdated Show resolved Hide resolved
@JensenPaul JensenPaul merged commit aa7c04c into WICG:main Jun 30, 2023
github-actions bot added a commit that referenced this pull request Jun 30, 2023
SHA: aa7c04c
Reason: push, by JensenPaul

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec Relates to the spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants