From 4462d5d3cf8bd63e39185ecd0afa5776bb95dc85 Mon Sep 17 00:00:00 2001 From: Lex Li Date: Fri, 15 Nov 2024 19:26:10 -0500 Subject: [PATCH] Added a performance guide. --- docs/source/development.rst | 2 +- docs/source/index.rst | 23 ++++++++--------- docs/source/performance.rst | 50 +++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 docs/source/performance.rst diff --git a/docs/source/development.rst b/docs/source/development.rst index 9c8c432d..1c9b5ae6 100644 --- a/docs/source/development.rst +++ b/docs/source/development.rst @@ -1,6 +1,6 @@ .. include:: /includes/_links.rst -Further development +Further Development ------------------- Although PySNMP is already a mature software and it is being used at many diff --git a/docs/source/index.rst b/docs/source/index.rst index e1f19efc..17d7d168 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -29,16 +29,20 @@ and behavior of popular Net-SNMP snmpget/snmpset/snmpwalk utilities. They may be useful in a cross-platform situations as well as a testing and prototyping instrument for pysnmp users. -Quick Start ------------ +Quick Start and Samples +----------------------- You already know something about SNMP and have no courage to dive into this implementation? Try out quick start page! +We also have a collection of sample scripts to help you learn more about +every aspects of PySNMP. + .. toctree:: :maxdepth: 1 /quick-start + /examples/index Documentation ------------- @@ -71,26 +75,19 @@ Conceptual and API documentation are in the following section. Documentation about the SNMP protocol can be found on `PySNMP Homepage`_. -Samples -------- - -We have a collection of sample scripts to help you get started with PySNMP. - -.. toctree:: - :maxdepth: 2 - - /examples/index - Troubleshooting --------------- -If you are having trouble with PySNMP, please check the following section. +If you are having trouble with PySNMP, please check the following section +to learn troubleshooting tips, upgrade guides, and performance tuning +advice. .. toctree:: :maxdepth: 1 /troubleshooting /upgrade + /performance Downloads --------- diff --git a/docs/source/performance.rst b/docs/source/performance.rst new file mode 100644 index 00000000..1da08794 --- /dev/null +++ b/docs/source/performance.rst @@ -0,0 +1,50 @@ +.. include:: /includes/_links.rst + +Performance Tuning +================== + +PySNMP is a highly optimized software. However, there are some knobs you +can turn to make it work even faster. Here are some tips: + +Disabling MIB Support +--------------------- + +Loading MIB metadata into memory is a costly operation. If you are not +using MIBs in your application, you can disable MIB support by + +TODO: Add a code snippet here. + +Run Python Release Mode +----------------------- + +Python interpreter can run in debug and release modes. Running in release +mode can make your Python code run faster. To run Python in release mode, +you can use the following command: + +.. code-block:: bash + + $ python -O myscript.py + +Choosing the Right High-Level API +--------------------------------- + +PySNMP comes with two high-level APIs: v1 and v3. + +If you are using SNMPv1 and SNMPv2c, and you are not using any security +features in your application, you should use the v1 API. The +``SnmpDispatcher`` based API is the fastest API in PySNMP, as it simply +sends SNMP packets and does not do any heavy processing on the packets. + +If you are using SNMPv3, you have to use the v3 API with USM and VACM to +handle security and access control. The v3 API is significantly slower than +the v1 API because it builds up a local secure engine and has to do more +processing on the packets in order to be compliant with SNMPv3 standards. + +Using the right API, and using the right features in the API can make your +application run reasonably fast. + +Don't trust blindly other Python SNMP libraries claiming to be faster. They +either lack of essential features that make the comparison pointless or +they bind to native libraries that become your nightmare to maintain and +deploy. In the end the performance is limited by the Python interpreter and +the SNMP protocol itself.