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

Split the tracker into stateful/stateless to reduce the overhead #1417

Merged
merged 1 commit into from
Jun 1, 2021

Conversation

kvark
Copy link
Member

@kvark kvark commented May 31, 2021

Connections
Implements #1413 (comment)
Reduces the overhead for resource tracking in the Animometer benchmark by up to 50%.

Description
We used to use the full tracker set on the usage scopes associated with compute/render passes. A resource tracker has 2 responsibilities: ensuring the resource is held alive, and validating and recording the state transitions. This PR exploits the fact that the latter responsibility is only applicable for buffers and textures. So doing all the lifetime tracking for a pass is a waste: we can instead just attach the lifetimes to the parent command buffer, straight.

In the Animometer benchmark, there is one large buffer, and thousands of bind groups pointing to different offsets into it. The old code would fill up the pass tracker with those bind groups, and then merge it into the command buffer tracker. The new code would just fill up the command buffer tracker instead. Since there is only one buffer, the pass tracking becomes much lighter.

Testing
Untested. It would be nice to have some benchmarks here, possibly after #1397 ?

@kvark kvark requested a review from cwfitzgerald May 31, 2021 18:25
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 1, 2021

@bors bors bot merged commit 9cd0163 into gfx-rs:master Jun 1, 2021
@kvark kvark deleted the track branch June 1, 2021 12:43
bors bot added a commit to gfx-rs/wgpu-rs that referenced this pull request Jun 1, 2021
921: Update wgpu to eadaa1b r=kvark a=kvark

Picks up gfx-rs/wgpu#1419, gfx-rs/wgpu#1417, and gfx-rs/wgpu#1403

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
kvark added a commit to kvark/wgpu that referenced this pull request Jun 3, 2021
921: Update wgpu to eadaa1b r=kvark a=kvark

Picks up gfx-rs#1419, gfx-rs#1417, and gfx-rs#1403

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
bors bot added a commit that referenced this pull request Jun 23, 2021
1547: Don't merge stateless trackers from bind groups r=cwfitzgerald a=kvark

**Connections**
Hinted by @pythonesque on the matrix
Follow-up to #1417

**Description**
This is an optimization only.

When a bind group is used, we need to ensure two things:
  1. stateful usages are merged in (buffers and textures)
  2. other resources are help alive by the command buffer

We used to merge all of the states into the local trackers. However, the local tracker already
keeps a strong reference to the whole bind group, so the resources in it are not going away.
Therefore, we can skip having them separately in the local trackers.

**Testing**
Untested.


Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
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