SNMP Toolkit

Les Smithson lsmithso at NOhare.SPAM.demon.co.uk
Sat Jun 26 10:25:17 EDT 2004


>>>>> "Ilya" == Ilya Etingof <ilya at cray.glas.net> writes:

    Ilya> I've got an impression, that building/parsing BER is not
    Ilya> computationally intensive. In fact, BER encoding has been
    Ilya> designed to cope with rather limited resources (in terms of
    Ilya> about 20 yo hardware!).

    Ilya> As an alternative bottleneck I'd rather propose 1) object
    Ilya> instantiation and 2) function calls. As of this writing,
    Ilya> pysnmp.asn1 code is designed as a top-down parser what
    Ilya> implies intensive recursion and object creation. Although
    Ilya> not a real receipt but rater a workaround, I'd suggest
    Ilya> caching and reusing top-level ASN.1/SNMP objects (such as
    Ilya> SNMP message) inside your app whenever possible.  This might
    Ilya> safe lots of CPU on a long run.

    Ilya> -ilya

Out of interest, I ran a simple pysnmp test using the Python
profiler. The test case was a 1000 loops of a GETREQUEST/GETRESPONSE
of sysDescr, using pysnmp 2.0.8 on a Linux box. The top 10, sorted by
time, were:


         514003 function calls in 8.100 CPU seconds
 
   Ordered by: internal time
   List reduced from 63 to 10 due to restriction <10>
 
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    18000    0.760    0.000    1.300    0.000 v1.py:240(update)
    14000    0.560    0.000    2.140    0.000 asn1.py:284(decode)
     3000    0.520    0.000    0.770    0.000 asn1.py:633(num2str)
    13000    0.490    0.000    1.600    0.000 asn1.py:263(encode)
    25000    0.370    0.000    0.510    0.000 asn1.py:206(__init__)
    52000    0.350    0.000    0.350    0.000 asn1.py:245(update)
     4000    0.330    0.000    1.340    0.000 asn1.py:750(decode)
     2000    0.330    0.000    0.700    0.000 asn1.py:606(str2num)
    30000    0.320    0.000    1.190    0.000 v1.py:210(__setitem__)
    21000    0.270    0.000    0.270    0.000 asn1.py:142(decode_tag)
 
 
By fiddling with the args/ARGS dictionary merging code in
v1.py:240(update), I cut its internal time by around 50%. I haven't
found any significant optimisations elsewhere. I can't figure out
where the time goes in the asn1.py decode/encode/update functions -
they don't have any loops and there's not much to them.

Would using the array module for holding the PDU make a difference?









More information about the Python-list mailing list