Boosting dpkg performance

Tired of waiting for dpkg to do your bidding? dpkg is slow because it has a lot of files in the /var/lib/dpkg/info dir and filesystems such as ext3/4 are slow in these situations. So how about moving /var/lib/dpkg to reiserfs?
dd if=/dev/zero of=/var/lib/dpkg.img bs=1M count=300
mkfs.reiserfs -f /var/lib/dpkg.img
mkdir /mnt/dpkg && mount -o loop /var/lib/dpkg.img /mnt/dpkg
cp -a /var/lib/dpkg/* /mnt/dpkg
mount --move /mnt/dpkg /var/lib/dpkg

Test results

Before the tweak:
time apt-get check
Reading package lists... Done
Building dependency tree       
Reading state information... Done

real   0m1.769s
user   0m0.444s
sys   0m0.084s
 
After the tweak:
apt-get check
Reading package lists... Done
Building dependency tree       
Reading state information... Done

real   0m0.527s
user   0m0.384s
sys   0m0.028s
Notice the real time difference vs the not so big sys and user time differences? this is because real includes the time spend blocking on IO calls. So time spent waiting for IO was 1.769 - 0.444 - 0.084 = 1.241 and was reduced to 0.527 - 0.384 - 0.028 = 0.115. WOW!

This is a nice example of why it is important to chose the right filesystem for the job.

To make the change permanent you want to add this line to /etc/fstab
/var/lib/dpkg.img       /var/lib/dpkg   reiserfs        defautls,noatime 
0       1

Credits go to Or Cohen for the idea. -- AvishaiIshShalom - 19 Feb 2010
Topic revision: r1 - 19 Feb 2010 - 07:43:31 - AvishaiIshShalom
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback