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

Suggestion to introduce wgpu-sync for lock profiling #5183

Closed
wants to merge 1 commit into from

Conversation

udoprog
Copy link
Contributor

@udoprog udoprog commented Feb 1, 2024

Connections
Initially I started working on this to introduce loom tests, but I figured building a face like this would be useful to troubleshoot potential issues and bottlenecks caused by locks.

Could be used to troubleshoot issues which ask whether things have become slower with arcanization and increased use of locks in wgpu, such as #5180.

Description
This introduces a compatible layer which conditionally replaces Mutexes and RwLocks with facades which efficiently captures events into a global collection. This is compile-time enabled with the "trace" feature. Using this, users of wgpu can capture a lock trace, and generate a html report like this:

    if condition {
        wgpu::sync::capture();
    }

    /* do some wgpu work */

    if condition {
        let events = wgpu::sync::drain();

        let f = std::fs::File::create("trace.html").context("Creating trace.html")?;
        wgpu::sync::html::write(f, &events).context("Writing trace.html")?;
        println!("Wrote trace.html");
    }

I've included an example report I've generated from one of my projects here:
https://udoprog.github.io/trace.html

Note that if the "trace" feature is disabled, wgpu-sync instead provides the original parking_lot implementations without using facades.

This is a draft for now. Please take a look and tell me if y'all are interested in adopting something like this.

@udoprog udoprog requested a review from a team as a code owner February 1, 2024 12:05
@udoprog udoprog marked this pull request as draft February 1, 2024 12:05
@udoprog udoprog force-pushed the wgpu-sync branch 11 times, most recently from ccca0ca to 0bacfc1 Compare February 3, 2024 05:58
@udoprog
Copy link
Contributor Author

udoprog commented Feb 3, 2024

Closing for now to calm the builds down. I'll keep my branch around for profiling and might suggest it for inclusion later if it pans out.

@udoprog udoprog closed this Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant