]> granicus.if.org Git - postgresql/commit
Prevent growth of simplehash tables when they're "too empty".
authorAndres Freund <andres@anarazel.de>
Mon, 29 Jan 2018 19:02:09 +0000 (11:02 -0800)
committerAndres Freund <andres@anarazel.de>
Mon, 29 Jan 2018 19:24:57 +0000 (11:24 -0800)
commitab9f2c429d8fbd3580cd2ae5f2054ba6956b1f60
treeb75c0239b09ce35238ffb00b3533d8f4171add30
parentc068f87723ca9cded1f2aceb956ede49de651690
Prevent growth of simplehash tables when they're "too empty".

In cases where simplehash tables where filled with either a lot of
conflicting hash-values, or values that hash to consecutive
values (i.e. build "chains") the growth heuristics in
d4c62a6b623d6eef88218158e9fa3cf974c6c7e5 could trigger rather
explosively.

To fix that, address some of the reasons (see previous commit) of why
the growth heuristics where needed, and only allow growth when the
table isn't too empty. While that means there's a few cases of bad
input that can be slower, that seems a lot better than running very
quickly out of memory.

Author: Tomas Vondra and Andres Freund, with additional input by
    Thomas Munro, Tom Lane Todd A. Cook
Reported-By: Todd A. Cook, Tomas Vondra, Thomas Munro
Discussion: https://postgr.es/m/20171127185700.1470.20362@wrigleys.postgresql.org
Backpatch: 10, where simplehash was introduced
src/include/lib/simplehash.h