Page 1 of 1

Speed Domoticz

Posted: Wednesday 17 May 2017 8:01
by poudenes
Hi Guys,

Have a little question before i change everything. :)

Is there any difference in speed between:
Blocky and LUA
Dummy Switches and User Variable

Im using blocky now and work great and some dummy switches as a check. But will it help to move them to user variable and LUA?
If there is no speeds difference than the Dummy Switches and blocky are a visualisation of some scripts then.

Let me know :D Thanks!

Re: Speed Domoticz

Posted: Wednesday 17 May 2017 8:41
by Nautilus
According to Gizmocus (and also my own testings) Blockly is faster than lua, see e.g. https://www.domoticz.com/forum/viewtopi ... er#p106800

Lua can be made quite fast using the ../domoticz/scripts/lua directory to store the script files (and not the event management system on the web interface, where you e.g. manage blocklies) but still it is slower. A lot of separate "script_device_XXX.lua" files will increase your CPU usage and possibly make Domoticz sluggish. This can be avoided by creating a master file that is the only one that actually triggers at device change and then call the other files from the master. But if you manage all your requirements with Blockly, I'd stick with that... :)

There are "3rd party" alternatives that work a lot faster, try searching e.g. "pass2php" ;)

Re: Speed Domoticz

Posted: Wednesday 17 May 2017 9:40
by Egregius
Because you ask the question, must be that you experience delays between some stuff.
Check your logfile to see where the time goes.
For me, the only real need for speed is when a light must be switched with a pir or a remote. All the rest is not that important.
When I ran Domoticz on my Syno I got reaction times as short as 20msec with pass2php :)
Since I moved to a RPi2 it's a little bit slower at around 80msec.

Re: Speed Domoticz

Posted: Wednesday 17 May 2017 11:05
by poudenes
Nautilus wrote:According to Gizmocus (and also my own testings) Blockly is faster than lua, see e.g. https://www.domoticz.com/forum/viewtopi ... er#p106800

Lua can be made quite fast using the ../domoticz/scripts/lua directory to store the script files (and not the event management system on the web interface, where you e.g. manage blocklies) but still it is slower. A lot of separate "script_device_XXX.lua" files will increase your CPU usage and possibly make Domoticz sluggish. This can be avoided by creating a master file that is the only one that actually triggers at device change and then call the other files from the master. But if you manage all your requirements with Blockly, I'd stick with that... :)

There are "3rd party" alternatives that work a lot faster, try searching e.g. "pass2php" ;)
Thanks for the feedback. i will check pass2php. But love to keep everything inside of Domoticz (backup options and everything go into it)

Re: Speed Domoticz

Posted: Wednesday 17 May 2017 11:17
by Nautilus
Egregius wrote: Since I moved to a RPi2 it's a little bit slower at around 80msec.
Interesting, since I was always comparing my RPi2-based results with yours and did not think the platform had so significant impact. So the time from "domoticz sees pir triggered to domoticz sends light on" is now about 80msec with RPi2?

Re: Speed Domoticz

Posted: Wednesday 17 May 2017 12:23
by Egregius
Correct, round 80msec between signal of pir and command to switch light.
Not so difficult: my nas has a dual core 2.2Ghz processor and 4GB memory, the RPi runs at 0,6Ghz with 1GB memory.

Re: Speed Domoticz

Posted: Wednesday 17 May 2017 19:53
by Nautilus
Egregius wrote:my nas has a dual core 2.2Ghz processor and 4GB memory, the RPi runs at 0,6Ghz with 1GB memory.
Guess that explains it. Always thought that other NASes are as slow as my Qnap... ;) Why the change to RPi though (and not enjoy the speed benefits of running on Syno)?

Re: Speed Domoticz

Posted: Wednesday 17 May 2017 19:59
by Egregius
Power consumption. Syno DS1513+ consumes 65W. That's a difference of about €130/year.

Re: Speed Domoticz

Posted: Wednesday 17 May 2017 23:30
by Nautilus
Egregius wrote:Power consumption. Syno DS1513+ consumes 65W. That's a difference of about €130/year.
Ah, ok, thought you had the Syno running continuously in any case so that's why I wondered the reasoning. But yes, that's quite a hefty consumption for a nas...

Re: Speed Domoticz

Posted: Thursday 18 May 2017 7:21
by Egregius
It was running 24/7 before, until I started looking at power consumption. For some reason I consumed 2800kWh more than usual, resulting in a huge bill. Then you start...
Since that, power consumption is down by about 40%.

Re: Speed Domoticz

Posted: Thursday 18 May 2017 9:44
by qwerk
just to get back on topic :D

I have 25 device scripts. running on a raspberry B
If I combine them to less, my speed would significant improve?

I can not set them to blockly at this moment, I need to be able to set a sensor value, and that can not be done in blockly ( only by url with json)

Re: Speed Domoticz

Posted: Thursday 18 May 2017 12:06
by Nautilus
Well, that also depends partly on whether you have them in the file system as text files or in the database. File system is definitely faster. The speed increase (if talking about just the minimum reaction time to certain event) is perhaps debatable in case you move to e.g. single master script but at least on RPi2 that made a huge impact on CPU usage and thus to overall responsiveness as well (which often translates to improved reaction speed as well :)):
Screen Shot 2017-05-18 at 13.01.33.png
Screen Shot 2017-05-18 at 13.01.33.png (152.18 KiB) Viewed 3430 times
You can see CPU steadily increasing as I kept adding more scripts. The drop comes from moving to a single master (device) script after which I've kept adding stuff to be processed with the master script but CPU usage has remained steady.

Re: Speed Domoticz

Posted: Thursday 18 May 2017 15:47
by qwerk
thanks for your comprehensive answer.

just to be sure, I have many PIR scripts with in the if devicechanged......
If I put them in 1 script that would work?

they are on the filesystem. a mounted share from a nas ( to save my sdcard) that made domoticz a little faster

Re: Speed Domoticz

Posted: Thursday 18 May 2017 16:41
by Egregius
How much time do you have now between pir and switch command?

Re: Speed Domoticz

Posted: Thursday 18 May 2017 17:15
by qwerk
I just checked my log:
the last time: 3 seconds

often it is around 1 seconds or 1,5

Re: Speed Domoticz

Posted: Thursday 18 May 2017 17:29
by Siewert308SW
Lua Event File system based scripts can be fast aswell.
But the conventional way as we know now with a bunch of lua files in one folder can make the system decrease in speed.
It's caused by all the commandArray {} and return commandArray
On my RPi3 i have one single file which controls that.
Major advantage is file based event system is faster more responsive and the memory footprint aswell as the cpu usage is much better.

Below a part of my log file.
Show the reaction time between a 433mhz sensor and time it took to switch the light.
Reaction time from Motion Sensor -> Domoticz -> switching light is 0.030 seconds

Code: Select all

2017-05-18 17:20:37.322 (RFXtrx433e) Lighting 2 (W.C Motion) 
2017-05-18 17:20:37.356 (RFXtrx433e) Lighting 2 (W.C Lamp)
2017-05-18 17:20:37.357 LUA: ========================= EVENT LOG =========================
2017-05-18 17:20:37.357 LUA:
2017-05-18 17:20:37.357 LUA: Message:
2017-05-18 17:20:37.358 LUA: "W.C Motion" sensor detected motion
2017-05-18 17:20:37.358 LUA: .............................................................
2017-05-18 17:20:37.358 LUA:
2017-05-18 17:20:37.358 LUA: Executing:
2017-05-18 17:20:37.358 LUA: > "W.C Lamp" set: On REPEAT 2 INTERVAL 1
2017-05-18 17:20:37.358 LUA: > "W.C Standby" set: On
2017-05-18 17:20:37.358 LUA:
2017-05-18 17:20:37.358 LUA: =============================================================

Re: Speed Domoticz

Posted: Thursday 18 May 2017 23:27
by Nautilus
qwerk wrote: just to be sure, I have many PIR scripts with in the if devicechanged......
If I put them in 1 script that would work?
Yes, you'll see some improvement each time you make the number of scripts fewer. As mentioned, I currently have only one (master) script which calls (with dofile) other script files to make it a bit easier to manage stuff (compared to having everything in s single file). As Siewert above describes, this kind of approach returns only a single commandArray from each device change.
qwerk wrote:they are on the filesystem. a mounted share from a nas ( to save my sdcard) that made domoticz a little faster
Interesting, mounted share (SMB?) is faster than an SD card, perhaps depending on the card type? I assume you have the whole Domoticz installation there, how significant was the speed improvement you got from this?