loblao / libotp-nametags

Reverse-engineered libotp nametags
MIT License
23 stars 5 forks source link

Performance: Rewrite libotp in C++ #14

Closed mfwass closed 4 years ago

mfwass commented 4 years ago

Per a cProfile taken on a TLOPO client, I have discovered that libotp is significantly impacting frame-rates. Disabling the cull callback code results in an immediate 20-30FPS improvement.

         70379804 function calls (70361083 primitive calls) in 217.404 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
   614319    2.773    0.000   37.996    0.000 /libotp/Nametag3d.py:41(cullCallback)
   614012   19.277    0.000   31.569    0.000 /libotp/Nametag3d.py:195(adjustToCamera)
    10984    0.021    0.000   16.343    0.001 /libotp/MarginManager.py:92(cullCallback)
    10984    2.672    0.000   16.322    0.001 /libotp/MarginManager.py:190(update)

libotp contains multiple mathematically intensive tasks which run every frame, and Python is not great at these kind of operations - especially when they need to run every frame. Disney had originally written this system in C++, I suspect this was the reasoning behind that decision.

@loblao and I have been working on this for the past week. We will be committing our progress soon.

mfwass commented 4 years ago

Open sourced in 661211f. This is not a perfect version, but is a start.

LittleToonCat commented 4 years ago

I've been anticipating this when I first saw the issue appeared. Now that it's out, I'll be giving it a go soon, thanks!

LittleToonCat commented 4 years ago

Toontown wise, despite most of the stuff being incomplete (i.e. MarginManager), it's a very good and promising start. toontown-screenshot-Thu-Feb-27-00-42-14-2020-5321

mfwass commented 4 years ago

@LittleToonCat Can you take a look at the rest of libotp and begin converting it?

We have a lot going on at TLOPO and don't intend to continue working on this in the foreseeable future.

LittleToonCat commented 4 years ago

No promises, but I'll try my best.