Monday, July 9, 2007

cpufreq and measuring power consumption

Since everyone are talking about Live Earth and global warming recently, I have decided to check my personal power consumption. Other than my car, I guess the second most power consuming device is my PC. So I decided to measure how much power it consumes. Especially as I have recently discovered the cpufreqd that can adjust my Pentium 4 processor speed from 2.4GHz down to 300MHz.

Unlike some hardware review sites where they could afford to buy good quality power meters like the Watts Up, all I have is just two multimeter laying around my toolbox and they can't even measure AC current. So, I also can't measure power as the method described in the article in TwistedMod. I has to create my own method to measure the current that goes into my PC. The circuit is as shown below:

circuit to measure PC power consumptionThe resistor 5.1ohm, 5W was used because it is the only suitable resistor that is in my toolbox. Basically, any low resistance high power resistor should be suitable. The power dissipation of the resistor must be less than its rated power. For instance, I would expect my PC to draw less than 200W average and the mains provides 250V, thus the current is I = P/V = 200W/250V = 0.8A. Therefore, resistor power dissipation is P = I2R = 0.82 x 5.1 = 3.264W, which is still safe and below 5W. Of course, a 10W resistor would be safer and if your mains is 110V, the current would be twice and there for a 2ohm, 10W resistor is probably more suitable as the voltage drop across the resistor is lower.

BTW, if you do not really understand the above paragraphs about voltage, current and power, PLEASE DO NOT ATTEMPT THIS AT HOME!

Ok, I have completed modifying the above circuit as shown below:


The setup showing multimeter measuring VR

Next, I set my two multimeters to measure AC voltage. And finally, I plugged in the power cord and I pressed the power button....

... fans and hard disk spins up ..... beep ...

Yes, it works. The VAC shows 252V and VR fluctuates around 1.8V as Kubuntu boots up. Also, resistor power dissipation, PR = 1.8V / 5.1ohm = 0.35A.

After the system boots up and once the system reaches idle (cpufreqd is set to ondemand and ksensors show 300MHz), the VR is 1.6A with my LCD monitor on and 1.2A when the LCD monitor is switched off.




Then, I set my CPU frequency using cpufreq-set command (for example, cpufreq -f 1600 to set various frequency and various system load to determine the effect of CPU frequency and CPU load on power consumption. For more info on setting CPU frequence and power management in Linux, see
Debian HOW-TO : CPU power management

To simulate load, I used mencoder to trancode an episode of DL.tv using the following command:

mencoder dl.tv.173.i.mp4 -ovc lavc -oac lavc -o /dev/null

FYI, these are the major components of my machine's specs:
  • Intel Pentium 4 - 2.4Ghz
  • 512MB RAM - Corsair XMS 2ns
  • MSI 865P Neo motherboard
  • MSI Geforce FX 5200 - 128MB
  • Creative SB Audigy
  • 250GB WD Caviar SE
  • 40GB WD Caviar
  • LiteON DVD +/- RW drive
  • 17" Samsung LCD 173V

Results:


Power consumption with single CPU load


Power consumption at idle

As you can see, when the CPU is loaded, the power consumption reduces when the CPU frequency is reduced. However, on idle load, changing CPU frequency does not seems to any effect on power consumption. I guess the reason is because my old processor is not really design for frequency scaling for reduced power consumption. It would be interesting to see the difference on newer processors with Intel's Enhanced SpeedStep or AMD's Cool 'n' Quiet.

At idle power consumption at 60W is not exactly low compared to some latest 'green' machines. But it is relatively low compared to the those high-end gaming machines.

Another observation is that the 17" LCD takes approximately 30W.

Lastly, please try to use Live Earth online calculator to find out your lifestyle carbon footprint and so something about it. My Live Impact score is 215 and 4.7 tons of carbon output per year. Hmm.. I guess I can probably do something to reduce this.

Monday, July 2, 2007

The Economics of open source

An interesting and lively discussion thread has popped up at Ubuntu Forums with a title that is sure to invite a large reaction among the group of highly enthusiastic Ubuntu users in the forum:
*deep breath* For the most unpopular opinion of any Ubuntu user, please click here.
In summary, the original poster's opinion was that Ubuntu should be made closed-source so that programmers can make a lot money and improve their lives. He/She also said that by closing up Ubuntu, its quality will improve because paying more money will make things better.

It is unfortunate that he/she has such opinion, which makes many other posters in the thread believe that he/she has very little understanding of the dynamics of open-source softwares. Later in the thread, he/she has indicated that he is still in college and he would wish that the software industry would be a huge money pot for everyone to join. So, I guess he/she can be forgiven for being less knowledgeable in the dynamics of the software industry and life as a software developer.

The software industry is relatively new industry that is fast growing and thus getting huge and complicated. Writing a software product is not like writing a home-brew program or student project. For large projects involving many programmer, the overhead for many non-coding processes increases (on this topic, I would recommend reading the first few chapters of Steve McConnell's Code Complete book). It seems to him/her that life as a programmer will be better if people pay companies to make softwares. Unlike other traditional industry where the workflow is something like:
1. Product designers conceptualize and designs the product such as cars.
2. Engineers turns the design in to prototype and ensure that the design is good and reliable.
3. Finally, factory workers build/assemble the cars and its parts.

But in software, we are the engineer and also the construction worker because, we do the design and also the dirty work of constructing each and every part of the software.

Personally, two years ago, when I was still in university, I also had a similar opinion like him but less radical. To me, Linux was mainly a toy OS to learn about how computer and software works. At that time, I also believed that proprietary software are still superior. However, things changes as I started working in a large US-based technology corporation that makes products with proprietary codes, I came to understand the real deal in developing softwares. Businesses are still businesses, the goal of the company is to make profit for the shareholders. Shareholders invest money in company to make profit, not to pay programmers to do what they like to do. Now, as a software engineer, I came to realize that quite often, what we do to the piece of software is primarily a business decision that leads back to faster time to market, better profit, etc.

I think open-source is an alternative business model that might actually work for software industry. While it is still quite early to decide is open-source is definitely the future, it is quite entirely possible as software development in indeed very different from most traditional product development industry.

Anyway, these are mainly the opinion of mine as a young software engineer as I begin probably a life-long journey in the software industry and may not necessary represent those that are veteran in the industry. I'll probably write more on this in the future. Until then here's some interesting reading about Linux vs. Windows http://linux.oneandoneis2.org/LNW.htm