Implement multi-dispatch cache.

While selftest is dominated by startup time, this does shave around 8%
off the time to run it.
Update .gitignore.