Skip to content

Instantly share code, notes, and snippets.

@4poc
Created March 9, 2011 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 4poc/861799 to your computer and use it in GitHub Desktop.
Save 4poc/861799 to your computer and use it in GitHub Desktop.
Slow Pacman Workaround(< 3.5!!!)
This is obsolete with the new pacman version 3.5!
Pacman (arch linux) uses a file based database with a lot
of small files. Some filesystems are awfully slow when
accessing lots of small files, in general this is not
that great of a deal because most of the applications
store their information with more sense. Pacman doesn't
care (it is a long well known problem), which means that
sometimes you have to wait minutes before a search query
completes (pacman -Ss).
# strace pacman -Ss rails 2> pacman_sS_rails.log
community/vim-rails 4.3-2
A Vim plugin for enhanced Ruby on Rails application development
# egrep '^open\(' pacman_sS_rails.log | wc
10259
This script creates a loopfs with reiserfs (the best fs
for many small files) and copies the pacman "db" into it.
#!/bin/bash
# new pacman versions are fast without this (< 3.5!!!)
# stop: umount /var/lib/pacman; losetup -d /dev/loop0
DATA="/var/lib/pacman"
VDISK="/var/lib/pacman.loopfs"
LOOP_DEV="/dev/loop0"
# create the loopfs
if [ ! -f $VDISK ];
then
echo "Create loopfs!"
dd if=/dev/zero of=$VDISK bs=1024 count=524288
losetup $LOOP_DEV $VDISK
mkfs.reiserfs $LOOP_DEV
else
echo "Start loopfs"
losetup $LOOP_DEV $VDISK
fi
# move the pacman directory to _backup if not already done
if [ ! -d "${DATA}_backup" ]; then
mv ${DATA} ${DATA}_backup
mkdir ${DATA}
fi
# mount loopfs
mount -o noatime $LOOP_DEV ${DATA}
# copy the files from the backup if not already done
if [ ! -d "${DATA}/local" ]; then
echo "Copy backup to loopfs mount"
cp -aux ${DATA}_backup/* ${DATA}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment