Performance of LUA scripting

Post Reply
User avatar
felix63
Posts: 100
Joined: Monday 07 December 2015 10:30
Target OS: Raspberry Pi
Domoticz version: 3.8275
Location: Gouda
Contact:

Performance of LUA scripting

Post by felix63 » Sunday 20 November 2016 23:20

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: 2446
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: Beta
Location: Beitem, BE
Contact:

Re: Performance of LUA scripting

Post by Egregius » Sunday 20 November 2016 23:51

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: 913
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Performance of LUA scripting

Post by deennoo » Monday 21 November 2016 0:07

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 / ESP8266 / MQTT / BLE
http://domo-attitude.fr

User avatar
heggink
Posts: 336
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V3.7067
Location: NL
Contact:

Re: Performance of LUA scripting

Post by heggink » Thursday 16 March 2017 21:39

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
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

User avatar
Siewert308SW
Posts: 499
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Performance of LUA scripting

Post by Siewert308SW » Thursday 16 March 2017 21:59

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:
1x RPi3 - PIco hv3.0A Plus / Domoticz
1x RPi3 - PIco hv3.0A Plus / PiHole
1x RFXtrx433E / Aeotec ZW090
3x FI9803P Cam
2x Youless Elec/Gas
4x KD101 detectors
a lot of KaKu/z-wave stuff

Domoticz scripts: @ GitHub
pico_installer: @ GitHub

User avatar
heggink
Posts: 336
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V3.7067
Location: NL
Contact:

Re: Performance of LUA scripting

Post by heggink » Friday 17 March 2017 22:09

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.
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

Tieske
Posts: 1
Joined: Saturday 18 March 2017 10:23
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Performance of LUA scripting

Post by Tieske » Saturday 18 March 2017 10: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?

commentator
Posts: 42
Joined: Thursday 23 June 2016 14:41
Target OS: Raspberry Pi
Domoticz version: beta
Location: NL
Contact:

Re: Performance of LUA scripting

Post by commentator » Sunday 20 August 2017 21:48

Tieske wrote:
Saturday 18 March 2017 10: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: 336
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V3.7067
Location: NL
Contact:

Re: Performance of LUA scripting

Post by heggink » Sunday 20 August 2017 22:29

Lua yes, dzvents no.
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests