sunnuntai 29. marraskuuta 2009

Using top

I have installed a cpu monitor status module from the extras repository, that at first seemed grossly inaccurate or at least hard to read any meaningful information from.



I take back what I said. Over the past few days I've noticed that CPU-monitor peaking (the left bar has gone into the red with five squares). Whenever that has happened, like the true linux-aficionado that I am, I've launched a terminal to see what's drawing resources. Each time it has been the same process: /usr/sbin/browserd. If you want the CPU-monitor, you can get it by installing load-applet.

Using top

To find out what process is sucking away cpu cycles, you can use top. On the N900, you start top, the diagnostic tool of choice for many unix administrators this way:
  • Start the terminal (easiest by just pressing ctrl-shift-x)
  • Write top at the prompt and press enter.
  • Exit top by pressing "q" on the keyboard.
  • Sort by CPU usage by pressing capital "P" (for processor)
  • Sort by memory usage by pressing capital "M"
  • The terminal can be exited by writing exit and pressing enter at the prompt. Or by closing the window from the X.



This is my view of top when I have started exactly two web sites: Facebook and the Finnish news service Ampparit. (Note the cpu monitor at four squares and the memory monitor at two). As you can see, browserd is using over 80% (81.5) of the CPU's capacity. This is of course not a static value that never changes: you need to keep monitoring the readings to see if it goes down to a more normal level over time.

In my case cpu usage jumps between 40% and 80%, but never goes down to a low level. Whether this is an error somewhere or not is hard to tell. We have to remember that this is a truly multitasking device, so CPU usage should be the same whether we are looking at the page or not. For Android this is not the case, on Android the background processes are going into a hibernate-kind-of-state and stop wasting CPU cycles when a window is thrown into the background.

On the N900 you, the user, are responsible for hibernating stuff you don't need. This means it might be a bad idea to leave a website open for a whole day in a backgrounded window. I was going to do just that for Facebook and always have the most up to date feed visible when I activate the window. Now I'm going to close web browser windows I don't need, because cpu usage is proportional to battery usage. Not in a linear fashion, but you can be sure that an N900 with a cpu usage of (average) 50% throughout the day is going to suck more juice out of your batteries than one that is hanging steady at 1%.

I've also confirmed that hibernating putting the N900 to sleep (by double pressing the power button so the screen goes black) has no effect on browserd cpu usage.

It is interesting to note, that we shouldn't assume the name browserd automatically implicates the web browser, but I googled it and came up with several web sites that confirmed that browserd is linked to the web browser and if I have no web sites open, it shouldn't be doing anything at all. Another typical way of confirming that the web browser is indeed responsible for the higher cpu usage is to close all browser windows and monitor the effect it has on browserd and system cpu usage. If it goes down, you can be pretty sure you caught the right program.

Different websites put a different strain on the CPU. One of the biggest culprits is naturally flash - we all know that. The site "Ampparit" is running some flash ads and so I tried closing down just Ampparit and leaving Facebook. The result was interesting. Cpu usage went down from 40-80% to around 2-5%. So leaving a website open with any kind of flash component is a big no-no. I might still not want facebook hanging in its own window throughout the day. Event 4% cpu usage that wouldn't have to be expended, might be too steep.

Ei kommentteja:

Lähetä kommentti