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

spec percent-scripts-timeout #8

Closed
wants to merge 15 commits into from
99 changes: 73 additions & 26 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2372,10 +2372,14 @@ or "component-auction", a [=currency tag=] |componentAuctionExpectedCurrency|, a
1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/code fetch time
averager=] and |decisionLogicFetcher|'s [=script fetcher/fetch duration=].
1. Let « |scoreAdResult|, |debugWinReportUrl|, |debugLossReportUrl|, |realTimeContributions|,
|paContributions| » be the result of [=evaluating a scoring script=] with |decisionLogicScript|,
|adMetadata|, |bidValue|'s [=bid with currency/value=], |auctionConfig|, |reportingContext|,
|sameOriginTrustedScoringSignals|, |crossOriginTrustedScoringSignals|, |browserSignals|,
|directFromSellerSignalsForSeller|, and |auctionConfig|'s [=auction config/seller timeout=].
|paContributions|, |executionMetrics| » be the result of [=evaluating a scoring script=] with
|decisionLogicScript|, |adMetadata|, |bidValue|'s [=bid with currency/value=], |auctionConfig|,
|reportingContext|, |sameOriginTrustedScoringSignals|, |crossOriginTrustedScoringSignals|,
|browserSignals|, |directFromSellerSignalsForSeller|, and |auctionConfig|'s [=auction config/
seller timeout=].
1. Increment|metrics|'s [=per participant metrics/script executions attempted=] by 1.
1. If |executionMetrics|'s [=execution metrics/script timeout occurred=] is true, increment
|metrics|'s [=per participant metrics/script timeouts occurred=] by 1.
1. If |generatedBid|'s [=generated bid/for k-anon auction=] is true:

Note: Non-k-anonymous bids do not participate in reporting (except for platform real-time
Expand Down Expand Up @@ -2918,13 +2922,17 @@ and a [=global object=] |global|:
|sellerReportingScriptFetcher|.
1. [=Add a sample to an averager=] given |metrics|'s [=per participant metrics/code fetch time
averager=] and |sellerReportingScriptFetcher|'s [=script fetcher/fetch duration=].
1. Let « |sellerSignals|, |reportUrl|, |reportingBeaconMap|, ignored, |paContributions| » be the
result of [=evaluating a reporting script=] with |sellerReportingScript|, "`reportResult`",
|reportingContext|, |config|'s [=auction config/seller=], |config|'s
1. Let « |sellerSignals|, |reportUrl|, |reportingBeaconMap|, ignored, |paContributions|,
|executionMetrics| » be the result of [=evaluating a reporting script=] with
|sellerReportingScript|, "`reportResult`", |reportingContext|,
|config|'s [=auction config/seller=], |config|'s
[=auction config/seller Private Aggregation coordinator=], |config|'s [=auction config/
config idl=]'s {{AuctionAdConfig/reportingTimeout}}, and
« |config|'s [=auction config/config idl=], |browserSignals|, |directFromSellerSignals| ».
1. Let |reportingResult| be a [=reporting result=] with the following [=struct/items=]:
1. Set |metrics|'s [=per participant metrics/script executions attempted=] to 1.
1. If |executionMetrics|'s [=execution metrics/script timeout occurred=] is true, set |metrics|'s
[=per participant metrics/script timeouts occurred=] to 1.
1. Let |reportingResult| be a [=reporting result=] with the following [=struct/items=]:
: [=reporting result/report url=]
:: |reportUrl|
: [=reporting result/reporting beacon map=]
Expand Down Expand Up @@ -3021,14 +3029,18 @@ a {{ReportingBrowserSignals}} |browserSignals|, a [=direct from seller signals=]
1. Let |reportFunctionName| be "`reportWin`".
1. If |winner|'s [=generated bid/provided as additional bid=] is true:
1. Set |reportFunctionName| be "`reportAdditionalBidWin`".
1. Let « ignored, |resultUrl|, |reportingBeaconMap|, |reportingMacroMap|, |paContributions| » be
the result of [=evaluating a reporting script=] with |buyerReportingScript|,
|reportFunctionName|, |reportingContext|, |ig|'s [=interest group/owner=], |ig|'s [=interest
group/Private Aggregation coordinator=], |leadingBidInfo|'s [=leading bid info/auction config=]'s
1. Let « ignored, |resultUrl|, |reportingBeaconMap|, |reportingMacroMap|, |paContributions|,
|executionMetrics| » be the result of [=evaluating a reporting script=] with
|buyerReportingScript|, |reportFunctionName|, |reportingContext|, |ig|'s
[=interest group/owner=], |ig|'s [=interest group/
Private Aggregation coordinator=], |leadingBidInfo|'s [=leading bid info/auction config=]'s
[=auction config/config idl=]'s {{AuctionAdConfig/reportingTimeout}}, and
« |leadingBidInfo|'s [=leading bid info/auction config=]'s [=auction config/config idl=]'s
{{AuctionAdConfig/auctionSignals}}, |perBuyerSignalsForBuyer|, |sellerSignals|,
|reportWinBrowserSignals|, |directFromSellerSignals| ».
1. Set |metrics|'s [=per participant metrics/script executions attempted=] to 1.
1. If |executionMetrics|'s [=execution metrics/script timeout occurred=] is true, set |metrics|'s
[=per participant metrics/script timeouts occurred=] to 1.
1. [=Commit private aggregation contributions=] given |paContributions|, |winner|'s [=generated
bid/reporting id=] and |reportingContext|.
1. Set |leadingBidInfo|'s [=leading bid info/buyer reporting result=] to a [=reporting result=]
Expand Down Expand Up @@ -3719,6 +3731,10 @@ auction in a multi-party auction).
|ig|'s [=interest group/owner=], [=worklet function/generate-bid=].
1. [=Merge samples to an averager=] given |metrics|'s [=per participant metrics/code fetch time
averager=] and |executionMetrics|'s [=execution metrics/code fetch time averager=].
1. Set |metrics|'s [=per participant metrics/script executions attempted=] to
|metrics|'s [=per participant metrics/participating interest group count=].
1. If |executionMetrics|'s [=execution metrics/script timeout occurred=] is true, increment
|metrics|'s [=per participant metrics/script timeouts occurred=] by 1.
1. [=set/Insert=] |id| into |reportingContext|'s [=reporting context/bidder participants=].
1. [=Commit private aggregation contributions=] given |paContributions|, |id| and
|reportingContext|.
Expand Down Expand Up @@ -4124,6 +4140,9 @@ A signal base value is one of the following:
auction, after considering prioritization and capabilities. Interest groups included in this might
not actually get to bid if the cumulative timeout expires, or the script fails to load, etc; or
might decide not to bid, but they would have gotten a chance if nothing went wrong.
: "<dfn><code>percent-scripts-timeout</code></dfn>"
:: The numeric value is percentage of executions of this script that hit their individual timeout,
out of all executions that were expected to happen.

</dl>

Expand Down Expand Up @@ -4212,6 +4231,8 @@ metrics collected from a single execution of a worklet function:
<dl dfn-for="execution metrics">
: <dfn>code fetch time averager</dfn>
:: An [=averager=].
: <dfn>script timeout occurred</dfn>
:: A [=boolean=], initially false.
</dl>

A <dfn>per participant metrics</dfn> is a [=struct=] with the following [=struct/items=],
Expand All @@ -4221,6 +4242,10 @@ representing metrics aggregated over a particular participant (e.g. bidder or se
:: A {{long}}, initially 0.
: <dfn>code fetch time averager</dfn>
:: An [=averager=].
: <dfn>script timeouts occurred</dfn>
:: A {{long}}, initially 0.
: <dfn>script executions attempted</dfn>
:: A {{long}}, initially 0.
</dl>

<h4 dfn-type=dfn>Private Aggregation contributions</h4>
Expand Down Expand Up @@ -4582,6 +4607,20 @@ They return a {{double}}.
participant metrics/code fetch time averager=].
1. If |signalBaseValue| is "<code>[=signal base value/participating-ig-count=]</code>":
1. Return |bidAndScoreMetrics|'s [=per participant metrics/participating interest group count=].
1. If |signalBaseValue| is "<code>[=signal base value/percent-scripts-timeout=]</code>":
1. Return the result of [=computing a percentage metric=] given |metrics|'s [=per participant
metrics/script timeouts occurred=] and |metrics|'s [=per participant metrics/script executions
attempted=].

</div>

<div algorithm>
To <dfn>compute a percentage metric</dfn> given {{long}}s |numerator| and |denominator|:
1. If |denominator| is 0, return 0.
1. Let |result| be 100.0 * |numerator| / |denominator|, performing the computation with
{{double}}s.
1. If |result| &gt; 110.0, set |result| to 110.0
1. Return |result|.

</div>

Expand Down Expand Up @@ -5531,7 +5570,8 @@ of the following global objects:
1. Let |crossOriginTrustedBiddingSignalsJS| be |crossOriginTrustedBiddingSignals|
[=converted to ECMAScript values=].
1. Let |startTime| be |settings|'s [=environment settings object/current monotonic time=].
1. Let |result| be the result of [=evaluating a script=] with |realm|, |script|, "`generateBid`",
1. Let (|result|, |executionMetrics|'s [=execution metrics/script timeout occurred=]) be the
result of [=evaluating a script=] with |realm|, |script|, "`generateBid`",
« |igJS|, |auctionSignalsJS|, |perBuyerSignalsJS|, |sameOriginTrustedBiddingSignalsJS|,
|browserSignalsJS|, |directFromSellerSignalsJS|, |crossOriginTrustedBiddingSignalsJS| »,
and |timeout|.
Expand Down Expand Up @@ -5614,7 +5654,9 @@ of the following global objects:
1. Let |directFromSellerSignalsJs| be |directFromSellerSignalsForSeller|
[=converted to ECMAScript values=].
1. Let |startTime| be |settings|'s [=environment settings object/current monotonic time=].
1. Let |scoreAdResult| be the result of [=evaluating a script=] with |realm|, |script|, "`scoreAd`",
1. Let |executionMetrics| be a new [=execution metrics=].
1. Let (|scoreAdResult|, |executionMetrics|'s [=execution metrics/script timeout occurred=]) be
the result of [=evaluating a script=] with |realm|, |script|, "`scoreAd`",
«|adMetadata|, |bidValue|, |auctionConfigJS|, |sameOriginTrustedScoringSignalsJS|,
|browserSignalsJS|, |directFromSellerSignalsJs|, |crossOriginTrustedScoringSignalsJS|»,
and |timeout|.
Expand All @@ -5636,7 +5678,7 @@ of the following global objects:
1. Let |paContributions| be the result of [=extracting private aggregation contributions=] given
|global|.
1. Return « |scoreAdResult|, |debugWinReportUrl|, |debugLossReportUrl|, |realTimeContributions|,
|paContributions| ».
|paContributions|, |executionMetrics| ».
</div>

<div algorithm>
Expand All @@ -5655,8 +5697,10 @@ of the following global objects:
1. Let |argumentsJS| be the result of [=converting a Web IDL arguments list to an ECMAScript
arguments list|converting=] |arguments| to an ECMAScript arguments list. If this
[=exception/throws=] an exception, return « "null", null, null, null ».
1. Let |result| be the result of [=evaluating a script=] with |realm|, |script|,
|functionName|, |argumentsJS|, and |timeout|.
1. Let |executionMetrics| be a new [=execution metrics=].
1. Let (|result|, |executionMetrics|'s [=execution metrics/script timeout occurred=]) be the
result of [=evaluating a script=] with |realm|, |script|, |functionName|, |argumentsJS|,
and |timeout|.
1. If |result| is an [=ECMAScript/abrupt completion=], return « "null", null, null, null ».
1. Let |resultJSON| be "null".
1. If |functionName| is "`reportResult`", then set |resultJSON| to the result of
Expand All @@ -5673,20 +5717,23 @@ of the following global objects:
|global|.
1. Return « |resultJSON|, |reportURL|,
|global|'s [=InterestGroupReportingScriptRunnerGlobalScope/reporting beacon map=], |macroMap|,
|paContributions| ».
|paContributions|, |executionMetrics| ».
</div>

<div algorithm>
To <dfn>evaluate a script</dfn> with a [=ECMAScript/realm=] |realm|, [=string=] |script|, [=string=]
|functionName|, a [=list=] |arguments|, and an integer millisecond [=duration=] |timeout|, run these steps.
They return a [=ECMAScript/Completion Record=], which is either an [=ECMAScript/abrupt completion=] (in
the case of a parse failure or execution error), or a [=ECMAScript/normal completion=] populated with the
[=ECMAScript/ECMAScript language value=] result of invoking |functionName|.
They return a tuple of a [=ECMAScript/Completion Record=], which is either an [=ECMAScript/abrupt
completion=] (in the case of a parse failure or execution error), or a [=ECMAScript/normal
completion=] populated with the [=ECMAScript/ECMAScript language value=] result of invoking
|functionName|, and a [=boolean=] stating whether the script was interrupted due to reaching
|timeout|.

1. [=Assert=] that these steps are running [=in parallel=].

1. If |timeout| &le; 0, [=immediately=] interrupt the execution and set |finalCompletion| to a
new [=ECMAScript/throw completion=] given null.
1. If |timeout| &le; 0, return (new [=ECMAScript/throw completion=] given null, true).

1. Let |timeoutOccurred| be false.

1. Let |global| be |realm|'s [=realm/global object=], and run these steps in |realm|'s [=realm/agent=]:

Expand Down Expand Up @@ -5717,8 +5764,8 @@ of the following global objects:
|arguments|)).

In |timeout| milliseconds, if the invocation of [$Call$] has not completed,
[=immediately=] interrupt the execution and set |finalCompletion| to a new
[=ECMAScript/throw completion=] given null.
[=immediately=] interrupt the execution, set |finalCompletion| to a new
[=ECMAScript/throw completion=] given null, and set |timeoutOccurred| to true.

1. <i id=evaluate-script-return>Return</i>: at this point |finalCompletion| will be set to a
[=ECMAScript/Completion Record=].
Expand All @@ -5727,7 +5774,7 @@ of the following global objects:
execution context|running JavaScript execution context=], and remove it from the
[=ECMAScript/execution context stack|JavaScript execution context stack=].

1. Return |finalCompletion|.
1. Return (|finalCompletion|, timeoutOccurred).
</div>

## Global scopes ## {#global-scopes}
Expand Down