[pacman-dev] [RFC] pactree rewrite in C

Dave Reisner d at falconindy.com
Mon Oct 11 09:06:41 EDT 2010

The recent patchwork over the weekend inspired me to take a closer look
at pactree. My first impression was that it would be a great candidate
for a rewrite in C.


Results are entertaining:

# bash version
$ time pactree -r glib2 >/dev/null

real    0m2.538s
user    0m1.593s
sys     0m0.435s

# C rewrite
$ time ./pactree -r glib2 >/dev/null

real    0m0.016s
user    0m0.007s
sys     0m0.009s

I'm finding that it's even slightly more accurate than the bash version
WRT to reverse dependency tracking as it's hooking into alpm's
alpm_pkg_compute_required_by() instead of wandering through the file

It's feature complete compared to the Bash version, aside from the
export to graphviz. The only functional change I've made is: when
walking reverse depends, don't re-walk already visited dependencies. I
thought this was a logical change given the behavior of the standard
dependency tracking.

I'm happy to offer this up for merging if desirable. There's a few ugly
bits in the code I still want to refactor -- if anyone has any comments
or criticisms, they're very welcome.


More information about the pacman-dev mailing list