Profiler and Visual profiler both show unaccounted for time.

Thank you very much for your help!

I’ve followed your advice, and here are my findings:

  • Removing the nodes and using code, just by itself, gave a performance boost.
  • Using Node2D.position as a variable was slower than using my own pos. As I wasn’t using it other than for scripts, it works out fine. It would break physics if I had any.
  • RenderingServer.canvas_item_add_rect() is very slow and cannot be used for thousands of items. Using canvas_item_add_texture_rect() with solid colored textures is better.
  • I wanted my entities to move, so set_process(false) didn’t work for me. I ended up using staggered updates (entities update in batches of around 1000 per frame). That limits the performance impact of the process function.

The results are staggering! From 2000 units at 20fps to 2000 at 350fps and 10000 at 60fps.

There is still a huge gap in the profiler that I don’t know how to deal with, but I’ll treat that as normal and move on.

Again, thank you @normalized for your time and help!

1 Like