pgsql: Rewrite the rbtree routines so that an RBNode is the first field

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rewrite the rbtree routines so that an RBNode is the first field
Date: 2010-08-01 02:12:51
Message-ID: 20100801021251.92CC57541D5@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Rewrite the rbtree routines so that an RBNode is the first field of the
struct representing a tree entry, rather than being a separately allocated
piece of storage. This API is at least as clean as the old one (if not
more so --- there were some bizarre choices in there) and it permits a
very substantial memory savings, on the order of 2X in ginbulk.c's usage.

Also, fix minor memory leaks in code called by ginEntryInsert, in
particular in ginInsertValue and entryFillRoot, as well as ginEntryInsert
itself. These leaks resulted in the GIN index build context continuing
to bloat even after we'd filled it to maintenance_work_mem and started
to dump data out to the index.

In combination these fixes restore the GIN index build code to honoring
the maintenance_work_mem limit about as well as it did in 8.4. Speed
seems on par with 8.4 too, maybe even a bit faster, for a non-pathological
case in which HEAD was formerly slower.

Back-patch to 9.0 so we don't have a performance regression from 8.4.

Tags:
----
REL9_0_STABLE

Modified Files:
--------------
pgsql/src/backend/access/gin:
ginbtree.c (r1.15 -> r1.15.6.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/gin/ginbtree.c?r1=1.15&r2=1.15.6.1)
ginbulk.c (r1.19 -> r1.19.4.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/gin/ginbulk.c?r1=1.19&r2=1.19.4.1)
ginentrypage.c (r1.24 -> r1.24.4.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/gin/ginentrypage.c?r1=1.24&r2=1.24.4.1)
ginfast.c (r1.7 -> r1.7.6.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/gin/ginfast.c?r1=1.7&r2=1.7.6.1)
gininsert.c (r1.26 -> r1.26.6.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/gin/gininsert.c?r1=1.26&r2=1.26.6.1)
pgsql/src/backend/utils/misc:
rbtree.c (r1.3 -> r1.3.4.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/misc/rbtree.c?r1=1.3&r2=1.3.4.1)
pgsql/src/include/access:
gin.h (r1.38.4.1 -> r1.38.4.2)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/access/gin.h?r1=1.38.4.1&r2=1.38.4.2)
pgsql/src/include/utils:
rbtree.h (r1.3 -> r1.3.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/rbtree.h?r1=1.3&r2=1.3.2.1)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2010-08-01 19:16:39 pgsql: Fix an additional set of problems in GIN's handling of lossy page
Previous Message Tom Lane 2010-08-01 02:12:42 pgsql: Rewrite the rbtree routines so that an RBNode is the first field