fredlcore / BSB-LAN

LAN/WiFi interface for Boiler-System-Bus (BSB) and Local Process Bus (LPB) and Punkt-zu-Punkt Schnittstelle (PPS) with a Siemens® controller used by Elco®, Brötje® and similar heating systems
220 stars 83 forks source link

Use 4 KB buffer in transmitFile() on ESP32 #554

Closed DE-cr closed 1 year ago

DE-cr commented 1 year ago

... if available from the heap, otherwise falling back to the existing static (<=) 1 KB buffer reason: performance improvement (>20% on an esp32 w/o SD card, using wifi)

An equivalent algorithm is already part of my https://github.com/fredlcore/BSB-LAN/pull/542, but only for /Dyyyy-mm-dd,YYYY-MM-DD, as /D and /Dn in that PR use transmitFile() directly (and therefore would also benefit from this PR here!).

The change has been done based on measuring /D times [s] on a datalog.txt of about 970 KB on my system (see above), comparing implementations using the original 1 KB buffer size and the new 4 KB buffer size for the transfer (file reading and data transmission over http):

      1 KB   4 KB   gain       
----+------+------+-----
#1    7.09   5.12   28 %
#2    6.92   5.18   25 %
#3    6.86   5.09   26 %
#4    6.80   5.51   19 %
#5    6.79   5.17   24 %
#6    6.80   5.02   26 %
#7    6.79   5.09   25 %
#8    6.76   5.44   20 %
#9    6.79   5.17   24 %
#10   6.80   5.14   24 %
----+------+------+-----
min   6.76   5.02   26 %
max   7.09   5.51   22 %
avg   6.84   5.19   24 %

I've created a new PR here, and have not included this in https://github.com/fredlcore/BSB-LAN/pull/542, to allow inclusion of this PR here, even if the other one is not accepted.

DE-cr commented 1 year ago

I'd appreciate others testing this change on systems I don't have available, most notably Arduino instead of ESP32, wired network connection instead of wifi, and using an SD card.

DE-cr commented 1 year ago

Not doing this on Arduino now, because of https://github.com/fredlcore/BSB-LAN/pull/542#issuecomment-1474269236