bootchart on gentoo

Wednesday, April 23rd, 2008

Well after reading an article on OpenRC at Roys webs, I decided to take a look at my current system. I started by emerging bootchart.

Firstly I needed to unmask bootchart

echo "app-benchmarks/bootchart" >> /etc/portage/package.keywords

I then enabled the java use flag so I get the java code to generate png files

echo "app-benchmarks/bootchart java" >> /etc/portage/package.use

then I emerged it

emerge -av bootchart

I had to add init=/sbin/bootchartd to the end of the /etc/grub/grub.conf kernel line like this

kernel /boot/kernel-2.6.23-tuxonice-r11 root=/dev/sda3 init=/sbin/bootchartd

Then I editted the /etc/conf.d/rc and changed

RC_USE_BOOTCHART="no"

to

RC_USE_BOOTCHART="yes"

I enabled the auto chart creation by editing /etc/bootchartd.conf and changing

AUTO_RENDER="no"

to

AUTO_RENDER="yes"

This is what I got the first time.

Virtually all of my boot time is spent checking the internal tree of the 2 300Gb disks. One disk took around 17 seconds to check and the second one too around 15 seconds (its slightly smaller). Both are reiserfs. Both disks were unmounted cleanly and the fsck knew they were clean file systems, but the tree check still takes some time.

Do I really want it to not check the file system when it boot? That is the question…..

Heres the bootchart with the check disk disabled

I just changes the /etc/fstab entry from

/dev/sda3		/		reiserfs	noatime		0 1

to

/dev/sda3		/		reiserfs	noatime		0 0

I didnt enable the Process Accounting part so some short-lived process may not appear in the bootchart images. Ill try this next and see if I anything interesting.

GIMP Flame Fractal Backgrounds

Saturday, April 19th, 2008

I found this tutorial on how to create fractal backgrounds with GIMPs Flame filter on the front page of the gentoo wiki site.

You can actually get some very good results quite easily.

Here are the first few I managed to create.

Large versions are available here

Once you generate a good flame pattern you can keep creating new images and reusing the last flame settings but with different colours.

There is one issue. It appears that it has trouble generating large flames. 1600×1280 worked for me, but I could not get 3200×1080 working (dual monitor wide flame).

dont use stdio getc() or fgetc(), they are slow

Tuesday, April 15th, 2008

Well I thought I would write about an issue I have known about for some time, but it appears others still dont.

Its regarding stdio fgetc() performance. Mainly that using fgetc() is always slow and should rarely be used.

Here is a comparison of fgetc(), fread() and fgets() when reading a 333Mb mbox file created via thunderbird.

operation time
fgetc() 7.15 seconds
fgets() 0.65 second
fread() 0.08 seconds

Times are take on a quad core 2.4Ghz (linux 2.6.2.4 tuxonice r4 gentoo)

The performance issues clear show that retrieving information in larger ‘chunks’ is more efficient and its scary how different the performance is. Unless you only want 1 or a few characters, you should probably not use getc()

The code

fgetc()

clock_t start;
clock_t end;
FILE* testFile;
char buf[8*1024];
unsigned char chr;

testFile = fopen("testdata", "r");
start = clock();

while(!feof(testFile)) {
    chr = (unsigned char)getc(testFile);
}

end = clock();
printf("fgetc() %f seconds\n", ((float)end - (float)start) / (float)CLOCKS_PER_SEC);

fgets()

clock_t start;
clock_t end;
FILE* testFile;
char buf[8*1024];

testFile = fopen("testdata", "r");
start = clock();

do {}  while (fgets (buf, sizeof(buf), testFile) != NULL);

end = clock();
printf("fgets() %f seconds\n", ((float)end - (float)start) / (float)CLOCKS_PER_SEC);

fread()

clock_t start;
clock_t end;
FILE* testFile;
char data[8*1024];
int r = 1;

testFile = fopen("testdata", "r");
start = clock();

while(r!=0) {
    r = fread(data, sizeof(char), 1024*8, testFile);
}

end = clock();
printf("fread() %f seconds\n", ((float)end - (float)start) / (float)CLOCKS_PER_SEC);

Alsa Surround Sound with only stereo speakers

Tuesday, April 8th, 2008

I use Gentoo linux for my home desktop and I have had a problem with the alsa sound settings since I moved from my old PC to my new 64bit PC.

The problem was that I only had stereo speakers connected to the front channel and I had to keep opening alsamixer to set the volumes for this channnel.

If I changed the volume in any applications it only updated the PCM channel, which didn’t affect the front channel and didn’t affect the speakers connected to it.

I finally decided to fix this today.

After a little searching I found this HOWTO Surround Sound document, via the gentoo forums, on the gentoo wiki.

After reading it and giving a few failed tries, I used the following for my .asoundrc settings.

# cat ~/.asoundrc
pcm.!dmix {
        type plug
        slave {
                pcm surround51
                channels 6
        }
}
pcm.!default {
        type plug
        slave.pcm "dmix"
        slave.channels 6
        route_policy duplicate
}

I then rebooted. In Alsamixer I set the front channel at 100, and pcm at 50. I then fired up mplayer, when I changed the volume the pcm channel was affected and it did affect my stereo speakers plugged into the front channel.

Additional info

# lspci | grep Audio
00:0f.1 Audio device: nVidia Corporation MCP55 High Definition Audio (rev a2)
# cat /proc/asound/card0/id
NVidia
# cat /proc/asound/card0/codec#0 | grep Codec
Codec: Realtek ALC885