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

TextServerFallback: 2x performance improvement by removing redundant lookups #92581

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

rune-scape
Copy link
Contributor

followup to #92575

  • removes redundant FontForSizeFallback cache lookups
  • also caches editor setting
  • usies a faster hash method on the FontForSizeFallback cache (its the same function its just not converting the key to a variant before hashing)
  • ShapedTextDataFallback::valid changed to an atomic bool to avoid locking a mutex, as its read Very often

in total from my benchmark it takes ~38% of the time to render the same text in a Label (~44% in CodeEdit, the main script editor in godot)

benchmark: TextServerTest.zip
benchmark compile flags: scons target=template_release production=yes optimize=speed lto=full tests=yes deprecated=no scu_build=yes module_text_server_adv_enabled=no module_text_server_fb_enabled=yes
benchmark run command: ./godot/bin/godot.linuxbsd.template_release.x86_64 --disable-vsync ./TextServerTest/project.godot

results before:

Godot Engine v4.3.beta.custom_build.6b38be699 (2024-05-30 20:38:39 UTC) - https://godotengine.org
Vulkan 1.3.277 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce GTX 1080 Ti

18.2138115468651ms avg draw time (99 samples)
18.2687489673345ms avg draw time (198 samples)
18.1693966541226ms avg draw time (297 samples)
18.088425048674ms avg draw time (396 samples)
18.0387193506414ms avg draw time (495 samples)
18.0871025079027ms avg draw time (594 samples)
18.1229936784136ms avg draw time (693 samples)
18.1424099989612ms avg draw time (792 samples)
18.1100280196578ms avg draw time (891 samples)
18.088856369558ms avg draw time (990 samples)
18.1047671206836ms avg draw time (1089 samples)

after:

Godot Engine v4.3.beta.custom_build.7a4461225 (2024-05-31 05:57:28 UTC) - https://godotengine.org
Vulkan 1.3.277 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce GTX 1080 Ti

6.8193662046182ms avg draw time (99 samples)
6.81492054101193ms avg draw time (198 samples)
6.8215898391775ms avg draw time (297 samples)
6.8254777879426ms avg draw time (396 samples)
6.82788376856332ms avg draw time (495 samples)
6.80477530867965ms avg draw time (594 samples)
6.78739540848725ms avg draw time (693 samples)
6.77584548189182ms avg draw time (792 samples)
6.76721113699454ms avg draw time (891 samples)
6.75983934691458ms avg draw time (990 samples)
6.75281939756115ms avg draw time (1089 samples)

the last line of each is the most important, its the average of all frame times (minus some longer startup frames)

@rune-scape rune-scape requested a review from a team as a code owner May 31, 2024 06:51
@rune-scape rune-scape force-pushed the rune-text-srvr-fb-cacher branch from 7a44612 to 1c36815 Compare May 31, 2024 06:57
@Calinou Calinou added this to the 4.x milestone May 31, 2024
@rune-scape rune-scape force-pushed the rune-text-srvr-fb-cacher branch from 1c36815 to f9eee79 Compare May 31, 2024 08:18
@rune-scape rune-scape force-pushed the rune-text-srvr-fb-cacher branch from f9eee79 to 4ceb82f Compare May 31, 2024 11:08
@rune-scape rune-scape force-pushed the rune-text-srvr-fb-cacher branch 4 times, most recently from ad6ca18 to 58a0061 Compare May 31, 2024 11:21
@rune-scape rune-scape force-pushed the rune-text-srvr-fb-cacher branch from 58a0061 to 7d99133 Compare August 28, 2024 20:01
+ caching editor setting
+ using a faster hash method on the FontForSizeFallback cache
+ SafeFlag instead of mutex for ShapedTextDataFallback::valid bc its read Very often
@rune-scape rune-scape force-pushed the rune-text-srvr-fb-cacher branch from 7d99133 to 2fc5321 Compare August 28, 2024 20:10
@akien-mga akien-mga merged commit 80cd8f4 into godotengine:master Aug 29, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@rune-scape rune-scape deleted the rune-text-srvr-fb-cacher branch August 30, 2024 02:25
@akien-mga akien-mga modified the milestones: 4.x, 4.4 Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants