Re: pgsql: Optimize pglz compressor for small inputs.

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pgsql: Optimize pglz compressor for small inputs.
Date: 2013-07-14 17:12:12
Message-ID: 20130714171212.GD2511@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Heikki,

* Heikki Linnakangas (heikki(dot)linnakangas(at)iki(dot)fi) wrote:
> 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.

The coverity scanner has a bit of an issue with this patch which, at
least on first blush, looks like a valid concern.

While the change in pg_lzcompress.c:pglz_find_match() to loop on:

while (hent != INVALID_ENTRY_PTR)
{
const char *ip = input;
const char *hp = hent->pos;

looks good, and INVALID_ENTRY_PTR is the address of the first entry in
the array (and can't be NULL), towards the end of the loop we do:

hent = hent->next;
if (hent)
...

Should we really be checking for 'hent != INVALID_ENTRY_PTR' here? If
not, and hent really can end up as NULL, then we're going to segfault
on the next loop due to the unchecked 'hent->pos' early in the loop.
If hent can never be NULL, then we probably don't need this check at
all.

Thanks,

Stephen

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Stephen Frost 2013-07-14 18:40:03 pgsql: During parallel pg_dump, free commands from master
Previous Message Peter Eisentraut 2013-07-13 01:27:36 pgsql: Add session_preload_libraries configuration parameter

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2013-07-14 17:55:43 Re: [PATCH] pgbench --throttle (submission 7 - with lag measurement)
Previous Message Atri Sharma 2013-07-14 16:58:31 Re: Removing Inner Joins