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

UI Materials: don't reserve items on phase from inside the loop #10437

Closed

Conversation

mockersf
Copy link
Member

@mockersf mockersf commented Nov 7, 2023

Objective

  • UI Materials reserve an additional nodes length for each node, leading to (number of nodes) ^2 reserved size of array

Solution

  • Reorder the loops and reserve length outside of the loop on nodes

@mockersf mockersf added the A-UI Graphical user interfaces, styles, layouts, and widgets label Nov 7, 2023
@mockersf mockersf added this to the 0.12.1 milestone Nov 7, 2023
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times labels Nov 7, 2023
.items
.reserve(extracted_uinodes.uinodes.len());
for (entity, extracted_uinode) in extracted_uinodes.uinodes.iter() {
let material = render_materials.get(&extracted_uinode.material).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

This means the material will have to be looked up once per view per entity instead of once per entity

@@ -742,9 +745,6 @@ pub fn queue_ui_material_nodes<M: UiMaterial>(
bind_group_data: material.key.clone(),
},
);
transparent_phase
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not if items.len() < uinodes.len() { reserve diff }?

@alice-i-cecile alice-i-cecile removed this from the 0.12.1 milestone Nov 22, 2023
@alice-i-cecile
Copy link
Member

Removing from 0.12.1: not straightforward, and not essential.

@mockersf
Copy link
Member Author

updated in #15919

@mockersf mockersf closed this Oct 15, 2024
github-merge-queue bot pushed a commit that referenced this pull request Oct 16, 2024
# Objective

- UI materials reserve too much capacity in a vec: for every node in the
transparent phase, it reserves enough memory to store all the nodes
- Update #10437 

## Solution

- Only reserve extra memory if there's not enough
- Only reserve the needed memory, not more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants