mmp / vice

Virtual air traffic control simulator
https://pharr.org/vice
GNU General Public License v3.0
18 stars 25 forks source link

review profile, reduce cpu usage #255

Closed mmp closed 2 weeks ago

mmp commented 2 weeks ago

If you launch e.g. the Socal Combined scenario and let it run for a while (so, tons of aircraft), CPU usage is around 100% on my system here. Looking at a profile, there are a bunch of culprits in the STARS code that shouldn't be so dominant:

Part of the datablock-related cost is that both drawLeaderLines() and drawDatablocks() ends up calling formatDatablocks(). Perhaps datablocks should just be cached in STARSAircraftState and only updated when we get a new track.

mmp commented 2 weeks ago

Starting point from http://localhost:6502/debug/pprof/profile?seconds=30; duration 30s, 25s of samples

mmp commented 2 weeks ago

This so far brings us down to 5.73s in and under STARSPane Draw, or a 3.07x speedup overall. Probably good enough for now, though when the datablock formatting code gets its next rewrite, we should probably just cache the datablock text.