Thanks, hopefully this helps. I notice whenever I use JS plugins the module tends to crash very often and occasionally freeze.

Regards,

M. Jaunius Kapkan

On Aug 28, 2021 17:34, Michael Balzer <dexter@expeedo.de> wrote:

Everyone,

when debugging some lost events due to Duktape queue overflows, I
stumbled across a major Duktape performance issue in the JSON
serialization support: encoding the AuxBatMon history data object of 5
arrays with 1440 numbers each (JSON size ~ 30 K) took ~ 12 seconds.

I searched the Duktape repository for this and found a "fastpath"
optimization we can use but didn't enable, so I tried that: that took
down the encoding time to ~ 8 seconds. Unfortunately, that's as good as
it gets with JSON in Duktape.

So I checked the CBOR support
(https://duktape.org/guide.html#builtin-cbor), and that works much
better. Encoding the AuxBatMon history to CBOR takes ~ 500 ms. That's
still not really good, but acceptable.

To enable using CBOR for data exchange with the web frontend as well,
I've included the CBOR-JS library by Patrick Gansterer, and added a
binary output option for Javascript commands. I've changed the AuxBatMon
and PwrMon plugins to use CBOR instead of JSON, and both work and load
much faster now.

I strongly suggest updating the plugins if you use them.

If you implement a plugin with some kind of data storage or transfer of
larger objects to the web frontend, do not use JSON, use CBOR instead.
I've added a section to our manual on this:

https://docs.openvehicles.com/en/latest/userguide/scripting.html#cbor

Regards,
Michael

--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26

_______________________________________________
OvmsDev mailing list
OvmsDev@lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev