Skip site navigation (1) Skip section navigation (2)

pgsql: Tweak catalog cache management algorithms to reduce cost of

From: tgl(at)svr1(dot)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Tweak catalog cache management algorithms to reduce cost of
Date: 2005-08-13 22:18:08
Message-ID: 20050813221808.649E6529F5@svr1.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
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.

Modified Files:
--------------
    pgsql/src/backend/utils/cache:
        catcache.c (r1.122 -> r1.123)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/cache/catcache.c.diff?r1=1.122&r2=1.123)
    pgsql/src/include/utils:
        catcache.h (r1.54 -> r1.55)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/catcache.h.diff?r1=1.54&r2=1.55)

pgsql-committers by date

Next:From: Tom LaneDate: 2005-08-14 18:49:31
Subject: pgsql: Fix up tab completion for ROLEs and add some more completion
Previous:From: Tom LaneDate: 2005-08-13 19:02:35
Subject: pgsql: Make pg_stat_file() use OUT parameters so that the user doesn't

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group