Skip to content

API tracing #289

Closed
Closed
@kvark

Description

@kvark

API tracing is a feature that allows to serialize the workload that the library is processing over a period of time, so that it can be replayed later, potentially on a different machine and with a different GPU backend. It opens up a way to capture bugs (for investigating either the implementation or the application issues), share interesting workloads (as a form of art), or even do benchmarking.

At this point, it's clear that WebGPU as an API needs some tooling for workload capturing. There probably will appear some JS-based tools developed by the users and browser vendors. This issue is focuses on the native targets. Let's see what options we have to proceed:

A: Intercept in Rust, serialize with Serde.

This basically means transforming all the workload inputs (object descriptors, handles, etc), into pure Rust structs that implement Serde traits and recording them.

What this gives us:

  • Convenience of Rust and its ecosystem (i.e can use RON format as destination).
  • Can start the work today, not blocked by anything
  • Can build an internal testing and benchmarking suite based on the captured format
  • If used in conjunction with Capturing internal state for debug investigations #72, could support recording from a particular point (as opposed to the start of an application).

What's not clear is where this hookup should live. It could be a separate layer on top of wgpu-native, it could be a part of wgpu-remote, or be a part of wgpu-rs even.

B: develop a backend for RenderDoc and integrate with it

Given that RenderDoc became a central piece of the developer graphics tools, and it's open source, there is an opportunity here to start collaborating.

What this gives us:

  • RenderDoc is not an afterthought, we get it from day 1
  • convenience of the GUI

C: wait for the native tooling to emerge

We are not the only party interested in this technology. Obviously, Google is either already in process, or will attempt to build some tooling for tracing the API at the C level. Something like wgpuTrace as an analogy to vkTrace and apiTrace.

For us this plan means letting the things to advance by Google and assisting where time allows, focusing on interoperability with wgpu-native implementation (since clearly a hypothetical wgpuTrace will be catering to Dawn first and foremost).

What this gives us:

  • path of least resistance

Now, I'm personally leaning towards (A) since I don't think this is going to be a huge amount of work, I think it could play well with #72, it will allow us to inspect and modify captures in RON by hands, and build some testing/benchmarking without relying on external suites.

My understanding is that when/if wgpuTrace becomes a thing, we'll just set up a tooling for bidirectional conversion to its binary format, effectively mimicking how ApiTrace trace is different from the dump.

This is a heavy RFC, please share your thoughts!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions