• Heikki Linnakangas's avatar
    Optimize pglz compressor for small inputs. · 031cc55b
    Heikki Linnakangas authored
    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.
    031cc55b
pg_lzcompress.c 22.1 KB