Powered By

Powered by Blogger

Selasa, 16 Maret 2010

Speed Up DPKG With TDPKG (Using A Tokyocabinet Or Sqlite3 Database) [ Ubuntu / Debian ]

dpkg is pretty slow in Debian-based systems, usually because of the many files which are stored in the /var/lib/dpkg/info folder. To speed up things, Luca Bruno created a project called tdpkg which uses an sqlite3 or tokyocabinet database for loading the dpkg .list files in the /var/lib/dpkg/info folder which makes dpkg a lot faster.

The author (Luca Bruno) says that:

I've managed to bring cold startup time from about 14 seconds down to about 2 seconds. I will definitely have fun installing and removing applications back again.


Before installing this, the author clearly states that: "You'd better not install this library, it could make your system highly unstable". However I've made a backup and have been using it for a while and everything works great so if you also want to install it anyway, here's what you need to do!


1. Backup the /var/lib/dpkg/info/ folder. I've copied the entire folder in an info.backup folder in my home directory so you can do the same:
cp -r /var/lib/dpkg/info ~/info.backup


2. Download the tdpkg package and install build-essential and one of the 2: libsqlite3-dev (for the sqlite3 backend) and libtokyocabinet-dev (for libtokyocabinet). I've installed both of them to try out each one.

sudo apt-get install build-essential libsqlite3-dev libtokyocabinet-dev
git clone http://git.gitorious.org/lethal-works/tdpkg.git



3. Compile tdpkg

Compiling tdpkg is very easy. However, decide if you want to compile it with sqlite3 or libtokyocabinet. tokyocabinet is faster and sqlite handles concurrency better.

For sqlite3:
cd tdpkg/
make CACHE=sqlite


For libtokyocabinet:
cd tdpkg/
make


4. Now to get it working, you must create a simple alias in your .bashrc file. To edit the .bashrc file, enter this in a terminal:
gedit ~/.bashrc


And at the end of the file, enter this:
alias dpkg="LD_PRELOAD=/path/to/tdpkg/libtdpkg.so /usr/bin/dpkg"


Of course, replacing "/path/to/" with the path to the tdpkg/libtdpkg.so file (make sure you use the absolute path to libtdpkg.so). If you used the exact commands in this post, the file should be in: /home/YOUR_USERNAME/tdpkg/libtdpkg.so

Now save the file and reload the .bashrc file using this command:
cd && source .bashrc

That's it!


If dpkg doesn't pick up the alias, you can put the alias in the /etc/bash.bashrc file and then run "bash" in a terminal to reload it.


An amazing thing would be to use this with apt-fast to make an incredibly fast package manager for Debian based systems but I can't seem to get tdpkg to work with apt-get in the first place. If you manage to do this, let us know in the comments!


Via OssBlog.it and Luca Bruno's website.

Tidak ada komentar:

Posting Komentar