-
-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow encoding/decoding by comparison with libsnmp #44
Comments
Thank you for raising this concern! Good thing is that it's being addressed by the ongoing overhaul of pyasn1 -- the library that powers ASN.1 de/serialization used by pysnmp. With which pyasn1 version you are running the benchmarks? Could you run your comparison with pysnmp on top of the latest pyasn1 taken from master? Is there any difference? |
Interesting, sounds like this is being worked on already, good news. The tests I did were with pyasn1 0.2.3 - pip freeze output
I'll try and re-test with master pyasn1 and report back |
Slightly better using pyasn1 dc3f323 on cpython 2.7
...versus the released 0.2.3
Will test with pypy |
Difference is more pronounced under pypy, but both pypy and cython still seem to have a lot of room pyasn1 master on pypy
versus pyasn1 released on pypy
|
We have a set of bespoke applications for polling thousands of devices in parallel, using Twisted and the old/unmaintained libsnmp.
We recently looked at porting this to Python 3 and moving to pysnmp, but performance was not acceptable for our needs. Pretty much all the time seems to be spent in encoding/decoding when I inspect using profile.
https://gist.github.com/philmayers/67b9300d8fb7282481a1a6af5ed45818
I'll attachThe above gist is an example script which just decodes the same fake SNMPv2c PDU in a tight loop, measuring with timeit. Example results I get on my desktop under CPython:I see similar differences under pypy although both times are obviously much better:
Under pypy with larger iterations, libsnmp improves dramatically (~3x faster) whereas pysnmp far less so (1.5x faster):
I suspect the performance difference here is coming from libsnmp having a much more primitive asn1 implementation and from it being far more monolithic - fewer function calls, less flexibility - and as such it's doing a lot less work, and is also easier for pypy to performance-hotspot.
For the time being, we'll probably fork libsnmp and try moving that to Python 3, or remain on 2.7 with libsnmp, but I thought this info might be of interest.
Many thanks for your hard work on pysnmp!
The text was updated successfully, but these errors were encountered: