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

More explicit representation of script fetch parallelism #1225

Merged
merged 20 commits into from
Jul 22, 2024

Conversation

morlovich
Copy link
Collaborator

@morlovich morlovich commented Jul 11, 2024

This turns script fetches into asynchronous operations, with separate fetch start and waiting for results, with a separate
operation to wait for just the cross-origin trusted seller signals authorization. This representation also makes it easier to show which fetches are shared/reused, rather than making it look like we keep re-fetching things.

Only seller scripts really take advantage of this capabilities in this change.


Preview | Diff

|ig|'s [=interest group/bidding url=].
1. Let |biddingScript| be the result of [=waiting for script body from a fetcher=] given
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the right way to describe a non-blocking wait on a fetch? Reading the stuff this and the above line link to, it sounds like we queue a task off thread...and then synchronously wait for it to complete on the main thread.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're correct --- it doesn't change anything at this call sight [1]. Seller scripts are improved to:

  1. Start one fetch early, not have one every time we want to call scoreAd() (!)
  2. Have some asynchrony/overlap in timing between the fetch start and use.
    ... the plan to get both of those for bidders is to basically make a giant map and fetch all the scripts, as a separate change.

...but to fully fix parallelism, we need to make the actual bidding happen all in parallel, too, so the blocking happens off-thread. Which is tricky because of shared data structures.

My immediate interest was in making the dependency on the headers for cross-origin trusted seller signals stuff more explicit.

Copy link
Contributor

@dmdabbs dmdabbs Jul 11, 2024

Choose a reason for hiding this comment

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

...but to fully fix parallelism,

So the implementation has parallelism, the spec currently doesn't adequately describe it?

spec.bs Outdated

<dl dfn-for="script fetcher">
: <dfn>script body</dfn>
:: A [=byte sequence=], null or failure. Initially null. The body of the script.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comma after null. At least the Oxford comma seems to be pretty universal, at this point?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

1. Otherwise, set set |fetcher|'s [=script fetcher/script body=] to |responseBody|.
1. Let |failureSteps| be a set of steps that take an [=exception=] <var ignore>e</var>, and
perform the following:
1. Set set |fetcher|'s [=script fetcher/script body=] to failure.
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't figure out if fetch calls processResponse on errors. The fetch spec never actually mentions calling fetch/processResponse, just setting it / passing it as an argument, as far as I can see.

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 think fetch/processResponse gets copied to fetchParams/process response:

https://fetch.spec.whatwg.org/#ref-for-fetch-params-process-response:~:text=Let%20fetchParams%20be,is%20crossOriginIsolatedCapability.

And that will eventually get used in the function called here:
https://fetch.spec.whatwg.org/#ref-for-fetch-finale:~:text=Otherwise%2C%20run%20fetch%20response%20handover%20given%20fetchParams%20and%20response.

...and this does look like it's used for errors, though there is a good chance I am wrong since my ability to follow the fetch spec is poor.

...but I have a hard time following the fetch spec myself.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're right - I completely missed that they renamed "processResponse" to "process response" when passing it as an argument. :(

Copy link
Contributor

@MattMenke2 MattMenke2 left a comment

Choose a reason for hiding this comment

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

Oops, didn't mean to send that comma comment as a singleton.

Copy link
Contributor

@MattMenke2 MattMenke2 left a comment

Choose a reason for hiding this comment

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

This all looks good to me. Not confident I'm not missing something, though.

@morlovich morlovich requested a review from miketaylr July 12, 2024 17:13
@morlovich
Copy link
Collaborator Author

Any chance you may be able to look at this, Mike? Dominic appears to be unavailable...

@JensenPaul JensenPaul added the spec Relates to the spec label Jul 18, 2024
Copy link
Collaborator

@miketaylr miketaylr left a comment

Choose a reason for hiding this comment

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

this refactor lgtm

(sorry for the delay!)

@JensenPaul JensenPaul merged commit 032f159 into WICG:main Jul 22, 2024
2 checks passed
github-actions bot added a commit that referenced this pull request Jul 22, 2024
SHA: 032f159
Reason: push, by JensenPaul

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to morlovich/turtledove that referenced this pull request Jul 22, 2024
SHA: 032f159
Reason: push, by morlovich

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
caraitto added a commit to caraitto/turtledove that referenced this pull request Jan 22, 2025
Some changes in WICG#1340 and WICG#1225 broke the spec build.

@xtlsheep @morlovich
JensenPaul pushed a commit that referenced this pull request Jan 23, 2025
Some changes in #1340 and #1225 broke the spec build.

@xtlsheep @morlovich
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.

5 participants