V4.1.2: steadily increasing cpu load

Discussions about Z-Way software and Z-Wave technology in general
seattleneil
Posts: 172
Joined: 02 Mar 2020 22:41

Re: V4.1.2: steadily increasing cpu load

Post by seattleneil »

piet66 wrote:Now I have a question of understanding: do you think, that the http.request() command is buggy?
Yes. The code for http.request() is in /opt/z-way-server/modules/modhttp.so. Since it is compiled code and Z-Wave.Me has not made the source code available on github (see: https://github.com/Z-Wave-Me), users wlll have to either wait for a fix, live with high CPU load or adopt a workaround. So far, the workaround previously described in this thread of using a "Virtual Device (JavaScript)" has solved my CPU load problem.
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: V4.1.2: steadily increasing cpu load

Post by PoltoS »

Thank you all for this deep analysis. We have checked and there are only small changes in this app since 3.2.3: only one lock added. I don't think it can affect the performance that high. In addition, we can't see it on our side and as I got, not all users do experience this issue.

It might be related to the name resolution (direct IP is mentioned or DNS resolution is needed to resolve a name) and LAN v.s. Internet HTTP requests target.

Please help us to collect more info: users who do and don't experience it, what are your HTTP requests:
- I do / don't experience the issue
- IP or DNS
- HTTP / HTTPS / WS / WSS
- to a service at localhost, LAN, Internet
seattleneil
Posts: 172
Joined: 02 Mar 2020 22:41

Re: V4.1.2: steadily increasing cpu load

Post by seattleneil »

PoltoS wrote: Please help us to collect more info: users who do and don't experience it, what are your HTTP requests:
- I do / don't experience the issue
- IP or DNS
- HTTP / HTTPS / WS / WSS
- to a service at localhost, LAN, Internet
I do experience the issue, URL uses DNS, request is HTTP GET with no auth, LAN.

Two observations: (1) an HTTP device that is a reliable localhost service does not appear to cause an increase in CPU usage. (2) Periodic polling of an HTTP device that is slow to respond (or doesn't respond) appears to cause an increase in CPU usage.

Happy hunting!
piet66
Posts: 267
Joined: 04 Feb 2017 17:00

Re: V4.1.2: steadily increasing cpu load

Post by piet66 »

Hi PoltoS,
I would very much welcome it if the problem could be solved soon.

What do you think of the following idea:

I'm currently on 3.2.3 and have no increasing CPU load. Since there are only small changes in modhttp.so, can I copy the 4.1.2 version of that file into the 3.2.3 folder and restart the zway server? Would that work?

If I then have increasing CPU load, this would prove the suspicion, if not then the reason must lie elsewhere.
Raspberry Pi 3 Model B Rev 1.2
Raspbian GNU/Linux 10 (buster, 32bit)
RaZberry by Z-Wave.Me ZW0700 7.20.00 07.38/1766938484 1025/257
Z-Way version v4.1.2 from 2023-10-18 03:34:26 +0300
User avatar
aLiEnHeAd
Posts: 136
Joined: 02 Feb 2017 15:09

Re: V4.1.2: steadily increasing cpu load

Post by aLiEnHeAd »

PoltoS wrote:
21 Dec 2023 04:11
Please help us to collect more info: users who do and don't experience it, what are your HTTP requests:
- I do / don't experience the issue
- IP or DNS
- HTTP / HTTPS / WS / WSS
- to a service at localhost, LAN, Internet
- I do experience the issue
- IP within my LAN
- HTTP GET and parsing the response (JSON.parse($$)[0].value.state?'on':'off')
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: V4.1.2: steadily increasing cpu load

Post by PoltoS »

piet66 wrote:
21 Dec 2023 11:19
I'm currently on 3.2.3 and have no increasing CPU load. Since there are only small changes in modhttp.so, can I copy the 4.1.2 version of that file into the 3.2.3 folder and restart the zway server? Would that work?
Thank you, piet66, for this idea. Yes, it was tested that it will work, so just copy the modhttp.so and let us know the result.
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: V4.1.2: steadily increasing cpu load

Post by PoltoS »

Thanks to @aLiEnHeAd, let's add a few more:
- I do / don't experience the issue
- IP / localhost / DNS
- HTTP / HTTPS / WS / WSS
- to a service at localhost, LAN, Internet
- parsed in XML / JSON / as text / no parsing of the result
- sync / async / don't know (is there an async = true in the http.request ?)
seattleneil
Posts: 172
Joined: 02 Mar 2020 22:41

Re: V4.1.2: steadily increasing cpu load

Post by seattleneil »

PoltoS wrote: Thanks to @aLiEnHeAd, let's add a few more:
The HTTP Device app index.js sets async=true. This is not configurable from the app's web UI.

Parser for on/off status: JSON.stringify($$).split('"')[3] === 'ON' ? 'on' : 'off'
piet66
Posts: 267
Joined: 04 Feb 2017 17:00

Re: V4.1.2: steadily increasing cpu load

Post by piet66 »

PoltoS wrote:
23 Dec 2023 02:39
piet66 wrote:
21 Dec 2023 11:19
I'm currently on 3.2.3 and have no increasing CPU load. Since there are only small changes in modhttp.so, can I copy the 4.1.2 version of that file into the 3.2.3 folder and restart the zway server? Would that work?
Thank you, piet66, for this idea. Yes, it was tested that it will work, so just copy the modhttp.so and let us know the result.
Done it. It seems to work. Will observe it.

PoltoS wrote:
23 Dec 2023 02:46
Thanks to @aLiEnHeAd, let's add a few more:
- I do / don't experience the issue
- IP / localhost / DNS
- HTTP / HTTPS / WS / WSS
- to a service at localhost, LAN, Internet
- parsed in XML / JSON / as text / no parsing of the result
- sync / async / don't know (is there an async = true in the http.request ?)
- I do experience the issue in 4.1.2
- fixed IP address
- HTTP
- to a local service within in the same server
- parsed in JSON
- async

And here for the sake of completeness the code (from module MxChartDB):

Code: Select all

    var request = {
        url:     url,
        method:  'POST',
        auth: {
            "login":    self.constants.username,
            "password": self.constants.password
        },
        data:    JSON.stringify(data),
        async:   true,
        success: function(response) {
                    ...
                 },
        error:   function(response) {
                    ...
                 }
    };
    http.request(request);

Code: Select all

    var request = {
        url:     url,
        method:  'GET',
        auth: {
            "login":    self.constants.username,
            "password": self.constants.password
        },
        async:   true,
        success: function(response) {
                    ...
                 },
        error:   function(response) {
                    ...
                 }
    };
    http.request(request);
Raspberry Pi 3 Model B Rev 1.2
Raspbian GNU/Linux 10 (buster, 32bit)
RaZberry by Z-Wave.Me ZW0700 7.20.00 07.38/1766938484 1025/257
Z-Way version v4.1.2 from 2023-10-18 03:34:26 +0300
piet66
Posts: 267
Joined: 04 Feb 2017 17:00

Re: V4.1.2: steadily increasing cpu load

Post by piet66 »

piet66 wrote:
23 Dec 2023 12:12
PoltoS wrote:
23 Dec 2023 02:39
piet66 wrote:
21 Dec 2023 11:19
I'm currently on 3.2.3 and have no increasing CPU load. Since there are only small changes in modhttp.so, can I copy the 4.1.2 version of that file into the 3.2.3 folder and restart the zway server? Would that work?
Thank you, piet66, for this idea. Yes, it was tested that it will work, so just copy the modhttp.so and let us know the result.
Done it. It seems to work. Will observe it.
After some days I can report the result of my experiment:
it needs slightly more CPU, but I cannot recognize any growing of the load.

This would indicate that modhttp.so is not the culprit.

For a complete proof, it may actually make sense to go additionally the other way round: running the 3.2.3 version in 4.1.2. If it's possible.
Raspberry Pi 3 Model B Rev 1.2
Raspbian GNU/Linux 10 (buster, 32bit)
RaZberry by Z-Wave.Me ZW0700 7.20.00 07.38/1766938484 1025/257
Z-Way version v4.1.2 from 2023-10-18 03:34:26 +0300
Post Reply