Re: POC: Sharing record typmods between backends
Thomas Munro <thomas.munro@enterprisedb.com>
Attachments
- shared-record-typmod-registry-v3.patchset.tgz (application/x-gzip)
On Thu, Jun 1, 2017 at 6:29 AM, Andres Freund <andres@anarazel.de> wrote: > On May 31, 2017 11:28:18 AM PDT, Robert Haas <robertmhaas@gmail.com> wrote: >>> On 2017-05-31 13:27:28 -0400, Dilip Kumar wrote: [ ... various discussion in support of using DHT ... ] Ok, good. Here's a new version that introduces a per-session DSM segment to hold the shared record typmod registry (and maybe more things later). The per-session segment is created the first time you run a parallel query (though there is handling for failure to allocate that allows the parallel query to continue with no workers) and lives until your leader backend exits. When parallel workers start up, they see its handle in the per-query segment and attach to it, which puts typcache.c into write-through cache mode so their idea of record typmods stays in sync with the leader (and each other). I also noticed that I could delete even more of tqueue.c than before: it doesn't seem to have any remaining reason to need to know the TupleDesc. One way to test this code is to apply just 0003-rip-out-tqueue-remapping-v3.patch and then try the example from the first message in this thread to see it break, and then try again with the other two patches applied. By adding debugging trace you can see that the worker pushes a bunch of TupleDescs into shmem, they get pulled out by the leader when it sees the tuples, and then on a second invocation the (new) worker can reuse them: it finds matches already in shmem from the first invocation. I used a DSM segment with a TOC and a DSA area inside that, like the existing per-query DSM segment, but obviously you could spin it various different ways. One example: just have a DSA area and make a new kind of TOC thing that deals in dsa_pointers. Better ideas? I believe combo CIDs should also go in there, to enable parallel write, but I'm not 100% sure: that's neither per-session nor per-query data, that's per-transaction. So perhaps the per-session DSM could hold a per-session DSA and a per-transaction DSA, where the latter is reset for each transaction, just like TopTransactionContext (though dsa.c doesn't have a 'reset thyself' function currently). That seems like a good place to store a shared combo CID hash table using DHT. Thoughts? -- Thomas Munro http://www.enterprisedb.com
Commits
-
Remove TupleDesc remapping logic from tqueue.c.
- 6b65a7fe62e1 11.0 landed
-
Add support for coordinating record typmods among parallel workers.
- cc5f81366c36 11.0 landed
-
Improve division of labor between execParallel.c and nodeGather[Merge].c.
- 51daa7bdb39e 11.0 cited
-
Add minimal regression test for blessed record type transfer.
- d36f7efb39e1 11.0 landed
-
Consolidate the function pointer types used by dshash.c.
- d7694fc14870 11.0 landed
-
Fix unlikely shared memory leak after failure in dshash_create().
- 4569715bd6fa 11.0 landed
-
Refactor typcache.c's record typmod hash table.
- 35ea75632a56 11.0 landed
-
Add a hash_combine function for mixing hash values.
- 0052a0243d9c 11.0 landed
-
Backpatch introduction of TupleDescAttr(tupdesc, i).
- 8cda1fadd25b 9.2.23 landed
- 5b286cae3cc1 9.3.19 landed
- 3d58994eccb7 9.4.14 landed
- d778a77d38be 9.5.9 landed
- 6c036d01089c 9.6.5 landed
- d34a74dd064a 10.0 landed
-
Partially flatten struct tupleDesc so that it can be used in DSM.
- c6293249dc17 11.0 landed
-
Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n).
- 2cd708452400 11.0 landed