Re: Patch: fix lock contention for HASHHDR.mutex

From: Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch: fix lock contention for HASHHDR.mutex
Date: 2016-01-21 14:03:34
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

30.12.2015 16:01, Aleksander Alekseev:
> Here is a clean version of the patch. Step 1 is an optimization. Step 2
> refactors this:
> HTAB *
> ShmemInitHash(const char *name, /* table string name for shmem index */
> - long init_size, /* initial table size */
> + long init_size, /* initial table size XXX ignored,
> refactor! */

Hi, I found that the patch is still not reviewed, so I've looked it over.
I haven't dived into this subject before, so my comments will be more
general than relating to your investigation.
Sorry if some things seem like nitpicks, I just suppose that clear patch
would be more convenient for reviewers.

First of all, why not merge both patches into one? They aren't too big
Then, this thread became too tangled. I think it's worth to write a new
message with the patch, the test script, some results and brief overview
of how does it really works. It will make following review much easier.

+ /* number of entries in hash table */
+ long nentries[NUM_LOCK_PARTITIONS];
+ /* linked list of free elements */

I think comments should be changed, to be more informative here.

+ if (IS_PARTITIONED(hashp->hctl))
+ partitions_number = NUM_LOCK_PARTITIONS;
+ else
+ partitions_number = 1;
+ nelem_alloc = ((int) nelem) / partitions_number;
+ if (nelem_alloc == 0)
+ nelem_alloc = 1;

Add a comment here too.

-/* Number of partitions of the shared buffer mapping hashtable */
/* Number of partitions the shared lock tables are divided into */

+/* Number of partitions of the shared buffer mapping hashtable */

I'm sure, it was discussed above. but these definitions do not look
obvious at all.
Maybe you should explain this magic number 7 in the comment above?

Anastasia Lubennikova
Postgres Professional:
The Russian Postgres Company

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-01-21 14:25:39 Re: Inconsistent error handling in START_REPLICATION command
Previous Message Ashutosh Bapat 2016-01-21 13:48:23 Re: postgres_fdw join pushdown (was Re: Custom/Foreign-Join-APIs)