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

[Merged by Bors] - bevy_pbr: Optimize assign_lights_to_clusters #3984

Closed

Conversation

superdump
Copy link
Contributor

Objective

  • Optimize assign_lights_to_clusters

Solution

  • Avoid inserting entities into hash sets in inner loops when it is known they will be inserted in at least one iteration of the loop.
  • Use a Vec instead of a hash set where the set is not needed
  • Avoid explicit calculation of the cluster_index from x,y,z coordinates, instead using row and column offsets and just adding z in the inner loop
  • These changes cut the time spent in the system roughly in half

@superdump superdump self-assigned this Feb 18, 2022
@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Feb 18, 2022
@superdump superdump added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Feb 18, 2022
@alice-i-cecile alice-i-cecile added the C-Performance A change motivated by improving speed, memory usage or compile times label Feb 18, 2022
@alice-i-cecile
Copy link
Member

LGTM!

robtfm added a commit to robtfm/bevy that referenced this pull request Feb 19, 2022
@mockersf mockersf added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 19, 2022
@cart
Copy link
Member

cart commented Feb 28, 2022

bors r+

bors bot pushed a commit that referenced this pull request Feb 28, 2022
# Objective

- Optimize assign_lights_to_clusters

## Solution

- Avoid inserting entities into hash sets in inner loops when it is known they will be inserted in at least one iteration of the loop.
- Use a Vec instead of a hash set where the set is not needed
- Avoid explicit calculation of the cluster_index from x,y,z coordinates, instead using row and column offsets and just adding z in the inner loop 
- These changes cut the time spent in the system roughly in half
@bors bors bot changed the title bevy_pbr: Optimize assign_lights_to_clusters [Merged by Bors] - bevy_pbr: Optimize assign_lights_to_clusters Feb 28, 2022
@bors bors bot closed this Feb 28, 2022
rparrett pushed a commit to rparrett/bevy that referenced this pull request Mar 4, 2022
# Objective

- Optimize assign_lights_to_clusters

## Solution

- Avoid inserting entities into hash sets in inner loops when it is known they will be inserted in at least one iteration of the loop.
- Use a Vec instead of a hash set where the set is not needed
- Avoid explicit calculation of the cluster_index from x,y,z coordinates, instead using row and column offsets and just adding z in the inner loop 
- These changes cut the time spent in the system roughly in half
kurtkuehnert pushed a commit to kurtkuehnert/bevy that referenced this pull request Mar 6, 2022
# Objective

- Optimize assign_lights_to_clusters

## Solution

- Avoid inserting entities into hash sets in inner loops when it is known they will be inserted in at least one iteration of the loop.
- Use a Vec instead of a hash set where the set is not needed
- Avoid explicit calculation of the cluster_index from x,y,z coordinates, instead using row and column offsets and just adding z in the inner loop 
- These changes cut the time spent in the system roughly in half
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants