Re: BitmapHeapScan streaming read user and prelim refactoring
Melanie Plageman <melanieplageman@gmail.com>
Attachments
- v22-0005-BitmapHeapScan-initialize-some-prefetch-state-el.patch (text/x-patch) patch v22-0005
- v22-0002-Remove-table_scan_bitmap_next_tuple-parameter-tb.patch (text/x-patch) patch v22-0002
- v22-0003-Make-table_scan_bitmap_next_block-async-friendly.patch (text/x-patch) patch v22-0003
- v22-0001-table_scan_bitmap_next_block-counts-lossy-and-ex.patch (text/x-patch) patch v22-0001
- v22-0004-Add-common-interface-for-TBMIterators.patch (text/x-patch) patch v22-0004
- v22-0006-BitmapHeapScan-uses-unified-iterator.patch (text/x-patch) patch v22-0006
- v22-0007-BitmapHeapScan-Make-prefetch-sync-error-more-det.patch (text/x-patch) patch v22-0007
- v22-0008-Push-current-scan-descriptor-into-specialized-sc.patch (text/x-patch) patch v22-0008
- v22-0009-Remove-ss_current-prefix-from-ss_currentScanDesc.patch (text/x-patch) patch v22-0009
- v22-0010-Add-scan_in_progress-to-BitmapHeapScanState.patch (text/x-patch) patch v22-0010
- v22-0012-Update-variable-names-in-bitmap-scan-descriptors.patch (text/x-patch) patch v22-0012
- v22-0011-Make-new-bitmap-table-scan-and-bitmap-heap-scan-.patch (text/x-patch) patch v22-0011
- v22-0013-BitmapHeapScan-lift-and-shift-prefetch-functions.patch (text/x-patch) patch v22-0013
- v22-0014-BitmapHeapScan-Push-prefetch-code-into-heap-AM.patch (text/x-patch) patch v22-0014
- v22-0015-BitmapHeapScan-move-per-scan-setup-into-a-helper.patch (text/x-patch) patch v22-0015
- v22-0016-Remove-table-AM-callback-scan_bitmap_next_block.patch (text/x-patch) patch v22-0016
- v22-0018-Separate-TBMIterator-and-TBMIterateResult.patch (text/x-patch) patch v22-0018
- v22-0017-Hard-code-TBMIterateResult-offsets-array-size.patch (text/x-patch) patch v22-0017
- v22-0019-Use-streaming-I-O-in-Bitmap-Heap-Scans.patch (text/x-patch) patch v22-0019
On Fri, Jun 14, 2024 at 7:56 PM Melanie Plageman <melanieplageman@gmail.com> wrote: > > Attached v21 is the rest of the patches to make bitmap heap scan use > the read stream API. ---snip--- > The one relic of iterator ownership is that for parallel bitmap heap > scan, a single process must scan the index, construct the bitmap, and > call tbm_prepare_shared_iterate() to set up the iterator for all the > processes. I didn't see a way to push this down (because to build the > bitmap we have to scan the index and call ExecProcNode()). I wonder if > this creates an odd split of responsibilities. I could use some other > synchronization mechanism to communicate which process built the > bitmap in the generic bitmap table scan code and thus should set up > the iterator in the heap implementation, but that sounds like a pretty > bad idea. Also, I'm not sure how a non-block-based table AM would use > TBMIterators (or even TIDBitmap) anyway. I tinkered around with this some more and actually came up with a solution to my primary concern with the code structure. Attached is v22. It still needs the performance regression investigation mentioned in my previous email, but I feel more confident in the layering of the iterator ownership I ended up with. Because the patch numbers have changed, below is a summary of the contents with the new patch numbers: Patches 0001-0003 implement the async-friendly behavior needed both to push down the VM lookups for prefetching and eventually to use the read stream API. Patches 0004-0006 add and make use of a common interface for the shared and private bitmap iterators per Heikki's suggestion in [1]. Patches 0008 - 0012 make new scan descriptors for bitmap table scans and the heap AM implementation. 0013 and 0014 push all of the prefetch code down into heap AM code as suggested by Heikki in [1]. 0016 removes scan_bitmap_next_block() per Heikki's suggestion in [1]. Patches 0017 and 0018 make some changes to the TIDBitmap API to support having multiple TBMIterateResults at the same time instead of reusing the same one when iterating. 0019 uses the read stream API and removes all the bespoke prefetching code from bitmap heap scan. - Melanie [1] https://www.postgresql.org/message-id/5a172d1e-d69c-409a-b1fa-6521214c81c2%40iki.fi
Commits
-
Fix bitmapheapscan incorrect recheck of NULL tuples
- aea916fe555a 18.0 landed
-
Increase default maintenance_io_concurrency to 16
- cc6be07ebde2 18.0 landed
-
Separate TBM[Shared|Private]Iterator and TBMIterateResult
- 944e81bf99db 18.0 landed
-
Improve read_stream.c advice for dense streams.
- 7ea8cd15661e 18.0 landed
-
Increase default effective_io_concurrency to 16
- ff79b5b2aba0 18.0 landed
-
Delay extraction of TIDBitmap per page offsets
- bfe56cdf9a4e 18.0 landed
-
Add lossy indicator to TBMIterateResult
- b8778c4cd8bc 18.0 landed
-
Move BitmapTableScan per-scan setup into a helper
- a5358c14b2fe 18.0 landed
-
Add and use BitmapHeapScanDescData struct
- f7a8fc10ccb8 18.0 landed
-
Fix bitmap table scan crash on iterator release
- 754c610e13b8 18.0 landed
-
Bitmap Table Scans use unified TBMIterator
- 1a0da347a7ac 18.0 landed
-
Add common interface for TBMIterators
- 7f9d4187e7ba 18.0 landed
-
Make table_scan_bitmap_next_block() async-friendly
- de380a62b5da 18.0 landed
-
Move EXPLAIN counter increment to heapam_scan_bitmap_next_block
- 7bd7aa4d3067 18.0 landed
-
Refactor tidstore.c iterator buffering.
- f6bef362cac8 18.0 cited
-
BitmapHeapScan: Remove incorrect assert and reset field
- a3e6c6f92991 17.0 landed
-
Change BitmapAdjustPrefetchIterator to accept BlockNumber
- 92641d8d651e 17.0 landed
-
BitmapHeapScan: Use correct recheck flag for skip_fetch
- 1fdb0ce9b109 17.0 landed
-
BitmapHeapScan: Push skip_fetch optimization into table AM
- 04e72ed617be 17.0 landed
-
BitmapHeapScan: postpone setting can_skip_fetch
- fe1431e39cdd 17.0 landed
-
BitmapHeapScan: begin scan after bitmap creation
- 1577081e9614 17.0 landed
-
Fix EXPLAIN Bitmap heap scan to count pages with no visible tuples
- f3e4581acdc8 12.19 landed
- 992189a3e94d 13.15 landed
- 262757b73286 14.12 landed
- d3d95f583995 15.7 landed
- 1f4eb734200a 16.3 landed
- 0960ae1967d0 17.0 landed
-
Remove redundant snapshot copying from parallel leader to workers
- 84c18acaf690 17.0 landed
-
Remove some obsolete smgrcloseall() calls.
- 6a8ffe812d19 17.0 cited
-
Remove the "snapshot too old" feature.
- f691f5b80a85 17.0 cited
-
Compute XID horizon for page level index vacuum on primary.
- 558a9165e081 12.0 cited