Skip to content

Conversation

@valadaptive
Copy link
Contributor

  • I have followed the instructions in the PR template

While optimizing #7431, I noticed that Mesh::add_rect_with_uv was taking quite a bit of time. Using extend_with_slice results in much better codegen (fewer branches) and inlining the function makes things faster still. The same applies to Mesh::add_triangle.

Current main:

text_layout_uncached    time:   [65.988 µs 66.042 µs 66.108 µs]
                        change: [+0.1351% +0.3381% +0.5863%] (p = 0.00 < 0.05)

With these optimizations:

text_layout_uncached    time:   [59.996 µs 60.104 µs 60.269 µs]
                        change: [−9.8641% −9.6530% −9.4583%] (p = 0.00 < 0.05)
                        Performance has improved.

@github-actions
Copy link

github-actions bot commented Sep 7, 2025

Preview available at https://egui-pr-preview.github.io/pr/7511-optimize-add-rect
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@lucasmerlin lucasmerlin added performance Lower CPU/GPU usage (optimize) epaint labels Sep 8, 2025
Copy link
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

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

Nice, great find!

@emilk emilk merged commit 742b1dc into emilk:main Sep 8, 2025
27 of 28 checks passed
lucasmerlin pushed a commit that referenced this pull request Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

epaint performance Lower CPU/GPU usage (optimize)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants