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

WebGPURenderer: Improve performance tracking logic for better accuracy #28748

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

RenaudRohlinger
Copy link
Collaborator

@RenaudRohlinger RenaudRohlinger commented Jun 26, 2024

Related PR: #28741

Description

This is the second part of #28741, continuing my efforts to enhance performance tracking in the new Renderer:

By skipping timestamp queries when a previous one is still resolving, we may miss some frame data (visible as small spikes in the GPU monitor). However, this prevents potential stalls in the rendering pipeline caused by accumulating unresolved async operations.
This tradeoff ensures smoother overall performance, especially in complex scenes where the overhead of constant timestamp querying could significantly impact frame rates and so make meaningless the trackTimestamp feature.

This PR continues to enhance the accuracy of performance tracking. It now tracks performance more accurately without negatively impacting it. This is achieved by monitoring the number of compute programs executed per animation loop and resetting values only after the total timestamp has been correctly accumulated. This involves checking the total number of calls in each cycle using two new variables: previousFrameCalls and timestampCalls.

Basically the monitoring logic has been unwired from the renderer. The await behavior in resolveTimestampAsync has been updated to a simple promise as it was stalling the app loop, altering the array buffers consumed by the programs resulting in instability.

Before this PR (for a simulation with more than 90 compute shaders per frame):
Screenshot 2024-06-26 at 15 17 34

After this PR (the numbers regarding compute programs now make a lot more sense):
Screenshot 2024-06-26 at 15 13 08

By the way while testing the WebGL part I noticed some odd numbers in the webgpu_compute_particles_snow.html example. The WebGPU part runs at around 75 fps, whereas the WebGL backend easily runs at a full 144 fps+ on dev. This is previous to that PR, this PR just highlight the issue. /cc @sunag

This contribution is funded by Utsubo

@RenaudRohlinger RenaudRohlinger added this to the r166 milestone Jun 26, 2024
@sunag sunag merged commit 3defc7d into mrdoob:dev Jun 26, 2024
11 checks passed
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.

2 participants