
ALT Sam: Here's a list of all methods which return some type of array. Some of these are hot path methods. Juan: Returning or passing arrays is fine. Normally these are not hot paths. Sam: The problem with Godot arrays in C# is that they're still classes, so every return creates garbage, and garbage collection can cause dropped frames. From Unity, my standard rule is zero garbage in a frame. Juan: No hot path relies on returning arrays currently. I understand the obsession with the GC in C# but a couple hundred pointers freed per frame is fine. The priority is to only have the critical paths covered with a non-allocation policy.

ALT Sam: If we have a good pattern for doing zero allocations, that should probably be done everywhere whether or not it's significant. I'm a little uncomfortable with the engine making judgements about which methods are hot path and which aren't - users will find unanticipated hot path use-cases for things. Juan: To me this is solutions in search of a problem. The advantage of the current API is that it’s exposed in a very simple and predictable way. It's very difficult to write software based on speculation on what will be best and what will be fast, or even based on benchmarks that don't have any real-world usage scenario behind them. It's easier to write software to react to real-world bottlenecks. As an example, the current ray_cast function you found was indeed slow, but thousands of Godot games have been published to Steam with Godot and nobody ever complained. This means no one used it as much as you intended it to. Now that you stumbled into this problem, there is more motivatio

ALT Sam: How will these things get fixed once a real-world performance problem is found? Is the API going to get a breaking change? If not, the fix we end up with will be a little messy. Juan: Probably going to be a two-fold fix. The current function remains in compatibility API but deprecated. Sam: This would be a strong argument in favor of caring about the performance of every method up front, whether or not it's anticipated to be important - nobody wants to be in the ugly position of having to try to fix it after the fact. Juan: Absolutely not. I will insist your view is extremely misled because you are not familiar with the source code. Godot is a gigantic codebase and optimizing everything that exists for the sake of it is not only a large waste of effort and time, but it results in far more complex and difficult to maintain code. As such, only the performance critical areas get performance critical optimizations.

ALT Sam: Could you define what you mean by hot path? In games I think most of us (certainly I) take it to mean anything that might be called even once in a typical frame. Juan: In this context, hot path is something you call hundreds to thousands of times in a frame. Even having a few hundreds of memory allocation is not going to put any sweat into the GC. Sam: I think you will find that these performance philosophies are considered unacceptable by many Unity devs. I don't know whether you care about catering to them - perhaps they're just not your target audience, and that's absolutely fine. Juan: The general idea behind Godot development is fixing real problems people have, not catering to people with a specific philosophy or that speculates about potential problems they don't actually have. If simply they come to us with the speculation that something is a problem, then nothing is done from our side. Development is very pragmatic in this sense.






