loopier / animatron

Animatron for Godot 4.x <
15 stars 1 forks source link

Executing lots of commands freezes the app #51

Open loopier opened 1 month ago

loopier commented 1 month ago

Calling lots of commands freezes the app until all of them are processed.

I've tried with /create within a /for and from a remote SC client. I have also tried with /post and /log/level. For less demanding commands, like /post it doesn't freeze until a massive amount of commands is demanded (I tried 2000). But, still, this is not desirable.

Try:

/for i 20 /create x$i whatever

or

n = NetAddr("localhost", 56101);
20.do{|i| n.sendMsg("/create", "x"+i, "whatever")};

If thread is a solution, see loading images.

totalgee commented 1 month ago

I was playing a bit with the Profiler in Godot, and hopefully we can start to optimize certain things that are slower than they should be... Things like _resolveVariables() is called a huge amount in for loops, and even Status class is really heavily used (again, mainly noticeable when doing a big for loop).

This is besides the logging issue we identified this morning, where we should only show the last N lines of the log.

totalgee commented 1 month ago

Minor improvements with changes in 99385bf.

loopier commented 1 month ago

_resolveVariables() is called a huge amount in for loops,

I don't see how this can be avoided. Maybe storing resolving variables that are in a greater scope before entering the loop. But the loop index will have to be resolved every time, won't it?

and even Status class is really heavily used (again, mainly noticeable when doing a big for loop).

Maybe it wasn't a good idea implementing it. We can live without it. Not as elegant, I guess, but if it's so heavy on resources, let's get rid of it. Or maybe only use it when it makes sense. Although I believe it simplifies a lot of logic statements.

totalgee commented 1 month ago

Don't go removing anything now. These are just initial comments, I was more meaning it would be great to find any way to optimize those. But definitely don't remove Status right now!

loopier commented 1 month ago

After discussing this issue, we decided to not fix it for now, and use it as a creative constrain, adding an interval between command evaluations. This can be done either from the client or in GDScript. It should result in a transition instead of a sudden change, which might even work better.

loopier commented 2 weeks ago

0.04.wait on a Tdef seems to be the threshold. Maybe we should implement this in GDScript as the default when getting lots of commands.

totalgee commented 1 week ago

See changes from d31e63d (and commented in #52)