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

Performance regression since 4.2-beta1 when calling TranslationServer.set_locale() every frame #85718

Closed
Loneliiii opened this issue Dec 3, 2023 · 20 comments · Fixed by #85828

Comments

@Loneliiii
Copy link

Loneliiii commented Dec 3, 2023

Godot version

4.2

System information

Windows 11

Issue description

I started a project in Godot 4 and updated Godot and ended up with Godot 4.2dev_6 because this was compatible with the modi_player addon and Glow at the same time. Other Versions either had framrate issues (like the main problem i have now) or the addon not working.

After Godot 4.2 stable came out, I tried to work in my game with this Version and get massive framerate issues (5fps) in the forward+ and mobile renderer, even in an empty scene. I tried turning off hdr / glow and changed other project settings, but nothing works.
When I change to the Compatibility render I get the maximum amount of frames possible.

I have a Asus Rog Flow X13, Ryzen 7, GTX 1650 with Max-Q Design and a AMD Radeon Graphics

Steps to reproduce

its only in this project, no else, but here are the stept I did with the Game.

  • Started dev. in Godot 4.0
  • Updated to Godot 4.1
  • Installed Godot4.2_dev 3 for hdr glow (in 2D)
  • changed to Godot 4.2dev6 because of the midi player addon
  • now used a backup copy of my game to test Godot 4.2 stable

Minimal reproduction project

I won't upload my game here, because I'm pretty far in developement.

@clayjohn
Copy link
Member

clayjohn commented Dec 3, 2023

Can you work on creating a minimal reproduction project? Without one we can't really do anything to help.

The issue is likely some combination of your system, your add on, and your project. Without having access to those things, contributors can't even help you debug.

If you can't create an MRP, then you should at least try to identify what is causing the slowdown using a profiler. You should be able to identify if the issue comes from Godot, from your scripts, or from the add on you are using.

@Loneliiii
Copy link
Author

I just tried it without the addon. Nothing changes.
I'm gonna strip down the game to the minimum. to see, where and upload it here. Will take a bit

@Loneliiii
Copy link
Author

Loneliiii commented Dec 3, 2023

I can't upload it here, because its too big 199MB, I stripped the game down, deleted all objects, most of the sprites/fonts and nothing changes.
In the version I just uploaded I created a scene with a framecounter and a path with a sprite following it.

I also tried to open it on my Asus ROG Ally in Godot 4.2 but I get the same issue

I hope its okay, when I send the Google Drive link. https://drive.google.com/file/d/187y1EATuBMvr7RcKAHX1k9FEcgF-uZLp/view?usp=sharing

@clayjohn
Copy link
Member

clayjohn commented Dec 3, 2023

I ran the "test_room" scene in your project. It runs at 60 FPS on my device (11th Gen Intel® Core™ i7-1165G7 @ 2.80GHz × 8 usingintel integrated graphics). Turning of Vsync and it runs at around 900 FPS. I am using 4.2 stable. Switching to the compatibility renderer I get about 1330 FPS.

Have you been able to reproduce the issue on any other hardware? This issue might be specific to your hardware / drivers.

When you run your project, does it say that it is running with your NVidia GPU? Or does it say it is using the CPU instead? I'm wondering if there is a switchable graphics issue going on here.

Also, have you checked to make sure you are using up-to-date GPU drivers?

@Loneliiii
Copy link
Author

Loneliiii commented Dec 4, 2023

I ran the "test_room" scene in your project. It runs at 60 FPS on my device (11th Gen Intel® Core™ i7-1165G7 @ 2.80GHz × 8 usingintel integrated graphics). Turning of Vsync and it runs at around 900 FPS. I am using 4.2 stable. Switching to the compatibility renderer I get about 1330 FPS.

Have you been able to reproduce the issue on any other hardware? This issue might be specific to your hardware / drivers.

When you run your project, does it say that it is running with your NVidia GPU? Or does it say it is using the CPU instead? I'm wondering if there is a switchable graphics issue going on here.

Also, have you checked to make sure you are using up-to-date GPU drivers?

I tried it on two separate devices. My Asus ROG Flow X13 and the Asus ROG Ally.
I noticed, when I use the version that is working (in 4.2dev_6), the GPU is around 35%. The not working version (4.2 stable) at around 15%.
I'm pretty sure, that the drivers are up to date. I just updated them a few days ago.

I'm currently out of ideas why this happens :/

Thank you for looking into it :)

Things I tried:

  • using the standalone Godot 4.2 version (not steam) still the same (CPU at ~ 15%, GPU ~ 15%)
  • using Godot 4.2_dev5 and it works without problems (CPU at 8%, GPU ~ 35%)

To your question, it is saying the GPU in the output when starting the game.

It wasn't possible to reproduce it with new projects, but when I copy the game files to another windows 12 PC, I get the same issue

@saierXP
Copy link

saierXP commented Dec 5, 2023

TranslationServer.set_locale has no performance issues in 4.2.dev6, but has performance issues in 4.2.beta1.

Godot_v4 2-beta3_win64_stYEyCvqor

System Details

Godot v4.2.dev6 - Windows 10.0.19045 - Vulkan (Forward+) - integrated AMD Radeon(TM) Vega 8 Graphics (Advanced Micro Devices, Inc.; 31.0.14057.5006) - AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx (8 Threads)

@akien-mga
Copy link
Member

What locale(s) are you using for your OS, and for Godot?

@Loneliiii
Copy link
Author

You are a haero saierXP. I removed in a test version all of the translation stuff and it works without issues even in forward+.
I remove it from the autoload physics_process and only let the translation change once when starting the game and changing the language. No problem this way so far.

My OS is currently just German and my Godot is also in German currently. The translation of the game is changed in the options menu between german and english currently.

First of, thank you guys for helping me with this! :D
And maybe hopefully the "problem" can be fixed, so others don't have these performance issues. (And/Or I was just stupid by always loading the set_locale in the physics process)

@akien-mga akien-mga changed the title Framerate Issues with Forward+ renderer in Godot 4.2 Stable Performance regression since 4.2-beta1 when calling TranslationServer.set_locale() every frame Dec 5, 2023
@akien-mga
Copy link
Member

I can't reproduce the performance issue on Linux, so this might be specific to Windows. CC @bruvzg

I don't spot right away in the 4.2-beta1 changelog what could cause that performance regression.
https://godotengine.github.io/godot-interactive-changelog/#4.2-beta1

Maybe #80409 if changing the locale forces recalculating the title bar size. If so this might already be mitigated by #85542.

@bruvzg
Copy link
Member

bruvzg commented Dec 5, 2023

Setting locale trigger reload of all remapped resources (which was broken before 4.2) and complete reprocessing of all text, this is definitely not a fast thing and should not be done every frame.

@akien-mga
Copy link
Member

Yeah I first thought about my fix to translation remapping #84791, but it was merged in 4.2-beta6, so the timeline doesn't check out with this perceived regression.

I fully agree that resetting locale every frame should not be done, but it would be good to identify why it became much more expensive than it used to be.

@bruvzg
Copy link
Member

bruvzg commented Dec 5, 2023

I can't reproduce the issue on macOS, but I guess we can add the check if locale is changed and only call updates if necessary.

@bruvzg
Copy link
Member

bruvzg commented Dec 5, 2023

Screenshot 2023-12-05 at 16 20 33

It is triggering title update, so might be related to #80409

I will check it on Windows tomorrow.

@saierXP
Copy link

saierXP commented Dec 5, 2023

It's very strange, I can't reproduce the previous test results and my computer hasn't been restarted.
Loneliiii can you still reproduce it? Operate set_local on every frame.

@Loneliiii
Copy link
Author

It's very strange, I can't reproduce the previous test results and my computer hasn't been restarted.
Loneliiii can you still reproduce it? Operate set_local on every frame.

I will try it later, when I'm back home.
Empty project in 4.2, renderer forward+ and then autoload a script and calling the set_local in the physics_procesd.
That should be all I guess

As a question. You guys say, it is triggering the title update. Do you mean with title the game window title?

@Loneliiii
Copy link
Author

I tried to replicate it on my ROG Ally (Win 11). i can replicate it, by just the steps mentioned before.
here is the project, where I reproduced it
locale_reproduced.zip

@saierXP
Copy link

saierXP commented Dec 6, 2023

Godot_v4 2-stable_win64_ft3RkQgCXi
After several attempts today, I was able to reproduce the bug in forward+ and found that the System's hard disk write is 0.3Mb-0.5Mb, GPU usage is 50%, as well as cpu usage is high, GPU engine shows it is GPU-copy. after commenting out set_locale, System's usage dropped.
It may be related to vulkan, after switching renderer several times, compatibility mode is normal. Mobile has higher framerate than forward+.
I will do git bisect later.

@saierXP
Copy link

saierXP commented Dec 6, 2023

It is triggering title update, so might be related to #80409

72e2e47 is the first bad commit

@akien-mga
Copy link
Member

As I mentioned yesterday, this might have been mitigated by #85542 already. Could you test latest master?

@saierXP
Copy link

saierXP commented Dec 6, 2023

It didn't fix it. The runtime doesn't go to the window_id ! = DisplayServer::INVALID_WINDOW_ID if branch.

Edit: Execute set_locale in _process, frame rate is 54 fps, and small fluctuation change. 35 fps in _physics_process with large fluctuations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants