• Andres Freund's avatar
    Prevent growth of simplehash tables when they're "too empty". · ab9f2c42
    Andres Freund authored
    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
    d4c62a6b 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
    ab9f2c42
simplehash.h 25.4 KB