Raspberry server+client (WiringPi) runs slow - CPU @ 100%

I run local sever on my Raspberry, it works ok. But I have an issues with local clients (C++ one to be more exact). JS client works ok. But I prefer C++ client. Alas, it eats 100% of one of CPU cores when I start it. Why?

I just did everything in https://github.com/blynkkk/blynk-library/blob/master/linux/README.md:

$ git clone https://github.com/blynkkk/blynk-library.git
$ cd blynk-library/linux
$ ./build.sh raspberry
and
$ sudo ./blynk -t mytoken -s localhost &
answering:
[1] 12982
root@raspberrypi:/home/pi/blynk-library/linux# [0]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.0-beta on Linux

[1] Connecting to localhost:8442
[13] Ready (ping: 8ms).

Client is active and htop shows it eats 100% of one CPU core.
Is it normal?

I’ll have to re-check…

You have like 20 instances of what I’m guessing is java -jar /PATH/BlynkServer.jar :stuck_out_tongue: Perhaps that interfere? If you use top instead of htop, does it show the same CPU utilization? htop can be a bit funky :face_with_raised_eyebrow:

distans, Didn’t you never know that blynk local server creates lot of sub-threads? Contgrats!
vhymanskyy, any progress? Well, it is not so urgent, but I hope to resolve this. I tried to check with top, with same result.

I can confirm this too on my RasPi3. It shows 100% CPU. I just run the client, local server is on another Pi, so it is definitely somewhere in the client side of things.

I have never witnessed that :thinking:… and I have been been running Local Server for over a year now, and on a couple of different devices.

Only time I have ever seen two or three java references is when running ps -aux | grep java

@Lichtsignaal Are you running NodeJS or WiringPi (with 0.5.0) for your Blink client?

Thankfully I haven’t seen any issue with NodeJS on my RPi3… so I think it is probably the beta version of C++ client related.

Neither, I just compiled with the buildscript, so I guess that makes a C++ client, nothing to do with WIringPi or NodeJS. It’s a standalone client :slight_smile: Like the topic starter does :wink:

-edit

Build.sh shows wiringpi to be installed. I thought it would build a C++ client, lol.

Well, JS-client works well on same board with server. Moreover, I checked it today on my Cubieboard 2. Same 100%!
So the issue definitely lies inside C+±mode client.

LOL, try to use HTOP instead of TOP and you’ll witness!

0.5.0 is C++ version, not JS! And it must be more raw than JS one.

That I know… bracketed version# was in ref to the WiringPi… and yes, it is a BETA library, so probably the root of the issue.

Yes, I see now what you mean with HTOP… but most don’t seem to be really doing much, so not sure what all the seperate indications actually represent… more Linux crap to learn :stuck_out_tongue:

And here I thought that WiringPi was the only way to run C++ in the RPi… a bit-o-Googling later and apparently C and C++ is readily compilable on the RPi… natively??

OK… now I know a bit more… but i think I will stick with learning JS on the RPi so as to broaden my horizons a bit.

The whole Linux system is written in C… Linux is basically the love-child of C and Linus Torvalds :wink:

Guys wiringPi is a C++ library, that makes rpi coding very similar to Arduino.
our C++ library can be built either with or without it. There are 2 build flavours:

  • Linux - without wiringPi (i.e. for Ubuntu)
  • Raspberry - with wiringPi.

hense, vanilla linux version can’t perform direct pin operations.

100% cpu issue is on the library side, almost certainly. I’ll take a look at it soon. Sorry :wink:

1 Like

Thanks! Do I win a cookie?

Of course I know it creates threads… :roll_eyes: I’m just trying to exclude one possibility at time. If you had hit F5 in htop, the threads would actually have been shown, sparing you from uneducated guesses from my part.

S = Sleep :slight_smile:

        The state of the process:
           S for sleeping (idle)
           R for running
           D for disk sleep (uninterruptible)
           Z for zombie (waiting for parent to read its exit status)
           T for traced or suspended (e.g by SIGTSTP)
           W for paging

@Lichtsignaal @walkin-corpse @Gunner please update

1 Like

It appears to be stable. The RasPi also doesn’t go offline anymore (which it did about 5 seconds after connecting). CPU consumption is next to nothing now. You did great! (as if we ever doubted you… ha, not!).

1 Like

I don’t used C++ (WiringPi or otherwise) on my RPi, only NodeJS (which seems stuck at 0.4.7)… but I will consider the 0.5.0 for my Arduinos and ESPs

There is no consider, there is only do, or don’t :stuck_out_tongue:

Thnx a lot, now works seamlessly.