Thursday, 6 March 2014

Comparing Boot Times between Kanux (Kano OS) and Raspbian


I've spent a couple of hours playing around with Kano OS this morning. I was interested to see the claim that it boots twice as fast as Raspbian (it doesn't according to my calculations below) and wondering what special sauce had been sprinkled.

Boot to desktop time using two reformatted Samsung Class 6 Micro SD Card (previously had NOOBS):
http://swag.raspberrypi.org/collections/frontpage/products/noobs-8gb-sd-card

NetworkKanux boot time (s) Raspbian boot time (s)
Wifi card (not enabled)2839
Wifi enabled*39
Wired2838
None2739
* Couldn't connect to my Wifi using standard Edimax ew-7811un


They've removed a fair amount of stuff from Raspbian and replaced two packages.

If we look in the default runlevel for Kanux and Raspbian (2) and then diff the scripts found we see that Kanux replaces some standard Raspbian packages with alternatives (dropbear instead of OpenSSH and inetutils-syslogd instead of rsyslogd). They remove the swapfile process, NFS, NTP and rsync daemons.


tng@coalman:/tng_nfs/RASPBERRY_PI/Kanux_Raspbian_Comparison$ diff init.raspbian init.kanux 
6c6
< dphys-swapfile
---
> dropbear
7a8
> inetutils-syslogd
9,11d9
< motd
< nfs-common
< ntp
15,18d12
< rpcbind
< rsync
< rsyslog
< ssh
20c14
< triggerhappy
---
> update-motd


This is reflected in the running processes:

tng@coalman:/tng_nfs/RASPBERRY_PI/Kanux_Raspbian_Comparison$ diff proc.raspbian proc.kanux 
2c2,5
< [bcm2708_spi.0]
---
> -bash
> /bin/login
> /bin/login
> /bin/sh
7d9
< dhclient
10c12
< [ext4-dio-unwrit]
---
> [ext4-rsv-conver]
11a14,15
> idesk
> ifup
13d16
< [iscsi_eh]
19a23,24
> [kintegrityd]
> [ksmd]
23,24d27
< [kthrotld]
< [kworker/0:0]
34d36
< [nfsiod]
36d37
< pcmanfm
41d41
< [rpciod]
43,53c43
< /sbin/getty
< /sbin/getty
< /sbin/getty
< /sbin/getty
< /sbin/getty
< /sbin/getty
< /sbin/getty
< /sbin/wpa_cli
< /sbin/wpa_supplicant
< sshd:
< sshd:
---
> /sbin/udhcpc
57d46
< udisks-daemon:
65,69d53
< /usr/lib/arm-linux-gnueabihf/lxpolkit
< /usr/lib/gvfs/gvfs-afc-volume-monitor
< /usr/lib/gvfs/gvfsd
< /usr/lib/gvfs/gvfs-gdu-volume-monitor
< /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
71d54
< /usr/lib/udisks/udisks-daemon
73a57
> /usr/sbin/dropbear
78,81d61
< /usr/sbin/ntpd
< /usr/sbin/rsyslogd
< /usr/sbin/sshd
< /usr/sbin/thd
82a63
> [VCHIQka-0]
84a66,67
> [watchdog/0]
> wpa_supplicant

I'm not against trimming down the OS, but I wouldn't want to drop NFS from the Raspbian startup as it's so useful (LTSP). I certainly don't want NTP being dropped. Tonight I'm going to party like it's 1999:
From /etc/network/interfaces:

allow-hotplug eth0 
 iface eth0 inet manual 
 post-up /sbin/udhcpc -p /var/run/udhcpc-eth0.pid -S -i eth0 && (/usr/local/bin/tzupdate && /usr/bin/rdate -ncv $(cat /etc/timeserver.conf)) | logger -t kanuxnet -i -t kanuxnet


  tng@kano /etc/network $ more /etc/timeserver.conf 
ptbtime1.ptb.de

UPDATE1:

I was poking about through their network scripts and discovered they have a mountnfs in /etc/network/if-up.d.Maybe I'm just being too critical. They have removed the nfs tools (and kernel modules in their rebuilt kernel). Interesting move.

UPDATE2:


tng@coalman:/tng_nfs/RASPBERRY_PI/Kanux_Raspbian_Comparison$ ssh tng@192.168.1.136
tng@192.168.1.136's password: 
tng@kano ~ $ exit

tng@coalman:/tng_nfs/RASPBERRY_PI/Kanux_Raspbian_Comparison$ sftp tng@192.168.1.136
tng@192.168.1.136's password: 
bash: /usr/lib/sftp-server: No such file or directory
Connection closed

UPDATE3:

I have used the wonderful bootchart2 command to determine the boot times of Raspbian versus Kano as per Alejandro Simon's comments. I entirely agree with his readings of boot times using this tool



I now need to find out why the timings in bootcommand2 do not correspond to those of my stopwatch. I'm starting my time at power on and stopping the stopwatch when I see the first icon appear on the desktop. Intriguing.

UPDATE4:


Reading more about bootchart2, I see the following:

To make bootchart2 work best, please ensure your kernel is
configured with CONFIG_PROC_EVENTS=y and CONFIG_TASKSTATS=y, without
these we are slower, less accurate, and produce an uglier task hierarchy.
https://github.com/mmeeks/bootchart/blob/master/README

CONFIG_PROC_EVENTS is enabled in Kano but not in Raspbian:

tng@coalman:/tng_nfs/RASPBERRY_PI/Kanux_Raspbian_Comparison$ grep CONFIG_PROC_EVENTS config.kano
CONFIG_PROC_EVENTS=y
tng@coalman:/tng_nfs/RASPBERRY_PI/Kanux_Raspbian_Comparison$ grep CONFIG_PROC_EVENTS config.raspbian 
tng@coalman:/tng_nfs/RASPBERRY_PI/Kanux_Raspbian_Comparison$ 

Q: How are we supposed to accurately compare the startup times of the two O/S one of which is configured to produce faster, more accurate results with the measuring tool and one of which isn't?
A: Using a stopwatch. I stand by my timings.

4 comments:

Anonymous said...

Hi Tim,

Thanks for taking the time to look into Kanux in such detail -- it's really useful for us to get detailed feedback from the community.


The way we have measured the boot time is the following:
- Tool used: bootchart2
- OS: Kanux Beta v1.0 and (Raspbian 2014-01-07-wheezy-raspbian.zip) both out of the box. Just minimal required changes performed.
- SD card used: Transcend SDHC Class 10 8GB (Please take into account that boot time and performance in general depends on the SD card, so you won't get the same results without using the same card...)
- You can check the detailed results here:
Bootchart-raspbian - http://d.pr/i/NWQf
Bootchart-kanux - http://d.pr/i/903Y

To achieve those results, as you correctly noted, we have trimmed the OS down to the minimum and performed a bunch of other optimizations.*

We have removed NFS tools among other utilities that we thought a beginning user might not need. If you want to use sftp, why not use scp instead? It works perfectly fine ;-)

Regards,
Alejandro

* http://talk.kano.me/topic/78/kanux-v1-3-update

Tim Gibbon said...

Thanks for getting back to me Alejandro and providing such the detailed bootcharts you used. I now need to study them and understand them. I still stand by my figures. I've re-run the tests (with a stopwatch from plug in through to icons appearing on the desktop).

I'm fine with you removing NFS, but you should also clean up after yourselves, such as removing
/etc/network/if-up.d/mountnfs

Personally, I think that removing sftp-server means that you won't be able to use Filezilla. Some of your users may not be happy using the scp command but would be happy using a graphical tool(?).

If you really aren't using SFTP, then it might be a good idea to turn off the subsystem in sshd_config rather than getting an error.

I've looked through your kernel configuration and it would be good to have a detailed discussion about that either in the forums or elsewhere. Do you have any plans to publish your kernel config in github? That would be the easiest place to raise issues.


Tim Gibbon said...

Can you explain why you have different fbwidth and fbheight for the comparison tests between kanux and raspbian. I get the following for both raspbian and kanux.
bcm2708_fb.fbwidth=1600 bcm2708_fb.fbheight=1200

Are they run against the same screen?

Anonymous said...

Hi Tim,

The most efficient way to measure boot time is by using bootchart rather than stopwatch. It just requires couple of steps to setup:
1) Install it: sudo apt-get install bootchart2 pybootchartgui
2) Add the following line to /boot/cmdline.txt: init=/sbin/bootchartd
3) reboot and generate the graph: pybootchartgui

Thanks for the heads up about /etc/network/if-up.d/mountnfs , I will have a look.

You are right, you won't be able to use Filezilla, however you can transfer data by scp or even use sshfs which is closer to a graphical tool. We might need to write a tutorial on how to do this.

"it might be a good idea to turn off the subsystem in sshd_config" Well spotted! I'll create a ticket to solve this.

It would definitely be a great idea for you to have a look to our kernel configuration. You can find it here: https://github.com/KanoComputing/raspberrypi-linux/blob/rpi-3.12.y-bfs/config-rpi. Please share your feedback! We are using kernel version 3.12.9-ck2 with BFS scheduler. This definitely has a great impact in boot time.

"Can you explain why you have different fbwidth and fbheight" - I'm using the same screen, the same Pi and the same sd card for the tests. However, I think the difference is the overscan. Kanux fills the whole screen by default, while Raspbian has the black margin/frame around.

You can contact me at alejandro@kano.me, open issues in GitHub or join our forum: http://talk.kano.me/

Thanks!