dbus-shelly-3em-smartmeter icon indicating copy to clipboard operation
dbus-shelly-3em-smartmeter copied to clipboard

performance tweaks

Open msekoranja opened this issue 2 years ago • 2 comments
trafficstars

Hi,

I have a CCGX (slow CPU) and using dbus-shelly-3em-smartmeter is noticable. Even more powerful Cerbo-s will benefit from the following optimizations:

  • _getConfig() gets called 2 times per update, meaning config file is open/read/parsed/closed 2 times every ~500ms. Consider caching configuration, and configurable update period (FR).
  • for each update a new TCP connection is created Consider caching connection, i.e. using requests.Session object. See https://stackoverflow.com/questions/24873927/python-requests-module-and-connection-reuse

Great project!!!

msekoranja avatar Aug 10 '23 12:08 msekoranja

Update: I have been testing connection reuse against 3EM. 3EM drops the connection after request, so reuse is not possible.

I see 2Hz rate is a but too high (I get the same value most of the time). 1Hz looks good, i.e. ~900ms sleep accounting some delay for the request.

msekoranja avatar Aug 10 '23 15:08 msekoranja

@fabian-lauer the _getConfig() issue is fixed in PR #71

Kotty666 avatar Jun 01 '24 14:06 Kotty666