Re: shared-memory based stats collector - v70 - Mailing list pgsql-hackers

From Andres Freund
Subject Re: shared-memory based stats collector - v70
Date
Msg-id 20220406162030.tx53ihaihonxh2jb@alap3.anarazel.de
Whole thread Raw
In response to Re: shared-memory based stats collector - v70  (John Naylor <john.naylor@enterprisedb.com>)
List pgsql-hackers
Hi,

On 2022-04-06 16:24:28 +0700, John Naylor wrote:
> On Wed, Apr 6, 2022 at 10:00 AM Andres Freund <andres@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



pgsql-hackers by date:

Previous
From: "Gunnar \"Nick\" Bluth"
Date:
Subject: Re: [PATCH] pg_stat_toast
Next
From: Robert Haas
Date:
Subject: Re: [PATCH] pg_stat_toast