pacdiff: Only include relevant packages in unified cache index
pacdiff: Only include relevant packages in unified cache index

The commit message for b71d3a0085fe366a8ef37add07ad0a0ae47fc879 stated that
symlinking all cached packages into a single directory only takes a few
milliseconds on my machine, which is true (to be precise, it takes no longer
than a couple hundred), but *only once the disk cache has warmed up*. With a
cold cache, a benchmark (done with the hyperfine tool, and with one `.pacnew`
file for an official package and one for an AUR package) shows that it actually
takes around 8-9 seconds for pacdiff's interactive menu to be displayed after my
wrapper script is launched. Note that this isn't just the time taken to find and
symlink cached packages, because the pacdiff tool itself (which the wrapper
script then calls) doesn't start up instantly from a cold cache, either, but
benchmarking (in the same conditions as the wrapper script) shows that its
startup time is 2.5 seconds, meaning that at least 5.5 seconds are spent
symlinking (or more, if pacdiff benefits in any way from the cache warmup
provided by the wrapper).

Considering that I almost never use pacdiff multiple times in a row (excluding
`pacdiff -o`), cold cache performance is what actually matters. Therefore, I
decided to optimize it by only finding and symlinking cached packages for which
`.pac*` files currently exist. Figuring out which packages these are requires an
extra `pacdiff -o` invocation, is pretty much entirely a duplicate of the work
that pacdiff already does to find `.pac*` files and their merge bases, and
worsens warm cache performance (increasing startup time from roughly 130 ms to
roughly 250 ms), but all of this is more than justified by a significant cold
cache performance improvement: the benchmark run that compared the two
implementations (done in the same conditions as the previously mentioned
benchmarks) showed a decrease in startup time from 8.6±2.1 seconds to 3.3±0.1
seconds, meaning that the new implementation is approximately 2.6±0.7 times
faster.

razzolini/dotfiles,razzolini/dotfiles,razzolini/dotfiles