ampledata / aprs

Python APRS Module
https://github.com/ampledata/aprs
Other
95 stars 53 forks source link

Fixes and optimisations #29

Open hessu opened 3 years ago

hessu commented 3 years ago

I'm trying to use the parser at the 2500 packets/second OGN feed, and it doesn't work out, it's too slow. I did a few obvious fixes and optimisations, but I will likely stop here at this point and do something completely different instead, as modifying this module to do it would be quite a lot of work.

An overall issue is that the setter methods of Frame take any sort of input, and the APRS-IS parser gives it (binary) strings, and the setters try to handle them as everything else except strings. It would be faster and more correct to directly process them as strings when we certainly know we have APRS-IS strings in the variable, instead of checking if they would have turned into objects or something else instead. Similar patterns seem to appear elsewhere.

For example, APRS-IS callsign strings here are first tested if they're already decoded objects (no we gave it a string), and then the binary AX.25 callsign parser is tried (fails always, slow, raises exception on every call: source, destination, path elements), and then it goes for the correct parser. As a result, the code spends up parsing callsigns for most of the time, if looking at it in the profiler. https://github.com/ampledata/aprs/blob/master/aprs/functions.py#L101

And I fixed the module to not overwrite logging setup; it insisted on writing things to the console.