Performance of LUA scripting

Moderator: leecollings

Post Reply
User avatar
felix63
Posts: 244
Joined: Monday 07 December 2015 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Gouda
Contact:

Performance of LUA scripting

Post by felix63 »

Hi,

I am curious as to your experiences in regard to the running of scripts. As far as I can tell there are a couple of ways to automate things in Domoticz.
  • - Blocky scripts
    - File System based lua scripts
    - Database based lua scripts
    - lua scripts using dzVents
as well as PHP, Bash, Perl and Python scripts.

What is your experience with regards to performance issues? Specifically with the 3 different lua options? I kind of preferred the Database based option because of the ease of use and the automatic backup. But I've been reading some post discussing the benefits of alternative solutions but haven't quite found the ultimate answer.

Currently I have about 30 (blocky and lua) scripts in my database. What is your opinion?

cheers,
Lex
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Performance of LUA scripting

Post by Egregius »

Test it ;)
Make a blockly/lua/file with a name script_device_zzzzzz ( so it's executed last)
Let the script trigger a light by a pir and look at the difference in time between pir line and switch command.

On my syno I noticed that file based scripts are slightly faster than the ones in database.
And that even empty script cause a delay.
That's the main reason for me to only use 1 lua script. My reaction time went down from 800-1200msec to 42msec!
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Performance of LUA scripting

Post by deennoo »

Egregius PHP script is very fast, that true, but need some good knowledge on PHP if you are familliar with PHP that THE solution (his website is a good source)

Another solution :
run http command via LUA, because http request are fast
Not fast as Egreguis script but, fast as you can get a 200% better WAF

ICan provid you elements if you want (a simple lua parser + some new command on lua script) : http://easydomoticz.com/forum/viewtopic ... 706cb2242a

I notice differentes elements to :

chacon 433 switch module are slow and send order 2 times then if you need to drive another 433 modules this take time
chinese door contact/motion sensor + zwave module give fast answer
chinese door contact/motion sensor + milight bulb drive with rflink are fast as lightspeed
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
User avatar
heggink
Posts: 980
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Performance of LUA scripting

Post by heggink »

I switched from Blocky to Lua recently because of the memory issue with blocky causing my system to run out of memory after a few days. Unfortunately, I replaced the blocky's 1:1 with lua script files to then find that 1) domoticz seems single threaded and 2) with 40+ scripts keeps an RPI3 core 90% busy easily. The whole system was sluggish at best and usually downright slow.

After reading this, I consolidated the 42 lua scripts into 6 bigger scripts with lots of elseif's (tricky not to miss events).

Net result is that:
- domoticz hardly gets above 20% and typically hovers around 5-15%
- alexa no longer complains about devices not responding
- everything is a lot snappier

In hindsight it makes sense since I have inputs from 10 plugwise plugs, solar panels, a bunch of zwave plugs, a buncf of PIRs, a bunch of cameras, a p1 'smart'meter generating updates every 10 seconds and so on so masses op inputs every time triggering 42 lua scripts but then, hindsight is an exact science I guess.

Many thanks for this thread. Much happier now! :D :) :mrgreen:

H
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
User avatar
Siewert308SW
Posts: 290
Joined: Monday 29 December 2014 15:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Performance of LUA scripting

Post by Siewert308SW »

heggink wrote:I switched from Blocky to Lua recently because of the memory issue with blocky causing my system to run out of memory after a few days. Unfortunately, I replaced the blocky's 1:1 with lua script files to then find that 1) domoticz seems single threaded and 2) with 40+ scripts keeps an RPI3 core 90% busy easily. The whole system was sluggish at best and usually downright slow.

After reading this, I consolidated the 42 lua scripts into 6 bigger scripts with lots of elseif's (tricky not to miss events).

Net result is that:
- domoticz hardly gets above 20% and typically hovers around 5-15%
- alexa no longer complains about devices not responding
- everything is a lot snappier

In hindsight it makes sense since I have inputs from 10 plugwise plugs, solar panels, a bunch of zwave plugs, a buncf of PIRs, a bunch of cameras, a p1 'smart'meter generating updates every 10 seconds and so on so masses op inputs every time triggering 42 lua scripts but then, hindsight is an exact science I guess.

Many thanks for this thread. Much happier now! :D :) :mrgreen:

H
Are you sure that a script isn't triggered constantly?
5 to 15% on a Pi sounds like it does and for a Pi3 i bit high.
A pi3 should almost run idle with domoticz.
i have 35 scripts running and overhere it's hovering from 0.4 to max 0.75
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
User avatar
heggink
Posts: 980
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Performance of LUA scripting

Post by heggink »

Not that I have been able to see. Mind you, I dont use the motherboard sensors but track system and domoticz cpu usage myself. System is indeed nearly idle but domoticz usage only uses 1 core so 5-15% is in a single core. With 230+ devices many of which update constantly, I am not surprised with the current cpu usage. Thanks for the feedback btw.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Tieske
Posts: 1
Joined: Saturday 18 March 2017 9:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Performance of LUA scripting

Post by Tieske »

Just stumbled on this thread while browsing the forum.

I've only recently started with Domoticz, and one of the things I'm wondering is when the scripts (either Blockly or Lua) get triggered. From what I read above, the scripts get triggered on EVERY event. Is that correct?
commentator
Posts: 54
Joined: Thursday 23 June 2016 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

Re: Performance of LUA scripting

Post by commentator »

Tieske wrote: Saturday 18 March 2017 9:31 Just stumbled on this thread while browsing the forum.

I've only recently started with Domoticz, and one of the things I'm wondering is when the scripts (either Blockly or Lua) get triggered. From what I read above, the scripts get triggered on EVERY event. Is that correct?
the device scripts are, the time not
User avatar
heggink
Posts: 980
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Performance of LUA scripting

Post by heggink »

Lua yes, dzvents no.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest