pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aleksander Alekseev <a.alekseev@postgrespro.ru>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Subject: Re: Patch: fix lock contention for HASHHDR.mutex
Date: Mon, 21 Mar 2016 11:48:15 +0300
Message-ID: <20160321114815.4cd8a089@fujitsu> (raw)
In-Reply-To: <CAA4eK1JqCM=squb1c1DiNL9rA=htv5Xb5rbgRRwUHXniWoLEHA@mail.gmail.com>
References: <CA+TgmoZKfuJog2MoZrmPsrVh4b8owruPU3+Nm_7bMgVcc8U3WQ@mail.gmail.com>
	<20160208192857.GA316589@alvherre.pgsql>
	<20160210112400.22c0b677@fujitsu>
	<CA+TgmoZm=Uowt8a_XaSfooGwufeeLJ861NTADiCEOpyFehV8Wg@mail.gmail.com>
	<20160211171101.33f34160@fujitsu>
	<CA+TgmoYnXqrf29Qia7HAeeTYYE6Tsz6St0mdkg3dLkx_8Uje2Q@mail.gmail.com>
	<CA+Tgmobtf9nH566_jjs=jrTyMq5HdQdaRF5j7o+AbdOWQHE_Ow@mail.gmail.com>
	<20160212183445.716b2845@fujitsu>
	<CAA4eK1+ORDtkbtis4NWMLOWzs6akKmpkA5ekMCyj5N0FYmOXQA@mail.gmail.com>
	<20160301174313.218e04c7@fujitsu>
	<CA+TgmoZkg-04rcNRURt=jAG0Cs5oPyB-qKxH4wqX09e-oXy-nw@mail.gmail.com>
	<CAA4eK1L-YXwDproVh8jv5z0Q8eJeuVST-zNC2XuJ=ctzSMOvsQ@mail.gmail.com>
	<CA+TgmoaEJLiUJhK2zKL2wVPwDe2m_v_=D4Lp2GpDrYGpWmUQnQ@mail.gmail.com>
	<CAA4eK1JE7Vzut3JSnU2fQLeYAxr5h=V6sGB6PL2ymtG3b6BtUA@mail.gmail.com>
	<CA+TgmoZ=fSf4TD=_pgHx+S1+Va2sExqdz=+YKKsba0ZjdLqHBg@mail.gmail.com>
	<CAA4eK1JqCM=squb1c1DiNL9rA=htv5Xb5rbgRRwUHXniWoLEHA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

> This is the point where I think I am missing something about patch.
> As far as I can understand, it uses the same freelist index
> (freelist_idx) for allocating and putting back the entry, so I think
> the chance of increment in one list and decrement in another is there
> when the value of freelist_idx is calculated differently for the same
> input, is it so, or there is something else in patch which I am
> missing?

You are right, nentries _can't_ be negative unless we are using getpid()
for calculating freelist_idx, since same index of nentries[] is used
when we add (increment) and remove (decrement) element from/to hash
table. The fact that we also borrow elements from other freelists if
there is no more elements in our freelist doesn't change anything.

> One idea is to jigger things so that we maintain a count of the total
> number of entries that doesn't change except when we allocate, and
> then for each freelist partition we maintain the number of entries in
> that freelist partition.  So then the size of the hash table, instead
> of being sum(nentries) is totalsize - sum(nfree).

This is an interesting idea. Still I strongly disagree that is should
be implemented in this concrete patch and discussed in this concrete
thread. Obviously such type of change deserves a separate research and
discussing since it has nothing to do with performance and since we
agreed that "change LOG2_NUM_LOCK_PARTITIONS value" and "change the
calling convention for ShmemInitHash()" patches should be implemented
separately. I added it to my TODO list.

Once again I suggest we merge this patch already:

http://www.postgresql.org/message-id/CA+Tgmobtf9nH566_jjs=jrTyMq5HdQdaRF5j7o+AbdOWQHE_Ow@mail.gmail....

I have a strong feeling that we are just wasting our time here.

-- 
Best regards,
Aleksander Alekseev
http://eax.me/


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (74+ messages)  latest in thread

Message-ID: <20160321114815.4cd8a089@fujitsu>
Permalink:  ../20160321114815.4cd8a089@fujitsu/
Also on:    postgresql.org/message-id/20160321114815.4cd8a089@fujitsu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: a.alekseev@postgrespro.ru, amit.kapila16@gmail.com, robertmhaas@gmail.com, a.lubennikova@postgrespro.ru
  Subject: Re: Patch: fix lock contention for HASHHDR.mutex
  In-Reply-To: <20160321114815.4cd8a089@fujitsu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox