Speed Domoticz Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Speed Domoticz

Post 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!
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Speed Domoticz

Post 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" ;)
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Speed Domoticz

Post 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.
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Speed Domoticz

Post 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)
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Speed Domoticz

Post 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?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Speed Domoticz

Post 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.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Speed Domoticz

Post 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)?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Speed Domoticz

Post by Egregius »

Power consumption. Syno DS1513+ consumes 65W. That's a difference of about €130/year.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Speed Domoticz

Post 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...
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Speed Domoticz

Post 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%.
qwerk
Posts: 222
Joined: Tuesday 22 July 2014 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Speed Domoticz

Post 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)
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Speed Domoticz

Post 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 3422 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.
Last edited by Nautilus on Thursday 18 May 2017 23:21, edited 1 time in total.
qwerk
Posts: 222
Joined: Tuesday 22 July 2014 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Speed Domoticz

Post 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
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Speed Domoticz

Post by Egregius »

How much time do you have now between pir and switch command?
qwerk
Posts: 222
Joined: Tuesday 22 July 2014 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Speed Domoticz

Post by qwerk »

I just checked my log:
the last time: 3 seconds

often it is around 1 seconds or 1,5
User avatar
Siewert308SW
Posts: 294
Joined: Monday 29 December 2014 15:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Speed Domoticz

Post 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: =============================================================
Setup:
- DS923+ Docker
Domoticz Latest Stable
Mosquitto / ZwaveJSUI @ Aeotec Z-Stick Gen5+ / PiHole Unbound
P1 USB Gas/Power, HW watermeter
- A lot of Zwave switches, contacts, plugs, smoke/Co2 ect
- DiY 7.5kWh Solar Storage @ GitHuB
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Speed Domoticz

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest