Re: Parallel Full Hash Join
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Ian Lawrence Barwick <barwick@gmail.com>
Cc: Melanie Plageman <melanieplageman@gmail.com>,
Justin Pryzby <pryzby@telsasoft.com>, vignesh C <vignesh21@gmail.com>, Greg Nancarrow <gregn4422@gmail.com>, Masahiko Sawada <sawada.mshk@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-03-24T20:21:34Z
Lists: pgsql-hackers
Attachments
- v12-0001-Scan-for-unmatched-hash-join-tuples-in-memory-or.patch (text/x-patch) patch v12-0001
- v12-0002-Parallel-Hash-Full-Join.patch (text/x-patch) patch v12-0002
Here is a rebased and lightly hacked-upon version that I'm testing.
0001-Scan-for-unmatched-hash-join-tuples-in-memory-order.patch
* this change can stand on its own, separately from any PHJ changes
* renamed hashtable->current_chunk[_idx] to unmatched_scan_{chunk,idx}
* introduced a local variable to avoid some x->y->z stuff
* removed some references to no-longer-relevant hj_XXX variables in
the Prep function
I haven't attempted to prove anything about the performance of this
one yet, but it seems fairly obvious that it can't be worse than what
we're doing today. I have suppressed the urge to look into improving
locality and software prefetching.
0002-Parallel-Hash-Full-Join.patch
* reuse the same umatched_scan_{chunk,idx} variables as above
* rename the list of chunks to scan to work_queue
* fix race/memory leak if we see PHJ_BATCH_SCAN when we attach (it
wasn't OK to just fall through)
That "work queue" name/concept already exists in other places that
need to process every chunk, namely rebucketing and repartitioning.
In later work, I'd like to harmonise these work queues, but I'm not
trying to increase the size of this patch set at this time, I just
want to use consistent naming.
I don't love the way that both ExecHashTableDetachBatch() and
ExecParallelPrepHashTableForUnmatched() duplicate logic relating to
the _SCAN/_FREE protocol, but I'm struggling to find a better idea.
Perhaps I just need more coffee.
I think your idea of opportunistically joining the scan if it's
already running makes sense to explore for a later step, ie to make
multi-batch PHFJ fully fair, and I think that should be a fairly easy
code change, and I put in some comments where changes would be needed.
Continuing to test, more soon.
Commits
-
Remove overzealous assertion from PHJ.
- b37d051b0e59 16.0 landed
-
Remove comment obsoleted by 11c2d6fd.
- f303ec6210c4 16.0 landed
-
Parallel Hash Full Join.
- 11c2d6fdf5af 16.0 landed
-
Improve the naming of Parallel Hash Join phases.
- 8fba928fd788 16.0 landed
-
Update the names of Parallel Hash Join phases.
- 378802e3713c 14.0 landed
-
Add BarrierArriveAndDetachExceptLast().
- 7888b0999488 14.0 landed
-
Mop-up for wait event naming issues.
- 3048898e73c7 13.0 cited
-
Push tuple limits through Gather and Gather Merge.
- 3452dc5240da 11.0 cited