Page 1 of 1

Performance and quantity of classes

Posted: Wed Jul 22, 2020 8:42 pm
by AlexYeCu
Strange situation.
Writing a game using love2d and 3dreamengine.
90+ fps.
Adding a simple class (no drawing, no update inside, inheritanced from other simple class) — 25 fps…
Removing any string like cClass = require class gives higher fps again.
Looks like there is some limit.
The only suspicious thing — plus pare percents of CPU usage (96 to 98 —100, last drop?).
Memory is ok, video-memory is ok too.
The question. Does anyone know something about the situation?
Is there any known ways for optimizing this?

Re: Performance and quantity of classes

Posted: Thu Jul 23, 2020 7:02 am
by AlexYeCu
One class and 4 classes inherited from it: 25 fps. One big class, sum of all 5 — 60 with vsync.

Re: Performance and quantity of classes

Posted: Thu Jul 23, 2020 10:19 am
by MrFariator
Can you share example code or .love that demonstrates the framedrops?
Going off of this information alone doesn't give much to work with, I'm afraid.

Re: Performance and quantity of classes

Posted: Thu Jul 23, 2020 10:53 am
by AlexYeCu
>Can you share example code

Well, 1.5 Mb of my code, 3 Mb of third party libs, 125 Mb total.
Can build a light weight demo with the same code structure, but not sure if it'll get the same performance issue. I should think how to do it in better way…

Re: Performance and quantity of classes

Posted: Sat Aug 22, 2020 11:44 pm
by Sasha264
By the given info I suggest that problem is inside "inheritance" mechanism. Lua does not have embedded one, and there is some different technics to implement that. Can you share code about how you implement inheritance? Maybe it contains some copying, maybe it happens every frame by some mistake. Lua does not care about "classes" only about "tables", so if you add one table that designed to be new class — that is only human interpretation, lua does not know about it.

99% CPU usage is also strange. Modern CPU rarely contains 2 or 1 cores (Is that a case?) But with 4 or more cores it is really hard to effectively keep them busy with love. And that by itself can point to some mistake.