Comment fix and question about dshash.c - Mailing list pgsql-hackers

From Antonin Houska
Subject Comment fix and question about dshash.c
Date
Msg-id 8726.1540553521@localhost
Whole thread Raw
Responses Re: Comment fix and question about dshash.c  (Thomas Munro <thomas.munro@enterprisedb.com>)
List 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


pgsql-hackers by date:

Previous
From: Haribabu Kommi
Date:
Subject: Re: Pluggable Storage - Andres's take
Next
From: Michael Paquier
Date:
Subject: Re: [PATCH] Tab complete EXECUTE FUNCTION for CREATE (EVENT) TRIGGER