v13-0002-Use-fasthash-for-pgstat_hash_hash_key.patch
text/x-patch
Filename: v13-0002-Use-fasthash-for-pgstat_hash_hash_key.patch
Type: text/x-patch
Part: 3
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v13-0002
Subject: Use fasthash for pgstat_hash_hash_key
| File | + | − |
|---|---|---|
| src/include/utils/pgstat_internal.h | 2 | 7 |
From ada0dcec91474e2c89afd79e6c9c35eeae88d875 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sat, 9 Dec 2023 16:24:56 +0700
Subject: [PATCH v13 2/6] Use fasthash for pgstat_hash_hash_key
Previously this called the 32-bit Murmur finalizer on the three elements,
then joined with hash_combine(). Fasthash is simpler, executes faster
and takes up less binary space. While the collision and bias behavior
were almost certainly fine with the previous coding, now we have
measurements to prove it.
Discussion:
---
src/include/utils/pgstat_internal.h | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/src/include/utils/pgstat_internal.h b/src/include/utils/pgstat_internal.h
index 9862589f36..bbbb35bcd8 100644
--- a/src/include/utils/pgstat_internal.h
+++ b/src/include/utils/pgstat_internal.h
@@ -14,7 +14,7 @@
#define PGSTAT_INTERNAL_H
-#include "common/hashfn.h"
+#include "common/hashfn_unstable.h"
#include "lib/dshash.h"
#include "lib/ilist.h"
#include "pgstat.h"
@@ -777,15 +777,10 @@ static inline uint32
pgstat_hash_hash_key(const void *d, size_t size, void *arg)
{
const PgStat_HashKey *key = (PgStat_HashKey *) d;
- uint32 hash;
Assert(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;
+ return fasthash32((const char *) key, size, 0);
}
/*
--
2.43.0