Monday 1 September 2014

Openhab on Raspberry Pi - its a bit slow

I have been hoping that if a waited for a while, the performance problems of Openhab on a Raspberry Pi would get sorted, but no such luck, so it might be time to get out the old wheel tapper's hammer and see what's going on.


Clean rebuild

My original build hasn't been updated in a while (both raspbian and openhab), so time for a clean break.
  • I swapped cards in the pi (so I still have the old version and all its files).
  • downloaded the latest noobs build and installed raspbian and enabled ssh so I could work at my laptop.
  • Got NFS up and running and checked it is working OK (my old build was refusing to let me mount and it was looking messy - another good reason to go for a clean build).
  • if you want remote desktop, you can do it here as described by Andrew Munsell.
  • playing chase the lady with Oracle Java, it now can be found here today (although this isn't the sort of link that looks like it hangs around), and I can't see an easy way to grab it on a command line only machine, so I downloaded it on my desktop and copied onto the pi memory card.
  • But the built in version still takes precedence, and I don't want version 7 (openhab will run faster on 8...), so remove version 7
  • now just copy over working openhab directory...
  • copy over and setup the startup script.....
  • make use a member of group tty so it can access the zwave board
  • Annnndddddd.. its broken - zwave module gets an (unspecified and not logged) i/o exception talking to the daughterboard. However it seems the nfs problem was my baby cisco switch deciding to be a firewall as well (cunningly built in so it can't be switched off) so I can revert to the old os build and still run openhab 1.5.

First checks

I've got my original raspbian build running with openhab 1.5 with just a handful of nodes. First thought was to check what garbage collector is up to as previous experience on android suggests this could well be an issue. So add in some gc monitoring and run up the beasty. A short run gave me this:

3.462: [GC (Allocation Failure)  2048K->855K(6912K), 0.0390900 secs]
4.001: [GC (Allocation Failure)  2903K->1442K(6912K), 0.0344180 secs]
5.072: [GC (Allocation Failure)  3490K->1799K(6912K), 0.0298060 secs]
5.384: [GC (Allocation Failure)  3847K->2544K(6912K), 0.0330090 secs]
6.517: [GC (Allocation Failure)  4590K->2976K(6912K), 0.0165470 secs]
7.832: [GC (Allocation Failure)  5024K->3510K(6912K), 0.0311390 secs]
8.992: [GC (Allocation Failure)  5558K->4012K(6912K), 0.0211830 secs]
10.336: [GC (Allocation Failure)  6060K->4499K(6912K), 0.0460930 secs]
11.696: [GC (Allocation Failure)  6547K->4986K(7040K), 0.0339830 secs]
11.731: [Full GC (Allocation Failure)  4986K->3481K(7040K), 0.1661020 secs]
12.841: [GC (Allocation Failure)  5913K->4050K(8492K), 0.0542170 secs]
13.467: [GC (Allocation Failure)  6482K->4557K(8492K), 0.0241470 secs]
13.842: [GC (Allocation Failure)  6970K->4905K(8492K), 0.0204380 secs]
14.294: [GC (Allocation Failure)  7337K->5355K(8492K), 0.0187060 secs]
14.733: [GC (Allocation Failure)  7787K->5793K(8492K), 0.0267030 secs]
15.309: [GC (Allocation Failure)  8225K->6074K(8620K), 0.0245930 secs]
15.334: [Full GC (Allocation Failure)  6074K->3694K(8620K), 0.2063280 secs]
15.871: [GC (Allocation Failure)  6382K->4207K(9104K), 0.0153110 secs]
16.274: [GC (Allocation Failure)  6895K->4461K(9104K), 0.0167900 secs]
16.728: [GC (Allocation Failure)  7134K->4821K(9104K), 0.0186710 secs]
17.165: [GC (Allocation Failure)  7509K->5199K(9104K), 0.0209690 secs]
17.529: [GC (Allocation Failure)  7887K->5509K(9104K), 0.0184720 secs]
17.937: [GC (Allocation Failure)  8183K->5966K(9104K), 0.0206800 secs]
18.237: [GC (Allocation Failure)  8654K->6361K(9104K), 0.0201770 secs]
18.582: [GC (Allocation Failure)  9049K->6528K(9232K), 0.0179510 secs]
18.600: [Full GC (Allocation Failure)  6528K->4120K(9232K), 0.2556920 secs]
19.339: [GC (Allocation Failure)  7064K->4426K(10068K), 0.0157840 secs]
20.337: [GC (Allocation Failure)  7362K->4735K(10068K), 0.0334120 secs]
22.383: [GC (Allocation Failure)  7679K->5009K(10068K), 0.0337120 secs]
24.819: [GC (Allocation Failure)  7953K->5611K(10068K), 0.0418900 secs]
27.257: [GC (Allocation Failure)  8555K->6612K(10068K), 0.0579130 secs]
29.238: [GC (Allocation Failure)  9556K->7052K(10068K), 0.0371640 secs]
31.833: [GC (Allocation Failure)  9996K->7641K(10708K), 0.0455450 secs]
31.879: [Full GC (Allocation Failure)  7641K->5445K(10708K), 0.4019310 secs]
35.790: [GC (Allocation Failure)  9285K->6817K(13300K), 0.0622380 secs]
38.390: [GC (Allocation Failure)  10657K->8341K(13300K), 0.0781040 secs]
41.424: [GC (Allocation Failure)  12181K->9749K(13684K), 0.0875970 secs]
41.512: [Full GC (Allocation Failure)  9749K->9248K(13684K), 0.4591170 secs]
43.983: [GC (Allocation Failure)  15520K->10796K(22456K), 0.1275950 secs]
49.355: [GC (Allocation Failure)  17068K->12407K(22456K), 0.1191610 secs]
49.597: [Full GC (Metadata GC Threshold)  12579K->8607K(22456K), 0.5249270 secs]
54.533: [GC (Allocation Failure)  14879K->10782K(22456K), 0.0757230 secs]
58.911: [GC (Allocation Failure)  17051K->12014K(22456K), 0.0702440 secs]
62.784: [GC (Allocation Failure)  18286K->13739K(22456K), 0.0907340 secs]
67.059: [GC (Allocation Failure)  20011K->15685K(22456K), 0.1099720 secs]
72.060: [GC (Allocation Failure)  21957K->17046K(23352K), 0.3365230 secs]
72.397: [Full GC (Allocation Failure)  17046K->10403K(23352K), 0.6597370 secs]
77.736: [GC (Allocation Failure)  17699K->11664K(25404K), 0.0660120 secs]
81.556: [GC (Allocation Failure)  18960K->13794K(25404K), 0.1028180 secs]
86.398: [GC (Allocation Failure)  21086K->16188K(25404K), 0.1187710 secs]
90.574: [GC (Allocation Failure)  23484K->17807K(25404K), 0.1017460 secs]
93.402: [GC (Allocation Failure)  25103K->19184K(26556K), 0.0932930 secs]
93.496: [Full GC (Allocation Failure)  19184K->14327K(26556K), 1.0448790 secs]
99.092: [GC (Allocation Failure)  24055K->15925K(34760K), 0.0795140 secs]
103.312: [GC (Allocation Failure)  25653K->16462K(34760K), 0.0761240 secs]
105.752: [GC (Allocation Failure)  26190K->16114K(34760K), 0.0541730 secs]
109.821: [GC (Allocation Failure)  25842K->16824K(34760K), 0.0737000 secs]
119.117: [GC (Allocation Failure)  26552K->17678K(34760K), 0.0912650 secs]
125.231: [GC (Allocation Failure)  27406K->18864K(34760K), 0.1338120 secs]
134.292: [GC (Allocation Failure)  28592K->20760K(34760K), 0.1353860 secs]
183.100: [GC (Allocation Failure)  30488K->21715K(34760K), 0.1248940 secs]
Which doesn't look to bad. Overall less than 10% cpu (prolly quite a bit less if a add it up in full), although the fact that full gc takes over 1 sec later in the run might mean problems later. I'll add this into the service script and see what a days worth looks like....


Pootle's standard Raspberry pi tweak

(Just copied over from previous blog for convenience)
  1. After installing the OS, use noobs to uncomment
    hdmi_safe=1
    also if you are using hdmi and you get a blank (no signal) screen. Also you can uncomment
    hdmi_force_hotplug=1
    so you can boot without the monitor conected, but plug it in later
  2. use raspi-config to change password and set machine name
  3. sudo update-rc.d rpcbind enable
  4. sudo apt-get install nfs-kernel-server
  5. add
    /home/pi 192.168.1.0/24(rw,sync,no_subtree_check)
    to /etc/exports
  6. sudo service rpcbind start
  7. sudo service nfs-kernel-server start

Notes

  1. if you are using an older or otherwise strange hdmi monitor...
  2. just good practice
  3. rpcbind is disabled in the rasbian build I got on my noobs card
  4. just adding the usual nfs server package
  5. adjust the ip address to match your local network
  6. fire up rpcbind
  7. fire up nfs-kernel-server -
    you could reboot at this stage, just to make sure that nfs comes up OK to avoid confusion and head scratching later!

Java 8 on R pi

Upgrade to Java 8 - performance is noticeably better (and we need all we can get..) :
sudo apt-get purge oracle-java7-jdk
This not only removes java7, but installs java 8 as well.

2 comments:

  1. Hi,

    Oracle's Java8 is default in the Raspbian repo for some time now.
    Using that version will get you easy updates.


    pi@raspi /opt/openhab/logs $ sudo apt-cache search java8
    oracle-java8-jdk - Java™ Platform, Standard Edition 8 Development Kit

    pi@raspi /opt/openhab/logs $ sudo apt-cache showpkg oracle-java8-jdk
    Package: oracle-java8-jdk
    Versions:
    8 (/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_wheezy_main_binary-armhf_Packages) (/var/lib/dpkg/status)
    Description Language:
    File: /var/lib/apt/lists/archive.raspberrypi.org_debian_dists_wheezy_main_binary-armhf_Packages
    MD5: 55234b1a538593b6c23d5b274a074500


    Reverse Depends:
    wolfram-engine,oracle-java8-jdk
    Dependencies:
    8 - libasound2 (2 1.0.16) libatk1.0-0 (2 1.12.4) libc6 (2 2.13-28) libcairo2 (2 1.2.4) libfontconfig1 (2 2.9.0) libfreetype6 (2 2.2.1) libgcc1 (2 1:4.4.0) libgdk-pixbuf2.0-0 (2 2.22.0) libglib2.0-0 (2 2.16.0) libgtk2.0-0 (2 2.24.0) libpango1.0-0 (2 1.14.0) libstdc++6 (2 4.4.0) libx11-6 (0 (null)) libxau6 (0 (null)) libxdmcp6 (0 (null)) libxext6 (0 (null)) libxi6 (0 (null)) libxrender1 (0 (null)) libxtst6 (0 (null)) netbase (0 (null))
    Provides:
    8 - java8-sdk java8-runtime-headless java8-runtime java7-sdk java7-runtime-headless java7-runtime java6-sdk java6-runtime-headless java6-runtime java2-sdk java2-runtime-headless java2-runtime java2-compiler java-virtual-machine java-sdk java-runtime-headless java-runtime java-compiler
    Reverse Provides:

    pi@raspi /opt/openhab/logs $ java -version
    java version "1.8.0"
    Java(TM) SE Runtime Environment (build 1.8.0-b132)
    Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)
    pi@raspi /opt/openhab/logs $


    Cheers,

    Dennis

    ReplyDelete
  2. Ah! Thanks, I see, had assumed (always dangerous) that the default installed version would be the latest major version, I'll switch to this, not quite the latest from Oracle, but as you say will be automatically managed this way.

    ReplyDelete