Hi,

On 2022-04-06 16:24:28 +0700, John Naylor wrote:
> On Wed, Apr 6, 2022 at 10:00 AM Andres Freund <and...@anarazel.de> wrote:
> > - while working on the above point, I noticed that hash_bytes() showed up
> >   noticeably in profiles, so I replaced it with a fixed-width function
> 
> I'm curious about this -- could you direct me to which patch introduces this?

Commit 0010, search for pgstat_hash_key_hash. For simplicity I'm including it
here inline:

/* helpers for dshash / simplehash hashtables */
static inline int
pgstat_hash_key_cmp(const void *a, const void *b, size_t size, void *arg)
{
        AssertArg(size == sizeof(PgStat_HashKey) && arg == NULL);
        return memcmp(a, b, sizeof(PgStat_HashKey));
}

static inline uint32
pgstat_hash_key_hash(const void *d, size_t size, void *arg)
{
        const PgStat_HashKey *key = (PgStat_HashKey *)d;
        uint32 hash;

        AssertArg(size == sizeof(PgStat_HashKey) && arg == NULL);

        hash = murmurhash32(key->kind);
        hash = hash_combine(hash, murmurhash32(key->dboid));
        hash = hash_combine(hash, murmurhash32(key->objoid));

        return hash;
}

Greetings,

Andres Freund


Reply via email to