godot: Profiler missing most of my functions.

Godot version: 3.2.2

OS/device including version: Windows 10 Version 1903 Build 18362.900

Issue description: The profiler fails to detect a large portion of my functions and shows a suspiciously low Script Function time. Using Measure: Frame Time (sec) and Time: Inclusive.

Here’s a screenshot of the profiler on one of the spikes I’m investigating: borked_profile2

It states that the frame takes 34ms in Idle time, but the Script Function total is only 0.19ms!

Further more, the time for Script Function seemingly drops when the load spike occurs. (Pink: Idle, Yellow: Script) borked_profile3

The spike occurs at the start of a turn in my game. It’s spread out since each enemy character’s turn takes at least one frame, ends its turn and then moves on to next until its the players turn. All of this is triggered by signals and some use of yield(get_tree(), "idle_frame")

I’ve checked and doubled checked, by using OS.get_ticks_usec() and Engine.get_idle_frames(), that one of the missing functions actually runs during these frames and is a time hog, but it won’t show up in the profiler (and I double checked the neighboring frames too)!

In fact most of the functions that I’d expect to show in the profiler for that frame are missing.

I managed to optimize the function, so I’m convinced its my own code and not any server or file loading that occurs during these frames.

I’ve tried twiddling the Max Functions setting, but no change. Made a grep for func definitions and only got ~750, so it seems hardly an issue with the default setting of 16k, but I’ve tried 32k and 64k to make sure.

The drop in Script Function time as the load increases suggests to me that there’s some silent overflow besides the Max Function setting.

Steps to reproduce: Unfortunately I’ve failed to pinpoint what causes it. Hope this report is informative enough anyway! I’ll make another attempt at reproducing it at a small scale.

Minimal reproduction project:

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 9
  • Comments: 22 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@Zoomulator I had a similar issue - then I noticed that there is an option in editor “Profiler Frame Max Functions” that’s defaulting to 64 - and I had 2000-5000 calls per frame. See if raising that helps your case.

image

I just noticed Profiler Frame Max Functions is silently clamped between 16 and 512

Oh, that’s great… I probably just copy pasted it in 4.0. I think we can safely remove the clamp in 4.0 (or raise the maximum to something more reasonable like 32768), not sure in 3.2 since the network layer there is pretty messy, and if the data is too big it might hang or even crash the editor (like for prints, etc).

@Calinou Yes it’s the same problem but in a different area it seems. I don’t know if it’s already part of the plan for profiling improvements, but both cases show we need to start adding more details into profiling information (and I’m sure there’s more).

We could have some extra sub-categories to get more details about the main loop, physics and possibly rendering (if some areas can be clearly identified).

Maybe that could be just for debug, or disabled in release by default and based on some project settings.

If I understand correctly that the script functions should more or less equal idle time then I’m suffering from the same problem. I have a high idle time (making me noticeably drop to 30 fps), but my script functions time is very low.

This isn’t the case as servers (physics, rendering, …) don’t count as script functions: https://github.com/godotengine/godot/issues/23715

Are there any negative side effects to increasing this value? Maybe we should increase its default value.

Do you have a minimal reproduction project you could provide us? It would help pinpoint the part of your scripts that cause the spikes and then figure out if that could be added to the profiling data.