Blog of Julian Andres Klode

Debian, Ubuntu, Linux in general, and other free software

apt-show-versions rewrite in C++ (more than 10 times faster)

The script apt-show-versions is developed by another Debian Developer called Christoph Martin in Perl. Recently, it turned out that apt-show-versions is too slow for some users; so I decided to rewrite his program using APT’s C++ API. I expect this to be part of a future APT release, rendering the original apt-show-versions obsolete.

The rewrite is sadly not 100% backwards compatible to the original version; as some option names had to be renamed due to our command-line parser not supporting option names like -nh, and some other options were dropped because they are hard to support (like –status-file and –lists-dir) with our command-line parsing. I also decided not to keep the the -p and -r options, but use the standard APT command-line conventions insteads.

For now, it also cannot show you the distribution names you have specified in your sources.list file, but will always display codenames instead; if available. I hope to fix this in Jessie by extending APT’s cache format a bit.

On the performance side, this program now takes about 0.09s compared to the 1.40 seconds needed by apt-show-versions. The times are taken with all data in caches.

The current version can be found in a git repository, a link to gitweb is:

http://anonscm.debian.org/gitweb/?p=users/jak/apt-show-versions.git

Please also note that support for –allversions is not 100% implemented yet, but it should work for most uses.

Now, go testing and report back!

About these ads

Written by Julian Andres Klode

April 9, 2013 at 20:40

Posted in Debian

6 Responses

Subscribe to comments with RSS.

  1. [...] Andres Klode se rozhodl utilitu přepsat do C++, což vedlo ke stonásobnému zrychlení. Pravděpodobně se nová verze časem dostane i do [...]

  2. Wrong performance numbers?
    0.09s is about 15 times faster than 1.40 seconds, not 100 times faster.

    TK

    April 10, 2013 at 18:17

  3. How do I compile it ?

    ~/games/apt-show-versions$ make
    g++ -Wall -Wextra -pedantic -std=c++11 -O2 -g \
    -lapt-pkg -o apt-show-versions apt-show-versions.cc
    apt-show-versions.cc:26:26: fatal error: apt-pkg/init.h: No such file or directory
    #include
    ^
    compilation terminated.
    make: *** [apt-show-versions] Error 1

    shirishag75

    April 11, 2013 at 17:59

  4. Thanx did it. Would be monitoring the git repo.

    $ make
    g++ -Wall -Wextra -pedantic -std=c++11 -O2 -g \
    -lapt-pkg -o apt-show-versions apt-show-versions.cc

    s$ sudo make install
    [sudo] password for shirish:
    install -D -m755 -oroot -groot apt-show-versions /usr/bin/apt-show-versions

    $ apt-show-versions -a aptitude
    aptitude 0.6.9.1-1 install ok installed
    aptitude 0.6.3-3.2+squeeze1 stable http://ftp.debian.org
    aptitude 0.6.8.2-1 wheezy http://ftp.debian.org
    aptitude 0.6.8.2-1 unstable http://ftp.debian.org
    aptitude 0.6.9.1-1 experimental http://ftp.debian.org
    aptitude/experimental uptodate 0.6.9.1-1

    $ apt-show-versions -a apt-show-versions
    Not installed
    apt-show-versions 0.16+squeeze1 stable http://ftp.debian.org
    apt-show-versions 0.20 wheezy http://ftp.debian.org
    apt-show-versions 0.20 unstable http://ftp.debian.org
    No experimental version
    apt-show-versions not installed

    -a allversions seems to be work :)

    shirishag75

    April 11, 2013 at 21:42


Comments are closed.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: