godot-extended-libraries / godot-debug-menu

Display in-game FPS/performance/hardware metrics in a Godot 4.x project
https://github.com/godot-extended-libraries/godot-debug-menu-demo
MIT License
454 stars 18 forks source link

fix: takes too much time to load singleton #1

Closed Ark2000 closed 1 year ago

Ark2000 commented 1 year ago
    # Enable required time measurements to display CPU/GPU frame time information.
    RenderingServer.viewport_set_measure_render_time(get_viewport().get_viewport_rid(), true)
    update_information_label()
    update_settings_label()

the above code is very time consuming which will block the main thread and increase startup time by about three to four seconds, so I put them in a separate thread to avoid the block.

Calinou commented 1 year ago

I'll test this locally when I get home.

In my experience, the biggest culprit by far is getting the graphics driver version, which is very slow for some reason. I suggest using a C++ profiler on a debug build of the engine to determine why.

@myaaaaaaaaa Do you know a better way to do this?

myaaaaaaaaa commented 1 year ago

I generally diagnose performance problems like these using very advanced techniques such as putting printf(timestamp)s everywhere, commenting out lines of code until something changes, or Ctrl+C-ing in gdb once it reaches time-consuming code so that backtraces show likely culprits :upside_down_face:

Calinou commented 1 year ago

Merged manually with https://github.com/godot-extended-libraries/godot-debug-menu/commit/c7f463bd80c8dabf8eba081a412deddbae1e4ac4, which also displays loading text and prevents a warning from being printed by calling wait_to_finish() on the thread instance.

Thanks!