puppetlabs/puppetdb — pull request #302 by nicklewis (2012-10-02 18:42:55+00:00)
Title: Add a bounded-memoize function for better memo performance

`memo-lru` has a lot of smarts in it that we don't need over `memoize`,
which introduces a significant performance penalty on cache misses.
However, we still want to prevent the cache from growing unbounded, so
we use a naive approach of simply clearing the cache if it exceeds the
limit, which should be rare. The cache size is 40k, which is more than
sufficient even for my database of 26k nodes.

This change reduced the amount of time taken to compute the initial set
of resource hashes from ~15 seconds to ~225ms. Once the cache is
populated, performance is fairly similar in each case. Populations with
significant resource churn should see a good increase in the performance
of catalog storage.