Skip to content

Use SmallVec instead of HashMap in MaterialProperties #19846

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
merged 4 commits into from
Jun 28, 2025

Conversation

IceSentry
Copy link
Contributor

@IceSentry IceSentry commented Jun 28, 2025

Objective

  • MaterialProperties uses HashMap for some data that is generally going to be really small. This is likely using more memory than necessary

Solution

  • Use a SmallVec instead
  • I used the size a StandardMaterial would need for all the backing arrays

Testing

  • Tested the 3d_scene to confirm it still works

Notes

I'm not sure if it made a measurable difference since I'm not sure how to measure this. It's a bit hard to create an artificial workflow where this would be the main bottleneck. This is very in the realm of microoptimization.

@IceSentry IceSentry changed the title Use SmallVec for shaders in MaterialProperties Use SmallVec instead of HashMap in MaterialProperties Jun 28, 2025
@IceSentry IceSentry added the A-Rendering Drawing game state to the screen label Jun 28, 2025
@IceSentry IceSentry added S-Needs-Benchmarking This set of changes needs performance benchmarking to double-check that they help S-Needs-Review Needs reviewer attention (from anyone!) to move forward C-Performance A change motivated by improving speed, memory usage or compile times labels Jun 28, 2025
Copy link
Member

@tychedelia tychedelia left a comment

Choose a reason for hiding this comment

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

Looks good!

@superdump superdump added this pull request to the merge queue Jun 28, 2025
Merged via the queue into bevyengine:main with commit 37bbbf7 Jun 28, 2025
32 checks passed
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-Needs-Benchmarking This set of changes needs performance benchmarking to double-check that they help S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants