<div dir='auto'>Thanks, hopefully this helps. I notice whenever I use JS plugins the module tends to crash very often and occasionally freeze.<br><br><div data-smartmail="gmail_signature">Regards,<br><br>M. Jaunius Kapkan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Aug 28, 2021 17:34, Michael Balzer <dexter@expeedo.de> wrote:<br type="attribution" /><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Everyone,
<br>
<br>
when debugging some lost events due to Duktape queue overflows, I
<br>
stumbled across a major Duktape performance issue in the JSON
<br>
serialization support: encoding the AuxBatMon history data object of 5
<br>
arrays with 1440 numbers each (JSON size ~ 30 K) took ~ 12 seconds.
<br>
<br>
I searched the Duktape repository for this and found a "fastpath"
<br>
optimization we can use but didn't enable, so I tried that: that took
<br>
down the encoding time to ~ 8 seconds. Unfortunately, that's as good as
<br>
it gets with JSON in Duktape.
<br>
<br>
So I checked the CBOR support
<br>
(https://duktape.org/guide.html#builtin-cbor), and that works much
<br>
better. Encoding the AuxBatMon history to CBOR takes ~ 500 ms. That's
<br>
still not really good, but acceptable.
<br>
<br>
To enable using CBOR for data exchange with the web frontend as well,
<br>
I've included the CBOR-JS library by Patrick Gansterer, and added a
<br>
binary output option for Javascript commands. I've changed the AuxBatMon
<br>
and PwrMon plugins to use CBOR instead of JSON, and both work and load
<br>
much faster now.
<br>
<br>
I strongly suggest updating the plugins if you use them.
<br>
<br>
If you implement a plugin with some kind of data storage or transfer of
<br>
larger objects to the web frontend, do not use JSON, use CBOR instead.
<br>
I've added a section to our manual on this:
<br>
<br>
https://docs.openvehicles.com/en/latest/userguide/scripting.html#cbor
<br>
<br>
Regards,
<br>
Michael
<br>
<br>
--
<br>
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
<br>
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
<br>
<br>
</p>
<p dir="ltr">_______________________________________________
<br>
OvmsDev mailing list
<br>
OvmsDev@lists.openvehicles.com
<br>
http://lists.openvehicles.com/mailman/listinfo/ovmsdev
<br>
</p>
</blockquote></div><br></div>