v7-0005-Demonstrate-fasthash32-with-pgstat_hash_hash_key.patch
text/x-patch
Filename: v7-0005-Demonstrate-fasthash32-with-pgstat_hash_hash_key.patch
Type: text/x-patch
Part: 6
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 v7-0005
Subject: Demonstrate fasthash32 with pgstat_hash_hash_key
| File | + | − |
|---|---|---|
| src/include/utils/pgstat_internal.h | 2 | 7 |
From 60dee25ccb0c904904bb057aa7c7adc8998a9cf0 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 v7 05/13] Demonstrate fasthash32 with pgstat_hash_hash_key
Currently this calls the 32-bit Murmur finalizer on the
three elements, joined with hash_combine().
This is simpler, has better tested behavior, and probably shaves
a few cycles and some binary space.
Note: We may not need the full 32-bit finalizer reducing step.
It would be slightly cheaper to just use fasthash64 and
then take the lower 32 bits.
---
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 60fbf9394b..df310efee1 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 unsigned char *) key, size, 0);
}
/*
--
2.43.0