pgsql: Optimize pglz compressor for small inputs.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Optimize pglz compressor for small inputs.
Date: 2013-07-01 08:01:26
Message-ID: E1UtZ38-0006xD-AF@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Optimize pglz compressor for small inputs.

The pglz compressor has a significant startup cost, because it has to
initialize to zeros the history-tracking hash table. On a 64-bit system, the
hash table was 64kB in size. While clearing memory is pretty fast, for very
short inputs the relative cost of that was quite large.

This patch alleviates that in two ways. First, instead of storing pointers
in the hash table, store 16-bit indexes into the hist_entries array. That
slashes the size of the hash table to 1/2 or 1/4 of the original, depending
on the pointer width. Secondly, adjust the size of the hash table based on
input size. For very small inputs, you don't need a large hash table to
avoid collisions.

Review by Amit Kapila.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/031cc55bbea6b3a6b67c700498a78fb1d4399476

Modified Files
--------------
src/backend/utils/adt/pg_lzcompress.c | 95 +++++++++++++++++++++++----------
1 file changed, 66 insertions(+), 29 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2013-07-01 16:40:44 pgsql: Remove undocumented -h (help) option
Previous Message Heikki Linnakangas 2013-07-01 06:37:56 pgsql: Retry short writes when flushing WAL.

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-07-01 08:05:37 Re: Optimizing pglz compressor
Previous Message Pavel Stehule 2013-07-01 07:47:46 Re: proposal: simple date constructor from numeric values