Изменения

Tdpkg

1606 байтов добавлено, 13:49, 17 июня 2013
м
Нет описания правки
= tdpkg =It’s surprising, but Debian package manager [http://en.wikipedia.org/wiki/Dpkg dpkg] stores its database in the form of a very big number of small files, located under <tt>/var/lib/dpkg/info</tt> directory, '''without any indexes'''! So, evidently it’s very slow in cold first runs, until all info files get into the filesystem cache.
The '''tdpkg''' shared library is an interesting solution to this problem — a wrapper library that’s used to speed up [http://en.wikipedia.org/wiki/Dpkg dpkg] *.list files loading using either [http://1978th.net/tokyocabinet/ tokyocabinet] or [http://www.sqlite.org sqlite3]. The larger your dpkg database is, the larger will be the speedup you notice.
It currently works for the [http://www.debian.org Debian GNU/Linux] system.
* Grab the sources (git master): https://gitorious.org/lethal-works/tdpkg/archive-tarball/master
* Source code repository: http://gitorious.org/lethal-works/tdpkg
* My mirror: https://github.com/vitalif/tdpkg
= build Build =
'''Requirements''': build-essential, libsqlite3-dev ''(for the sqlite3 backend)'' and libtokyocabinet-dev ''(for the tokyocabinet backend)''
Type <code>make CACHE=sqlite</code> instead for sqlite3 support.
'''Important''': Library is experimental, = How it could make your system highly unstable.works =
= usage =tdpkg is a simple wrapper library that intercepts file operations like open() and read() when put into LD_PRELOAD. Then it checks if the requested file is under <tt>/var/lib/dpkg/info</tt> and if its contents are already cached inside an indexed database (tokyocabinet or sqlite). If yes, then it returns data from the cache database instead of really reading it from the file.
My personal opinion is that all this indexing and caching stuff should be really implemented inside dpkg, but the advantage of a wrapper library like tdpkg is that everyone can use it, instead of just people who patch their dpkg. = Stability = Library is experimental, there is no warranty of any sort on it! In theory it could make your system, in particular, dpkg and apt-get, highly unstable. My usage experience for more than a year, though, tells that tdpkg almost never fails, and when it fails, it doesn’t make any corruption to real dpkg database. All the negative impact is a temporary inability to install some packages while using tdpkg. Such problems are always fixed by running apt-get with tdpkg temporarily disabled. = Usage = Please make a backup copy of your <tt>/var/lib/dpkg/info/ </tt> directory before using starting to use tdpkg.
Manual usage:
<pre>LD_PRELOAD=./libtdpkg.so dpkg ... </pre>
For system-wide usage use an alias put aliases into your <tt>~/.bashrc</tt> (make sure you use the absolute path to libtdpkg.so):
<pre>alias dpkg="LD_PRELOAD=/path/to/libtdpkg.so dpkg"
The cache for both sqlite3 and tokyocabinet is located at '''/var/lib/dpkg/info/tdpkg.cache'''.
= benchmarking Benchmarking =
The operations involved with dpkg database reading are mostly done on the file system. For this reason cleaning up the kernel cache is a must before calling either tdpkg or dpkg:
<pre>echo 1 > /proc/sys/vm/drop_caches</pre>