Tweak catalog cache management algorithms to reduce cost of
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 13 Aug 2005 22:18:07 +0000 (22:18 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 13 Aug 2005 22:18:07 +0000 (22:18 +0000)
commita1dea4d5a65e4b9239f2fbc34d75f8d5a6100e80
tree93b55b14e27434b4b216017bb11d07e069442807
parentb88fe5226c6c163ecd5daafda10a7dbda07b33fa
Tweak catalog cache management algorithms to reduce cost of
SearchCatCacheList and ReleaseCatCacheList.  Previously, we incremented
and decremented the refcounts of list member tuples along with the list
itself, but that's unnecessary, and very expensive when the list is big.
It's cheaper to change only the list refcount.  When we are considering
deleting a cache entry, we have to check not only its own refcount but
its parent list's ... but it's easy to arrange the code so that this
check is not made in any commonly-used paths, so the cost is really nil.
The bigger gain though is to refrain from DLMoveToFront'ing each individual
member tuple each time the list is referenced.  To keep some semblance
of fair space management, lists are just marked as used or not since the
last cache cleanout search, and we do a MoveToFront pass only when about
to run a cleanout.  In combination, these changes reduce the costs of
SearchCatCacheList and ReleaseCatCacheList from about 4.5% of pgbench
runtime to under 1%, according to my gprof results.
src/backend/utils/cache/catcache.c
src/include/utils/catcache.h