Categories
My Media System profiling Programming

MMS now environmentally friendly

Sometimes nice tools just come dumping down from the sky and PowerTOP is the latest of such programs. The Linux kernel 2.6.21 has become tickless which means that instead of waking up at specific intervals it will just sleep until it needs to do something next. This clearly has the potential to save quite a lot of power, but only if it really can sleep longer than it otherwise would have.

Intel has created a tool, PowerTOP, to test which programs causes the kernel to wake up. And thanks to the power of free software they have also been able to fix quite a lot of the programs people use a lot. So tonight I decided that I would run MMS and see how it performed. I installed the new kernel and the tool on my laptop and was ready to test. Initially the kernel was waking up between 60-80 times a second but after starting MMS it quickly rose to 1000! Something was definitely wrong. After a long debug session I finally found the cause of this massive spike in kernel wakeups: SDL. For some reason SDL was initialized using SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER). This small SDL_INIT_TIMER flag caused SDL to start a thread which just slept for 10ms, woke up, just to sleep for 10ms again over and over again…

Luckily the fix was easy and now MMS causes no mentionable extra wake ups 🙂