Comment fix and question about dshash.c

From: Antonin Houska <ah(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Comment fix and question about dshash.c
Date: 2018-10-26 11:32:01
Message-ID: 8726.1540553521@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

1. The return type of resize() function is void, so I propose part of the
header comment to be removed:

diff --git a/src/backend/lib/dshash.c b/src/backend/lib/dshash.c
index b46f7c4cfd..b2b8fe60e1 100644
--- a/src/backend/lib/dshash.c
+++ b/src/backend/lib/dshash.c
@@ -672,9 +672,7 @@ delete_item(dshash_table *hash_table, dshash_table_item *item)

/*
* Grow the hash table if necessary to the requested number of buckets. The
- * requested size must be double some previously observed size. Returns true
- * if the table was successfully expanded or found to be big enough already
- * (because another backend expanded it).
+ * requested size must be double some previously observed size.
*
* Must be called without any partition lock held.
*/

2. Can anyone please explain this macro?

/* Max entries before we need to grow. Half + quarter = 75% load factor. */
#define MAX_COUNT_PER_PARTITION(hash_table) \
(BUCKETS_PER_PARTITION(hash_table->size_log2) / 2 + \
BUCKETS_PER_PARTITION(hash_table->size_log2) / 4)

I'm failing to understand why the maximum number of hash table entries in a
partition should be smaller than the number of buckets in that partition.

The fact that MAX_COUNT_PER_PARTITION refers to entries and not buckets is
obvious from this condition in dshash_find_or_insert()

/* Check if we are getting too full. */
if (partition->count > MAX_COUNT_PER_PARTITION(hash_table))

--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-10-26 12:08:13 Re: [PATCH] Tab complete EXECUTE FUNCTION for CREATE (EVENT) TRIGGER
Previous Message Haribabu Kommi 2018-10-26 11:24:56 Re: Pluggable Storage - Andres's take