Pioreactor / pioreactor

Hardware and software for accessible, extensible, and scalable bioreactors. Built on Raspberry Pi.
https://pioreactor.com
MIT License
94 stars 9 forks source link

Improve performance of CLI app #6

Closed CamDavidsonPilon closed 2 years ago

CamDavidsonPilon commented 3 years ago

Running pio or pios on the machines has a noticeable lag, and it's especially bad when running on a RpiZero. I don't want to overclock the machines - are there other ways to fix this?

Some useful points here: https://files.bemusement.org/talks/OSDC2008-FastPython/

Imports

3rd party packages take time to import (either because the modules need to be loaded, or the packages are doing initialization work).

Delay MQTT calls

Originally, pioreactor had calls to the leader to get information at initialization - this is probably causing some latency during pio (who didn't need this information). Move to lazily load this information.

CamDavidsonPilon commented 3 years ago

Through some import handling, I got it down about 3-5x using the tool python3 -X importtime -c "import pioreactor"

CamDavidsonPilon commented 3 years ago

The plugin system is about 33% of the start up time, specifically get_plugins, specifically:

pioreactor_plugins = entry_points().get("pioreactor.plugins", [])
CamDavidsonPilon commented 3 years ago

Some notes here: https://gregoryszorc.com/blog/2019/01/10/what-i've-learned-about-optimizing-python/