RE: [PATCH] Resolve Parallel Hash Join Performance Issue - Mailing list pgsql-hackers

From Deng, Gang
Subject RE: [PATCH] Resolve Parallel Hash Join Performance Issue
Date
Msg-id 0F44E799048C4849BAE4B91012DB910462E991B3@SHSMSX103.ccr.corp.intel.com
Whole thread Raw
In response to Re: [PATCH] Resolve Parallel Hash Join Performance Issue  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Regarding to the reason of setting bit was not cheap anymore in parallel join. As I explain in my original mail, it is
because'false sharing cache coherence'. In short word, setting of the bit will cause the whole cache line (64 bytes)
dirty.So that all CPU cores contain the cache line have to load it again, which will waste much cpu time. Article
https://software.intel.com/en-us/articles/avoiding-and-identifying-false-sharing-among-threadsexplain more detail. 

-----Original Message-----
From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Thursday, January 9, 2020 10:43 PM
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Deng, Gang <gang.deng@intel.com>; pgsql-hackers@postgresql.org
Subject: Re: [PATCH] Resolve Parallel Hash Join Performance Issue

Thomas Munro <thomas.munro@gmail.com> writes:
> Right, I see.  The funny thing is that the match bit is not even used
> in this query (it's used for right and full hash join, and those
> aren't supported for parallel joins yet).  Hmm.  So, instead of the
> test you proposed, an alternative would be to use if (!parallel).
> That's a value that will be constant-folded, so that there will be no
> branch in the generated code (see the pg_attribute_always_inline
> trick).  If, in a future release, we need the match bit for parallel
> hash join because we add parallel right/full hash join support, we
> could do it the way you showed, but only if it's one of those join
> types, using another constant parameter.

Can we base the test off the match type today, and avoid leaving something that will need to be fixed later?

I'm pretty sure that the existing coding is my fault, and that it's like that because I reasoned that setting the bit
wastoo cheap to justify having a test-and-branch around it.  Apparently that's not true anymore in a parallel join, but
Ihave to say that it's unclear why.  In any case, the reasoning probably still holds good in non-parallel cases, so
it'dbe a shame to introduce a run-time test if we can avoid it. 

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgbench - use pg logging capabilities
Next
From: David Steele
Date:
Subject: Re: backup manifests