Intent to Ship: WebGPU timestamp queries

246 views
Skip to first unread message

François Beaufort

unread,
Oct 26, 2023, 4:21:48 AM10/26/23
to blink-dev, Corentin Wallez

Contact emails

fbea...@google.com, cwa...@google.com


Explainer

https://github.com/gpuweb/gpuweb/issues/614


Specification

https://gpuweb.github.io/gpuweb/#timestamp


Summary

WebGPU timestamp queries allow WebGPU applications to measure precisely (down to the nanosecond) how much time their GPU commands take to execute, especially at the beginning and end of passes. Timestamp queries are heavily used to gain insights into the performance and behavior of GPU workloads.

While the WebGPU specification makes timestamp queries an optional feature due to timing attack concerns, we believe that timestamp queries quantization provides a good middle ground by reducing the precision of timers. To offer even more advanced protection against timing attacks and fingerprinting, timestamp queries are also coarsened based on site isolation status:

- Isolated contexts: timestamp queries are exposed with a resolution of 100 microseconds.

- Non-isolated contexts: timestamp queries are not exposed at all.


Blink component

Blink>WebGPU


TAG review

WebGPU spec: https://github.com/w3ctag/design-reviews/issues/626


TAG review status

A new TAG review was not requested because timestamp queries were already part of the original one for the WebGPU spec and was approved.


Risks



Interoperability and Compatibility

Timestamp queries have not yet been implemented in any browser, but have been approved by the GPU for the Web Community Group, with representatives from Chrome, Firefox, and Safari. See https://github.com/gpuweb/gpuweb/wiki/Minutes-2021-09-27#:~:text=consensus%20to%20support%20end/begin%2Dpass%20timestamp%20queries


Gecko: Positive (https://bugzilla.mozilla.org/show_bug.cgi?id=1827998)


WebKit: Positive (https://github.com/gpuweb/gpuweb/pull/2190)


Web developers: Positive. It’s one of the most common requested features. Many developers already use it today by running chrome with a special flag. See https://omar-shehata.medium.com/how-to-use-webgpu-timestamp-query-9bf81fb5344a
Note that it was heavily used to benchmark and optimize Tensorflow.js.


Other signals:


WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None at the moment, WebGPU currently does not ship on Android WebView. Parallel work is occurring to launch WebGPU on Android.



Debuggability

No DevTools changes are required.


Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

No

All platforms will eventually have support. Will immediately be available on ChromeOS, Mac, and Windows, since those platforms already support WebGPU. Linux and Android are planned to have WebGPU support in the future, so this feature will become available when WebGPU does.


Is this feature fully tested by web-platform-tests?

Yes

WebGPU/WGSL have a conformance test suite (https://github.com/gpuweb/cts) that is regularly pulled into Chromium and part of the testing of Dawn/Tint in Chromium.


Flag name on chrome://flags

None


Finch feature name

None


Non-finch justification

None


Requires code in //chrome?

False


Tracking bug

https://bugs.chromium.org/p/dawn/issues/detail?id=1800


Availability expectation

Feature is available only in Chromium browsers for the near future, on the order of months. Other browsers intend to ship WebGPU support, but don't have specified timelines.


Non-OSS dependencies

Does the feature depend on any code or APIs outside the Chromium open source repository and its open-source dependencies to function?

No


Estimated milestones

Shipping on desktop

121


Anticipated spec changes

Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).

None


Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5136606877188096


This intent message was generated by Chrome Platform Status.


Domenic Denicola

unread,
Oct 26, 2023, 5:05:51 AM10/26/23
to François Beaufort, blink-dev, Corentin Wallez
On Thu, Oct 26, 2023 at 5:21 PM 'François Beaufort' via blink-dev <blin...@chromium.org> wrote:

Contact emails

fbea...@google.com, cwa...@google.com


Explainer

https://github.com/gpuweb/gpuweb/issues/614


Specification

https://gpuweb.github.io/gpuweb/#timestamp


Summary

WebGPU timestamp queries allow WebGPU applications to measure precisely (down to the nanosecond) how much time their GPU commands take to execute, especially at the beginning and end of passes. Timestamp queries are heavily used to gain insights into the performance and behavior of GPU workloads.

While the WebGPU specification makes timestamp queries an optional feature due to timing attack concerns, we believe that timestamp queries quantization provides a good middle ground by reducing the precision of timers. To offer even more advanced protection against timing attacks and fingerprinting, timestamp queries are also coarsened based on site isolation status:

- Isolated contexts: timestamp queries are exposed with a resolution of 100 microseconds.

- Non-isolated contexts: timestamp queries are not exposed at all.


By "isolated" do you mean "has the cross-origin isolated capability"?

I wasn't able to find any spec or tests for this requirement, which seems like a potential interoperability issue.
 
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAPpwU5%2BEFoeuehbvaMwzXK3wZ6UxX0U4n7yZJwwJgVOADbBwHA%40mail.gmail.com.

François Beaufort

unread,
Oct 26, 2023, 6:21:07 AM10/26/23
to Domenic Denicola, blink-dev, Corentin Wallez
On Thu, Oct 26, 2023 at 11:05 AM Domenic Denicola <dom...@chromium.org> wrote:


On Thu, Oct 26, 2023 at 5:21 PM 'François Beaufort' via blink-dev <blin...@chromium.org> wrote:

Contact emails

fbea...@google.com, cwa...@google.com


Explainer

https://github.com/gpuweb/gpuweb/issues/614


Specification

https://gpuweb.github.io/gpuweb/#timestamp


Summary

WebGPU timestamp queries allow WebGPU applications to measure precisely (down to the nanosecond) how much time their GPU commands take to execute, especially at the beginning and end of passes. Timestamp queries are heavily used to gain insights into the performance and behavior of GPU workloads.

While the WebGPU specification makes timestamp queries an optional feature due to timing attack concerns, we believe that timestamp queries quantization provides a good middle ground by reducing the precision of timers. To offer even more advanced protection against timing attacks and fingerprinting, timestamp queries are also coarsened based on site isolation status:

- Isolated contexts: timestamp queries are exposed with a resolution of 100 microseconds.

- Non-isolated contexts: timestamp queries are not exposed at all.


By "isolated" do you mean "has the cross-origin isolated capability"?

Yes.
 

I wasn't able to find any spec or tests for this requirement, which seems like a potential interoperability issue.

The WebGPU spec currently says: "The feature is optional, and a WebGPU implementation may limit its exposure only to those scenarios that are trusted."
See https://gpuweb.github.io/gpuweb/#security-timing:~:text=The%20feature%20is%20optional%2C%20and%20a%20WebGPU%20implementation%20may%20limit%20its%20exposure%20only%20to%20those%20scenarios%20that%20are%20trusted

Ashley Gullen

unread,
Oct 26, 2023, 8:32:22 AM10/26/23
to François Beaufort, blink-dev
Is the requirement for cross-origin isolation stricter than the requirements to use EXT_disjoint_timer_query{_webgl2}? If so it will present a porting problem when switching WebGL content to WebGPU.


Chris Harrelson

unread,
Oct 26, 2023, 10:26:52 AM10/26/23
to François Beaufort, blink-dev, Corentin Wallez
On Thu, Oct 26, 2023 at 1:21 AM 'François Beaufort' via blink-dev <blin...@chromium.org> wrote:

Contact emails

fbea...@google.com, cwa...@google.com


Explainer

https://github.com/gpuweb/gpuweb/issues/614


Specification

https://gpuweb.github.io/gpuweb/#timestamp


Summary

WebGPU timestamp queries allow WebGPU applications to measure precisely (down to the nanosecond) how much time their GPU commands take to execute, especially at the beginning and end of passes. Timestamp queries are heavily used to gain insights into the performance and behavior of GPU workloads.

While the WebGPU specification makes timestamp queries an optional feature due to timing attack concerns, we believe that timestamp queries quantization provides a good middle ground by reducing the precision of timers. To offer even more advanced protection against timing attacks and fingerprinting, timestamp queries are also coarsened based on site isolation status:

- Isolated contexts: timestamp queries are exposed with a resolution of 100 microseconds.

- Non-isolated contexts: timestamp queries are not exposed at all.


Blink component

Blink>WebGPU


TAG review

WebGPU spec: https://github.com/w3ctag/design-reviews/issues/626


TAG review status

A new TAG review was not requested because timestamp queries were already part of the original one for the WebGPU spec and was approved.


Risks



Interoperability and Compatibility

Timestamp queries have not yet been implemented in any browser, but have been approved by the GPU for the Web Community Group, with representatives from Chrome, Firefox, and Safari. See https://github.com/gpuweb/gpuweb/wiki/Minutes-2021-09-27#:~:text=consensus%20to%20support%20end/begin%2Dpass%20timestamp%20queries


Gecko: Positive (https://bugzilla.mozilla.org/show_bug.cgi?id=1827998)


WebKit: Positive (https://github.com/gpuweb/gpuweb/pull/2190)


Please file positions according to bit.ly/blink-signals. There is not (yet) a carve-out for WebGPU.
 

Jeffrey Yasskin

unread,
Oct 26, 2023, 12:36:49 PM10/26/23
to François Beaufort, blink-dev, Corentin Wallez
On Thu, Oct 26, 2023 at 1:21 AM 'François Beaufort' via blink-dev <blin...@chromium.org> wrote:

Contact emails

fbea...@google.com, cwa...@google.com


Explainer

https://github.com/gpuweb/gpuweb/issues/614


Specification

https://gpuweb.github.io/gpuweb/#timestamp


Summary

WebGPU timestamp queries allow WebGPU applications to measure precisely (down to the nanosecond) how much time their GPU commands take to execute, especially at the beginning and end of passes. Timestamp queries are heavily used to gain insights into the performance and behavior of GPU workloads.

While the WebGPU specification makes timestamp queries an optional feature due to timing attack concerns, we believe that timestamp queries quantization provides a good middle ground by reducing the precision of timers. To offer even more advanced protection against timing attacks and fingerprinting, timestamp queries are also coarsened based on site isolation status:

- Isolated contexts: timestamp queries are exposed with a resolution of 100 microseconds.

- Non-isolated contexts: timestamp queries are not exposed at all.


For what it's worth, I suspect that it would be ok to expose the same resolution as `performance.now()`, which is available in non-isolated contexts. Kai's https://github.com/gpuweb/gpuweb/issues/4175 discusses this (aligning the coarsening behavior with the HR-time spec). I do think it'd be fine to ship what you're suggesting and then align the behavior (which would make it more precise) later.

Jeffrey

Domenic Denicola

unread,
Oct 26, 2023, 8:19:17 PM10/26/23
to François Beaufort, Domenic Denicola, blink-dev, Corentin Wallez
On Thu, Oct 26, 2023 at 7:21 PM François Beaufort <fbea...@google.com> wrote:


On Thu, Oct 26, 2023 at 11:05 AM Domenic Denicola <dom...@chromium.org> wrote:


On Thu, Oct 26, 2023 at 5:21 PM 'François Beaufort' via blink-dev <blin...@chromium.org> wrote:

Contact emails

fbea...@google.com, cwa...@google.com


Explainer

https://github.com/gpuweb/gpuweb/issues/614


Specification

https://gpuweb.github.io/gpuweb/#timestamp


Summary

WebGPU timestamp queries allow WebGPU applications to measure precisely (down to the nanosecond) how much time their GPU commands take to execute, especially at the beginning and end of passes. Timestamp queries are heavily used to gain insights into the performance and behavior of GPU workloads.

While the WebGPU specification makes timestamp queries an optional feature due to timing attack concerns, we believe that timestamp queries quantization provides a good middle ground by reducing the precision of timers. To offer even more advanced protection against timing attacks and fingerprinting, timestamp queries are also coarsened based on site isolation status:

- Isolated contexts: timestamp queries are exposed with a resolution of 100 microseconds.

- Non-isolated contexts: timestamp queries are not exposed at all.


By "isolated" do you mean "has the cross-origin isolated capability"?

Yes.
 

I wasn't able to find any spec or tests for this requirement, which seems like a potential interoperability issue.

The WebGPU spec currently says: "The feature is optional, and a WebGPU implementation may limit its exposure only to those scenarios that are trusted."
See https://gpuweb.github.io/gpuweb/#security-timing:~:text=The%20feature%20is%20optional%2C%20and%20a%20WebGPU%20implementation%20may%20limit%20its%20exposure%20only%20to%20those%20scenarios%20that%20are%20trusted

I realize that. I was suggesting that, for interoperability purposes, you should consider specifying the actual condition, instead of leaving it vague and optional. (E.g. at least in other standards bodies, we have guidance to avoid optional or implementation-defined features; instead, we try to work together with other browser engines to come to a common, interoperable implementation, backed by a test suite.)

I hope the API Owners can consider this when deciding whether or not to approve, as I believe that letting these sorts of non-specified and non-tested features be shipped is harmful for the platform's health.

Corentin Wallez

unread,
Oct 30, 2023, 12:59:29 PM10/30/23
to Domenic Denicola, François Beaufort, blink-dev
On Fri, Oct 27, 2023 at 2:19 AM Domenic Denicola <dom...@chromium.org> wrote:


On Thu, Oct 26, 2023 at 7:21 PM François Beaufort <fbea...@google.com> wrote:


On Thu, Oct 26, 2023 at 11:05 AM Domenic Denicola <dom...@chromium.org> wrote:


On Thu, Oct 26, 2023 at 5:21 PM 'François Beaufort' via blink-dev <blin...@chromium.org> wrote:

Contact emails

fbea...@google.com, cwa...@google.com


Explainer

https://github.com/gpuweb/gpuweb/issues/614


Specification

https://gpuweb.github.io/gpuweb/#timestamp


Summary

WebGPU timestamp queries allow WebGPU applications to measure precisely (down to the nanosecond) how much time their GPU commands take to execute, especially at the beginning and end of passes. Timestamp queries are heavily used to gain insights into the performance and behavior of GPU workloads.

While the WebGPU specification makes timestamp queries an optional feature due to timing attack concerns, we believe that timestamp queries quantization provides a good middle ground by reducing the precision of timers. To offer even more advanced protection against timing attacks and fingerprinting, timestamp queries are also coarsened based on site isolation status:

- Isolated contexts: timestamp queries are exposed with a resolution of 100 microseconds.

- Non-isolated contexts: timestamp queries are not exposed at all.


By "isolated" do you mean "has the cross-origin isolated capability"?

Yes.
 

I wasn't able to find any spec or tests for this requirement, which seems like a potential interoperability issue.

The WebGPU spec currently says: "The feature is optional, and a WebGPU implementation may limit its exposure only to those scenarios that are trusted."
See https://gpuweb.github.io/gpuweb/#security-timing:~:text=The%20feature%20is%20optional%2C%20and%20a%20WebGPU%20implementation%20may%20limit%20its%20exposure%20only%20to%20those%20scenarios%20that%20are%20trusted

I realize that. I was suggesting that, for interoperability purposes, you should consider specifying the actual condition, instead of leaving it vague and optional. (E.g. at least in other standards bodies, we have guidance to avoid optional or implementation-defined features; instead, we try to work together with other browser engines to come to a common, interoperable implementation, backed by a test suite.)

I hope the API Owners can consider this when deciding whether or not to approve, as I believe that letting these sorts of non-specified and non-tested features be shipped is harmful for the platform's health.
 
I'll add discussion of that to the agenda for this week's WebGPU meeting: can we agree on the availability of timestamp queries (provided there is hardware support) and the quantization depending on contexts. (but to be perfectly honest I think we'll have pushback). Of course the WebGPU standard body tries to avoid implementation-defined features, and instead have deterministic and tested features, but timestamps is one of the ones that might need to be an exception to it. Let's see what consensus the group comes to!

Mike Taylor

unread,
Oct 30, 2023, 2:39:55 PM10/30/23
to Corentin Wallez, Domenic Denicola, François Beaufort, blink-dev

On 10/30/23 12:59 PM, Corentin Wallez wrote:

On Fri, Oct 27, 2023 at 2:19 AM Domenic Denicola <dom...@chromium.org> wrote:


On Thu, Oct 26, 2023 at 7:21 PM François Beaufort <fbea...@google.com> wrote:


On Thu, Oct 26, 2023 at 11:05 AM Domenic Denicola <dom...@chromium.org> wrote:


On Thu, Oct 26, 2023 at 5:21 PM 'François Beaufort' via blink-dev <blin...@chromium.org> wrote:

Contact emails

fbea...@google.com, cwa...@google.com


Explainer

https://github.com/gpuweb/gpuweb/issues/614


Specification

https://gpuweb.github.io/gpuweb/#timestamp


Summary

WebGPU timestamp queries allow WebGPU applications to measure precisely (down to the nanosecond) how much time their GPU commands take to execute, especially at the beginning and end of passes. Timestamp queries are heavily used to gain insights into the performance and behavior of GPU workloads.

While the WebGPU specification makes timestamp queries an optional feature due to timing attack concerns, we believe that timestamp queries quantization provides a good middle ground by reducing the precision of timers. To offer even more advanced protection against timing attacks and fingerprinting, timestamp queries are also coarsened based on site isolation status:

- Isolated contexts: timestamp queries are exposed with a resolution of 100 microseconds.

- Non-isolated contexts: timestamp queries are not exposed at all.


By "isolated" do you mean "has the cross-origin isolated capability"?

Yes.
 

I wasn't able to find any spec or tests for this requirement, which seems like a potential interoperability issue.

The WebGPU spec currently says: "The feature is optional, and a WebGPU implementation may limit its exposure only to those scenarios that are trusted."
See https://gpuweb.github.io/gpuweb/#security-timing:~:text=The%20feature%20is%20optional%2C%20and%20a%20WebGPU%20implementation%20may%20limit%20its%20exposure%20only%20to%20those%20scenarios%20that%20are%20trusted

I realize that. I was suggesting that, for interoperability purposes, you should consider specifying the actual condition, instead of leaving it vague and optional. (E.g. at least in other standards bodies, we have guidance to avoid optional or implementation-defined features; instead, we try to work together with other browser engines to come to a common, interoperable implementation, backed by a test suite.)

I hope the API Owners can consider this when deciding whether or not to approve, as I believe that letting these sorts of non-specified and non-tested features be shipped is harmful for the platform's health.
 
I'll add discussion of that to the agenda for this week's WebGPU meeting: can we agree on the availability of timestamp queries (provided there is hardware support) and the quantization depending on contexts. (but to be perfectly honest I think we'll have pushback). Of course the WebGPU standard body tries to avoid implementation-defined features, and instead have deterministic and tested features, but timestamps is one of the ones that might need to be an exception to it. Let's see what consensus the group comes to!
 
Thank you - looking forward to the update.

François Beaufort

unread,
Nov 7, 2023, 3:31:59 AM11/7/23
to Chris Harrelson, blink-dev, Corentin Wallez

François Beaufort

unread,
Nov 7, 2023, 3:42:09 AM11/7/23
to Mike Taylor, Corentin Wallez, Domenic Denicola, blink-dev
Good news! The members of the GPU for the Web Community Group have accepted a proposal to allow timestamps regardless of site isolation, always with the non-isolated resolution from hr-time (100us). 
Check out the spec PR at https://github.com/gpuweb/gpuweb/pull/4359 and updated spec at https://gpuweb.github.io/gpuweb/#security-timing. This decision aims to address the interoperability concerns raised earlier.

Domenic Denicola

unread,
Nov 7, 2023, 8:34:40 PM11/7/23
to François Beaufort, Mike Taylor, Corentin Wallez, Domenic Denicola, blink-dev
That's great! Using the same time resolution as the rest of the platform makes sense, and this definitely addresses my interop concerns. Thanks to you and the group for making this change!
 

Yoav Weiss

unread,
Nov 8, 2023, 3:42:16 AM11/8/23
to Domenic Denicola, François Beaufort, Mike Taylor, Corentin Wallez, blink-dev
LGTM1

Thanks for working through this issue!!

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Daniel Bratell

unread,
Nov 8, 2023, 10:38:18 AM11/8/23
to Yoav Weiss, Domenic Denicola, François Beaufort, Mike Taylor, Corentin Wallez, blink-dev

LGTM2

100 microseconds sound very coarse for this, but I guess that just means they have to average data over many frames. And if they are happy, I'm happy.

/Daniel

Chris Harrelson

unread,
Nov 8, 2023, 11:35:09 AM11/8/23
to Daniel Bratell, Yoav Weiss, Domenic Denicola, François Beaufort, Mike Taylor, Corentin Wallez, blink-dev
Reply all
Reply to author
Forward
0 new messages