Re: BitmapHeapScan streaming read user and prelim refactoring
Melanie Plageman <melanieplageman@gmail.com>
On Wed, Feb 19, 2025 at 6:03 PM Thomas Munro <thomas.munro@gmail.com> wrote: > > On Fri, Feb 14, 2025 at 9:32 AM Andres Freund <andres@anarazel.de> wrote: > > I think we'll need to add some logic in read stream that only disables advice > > after a longer sequential sequence. Writing logic for that shouldn't be too > > hard, I think? Determining the concrete cutoffs is probably harder, although I > > think even fairly simplistic logic will be "good enough". > > (Sorry for taking time to respond, I had to try some bogus things > first before I hit on a principled answer.) > > Yeah, it is far too stupid. I think I have figured out the ideal > cutoff: just keep issuing advice for a given sequential run of blocks > until the pread() end of the stream catches up with the *start* of it, > if ever (ie until the kernel sees the actual sequential reads). So like fadvise blocks 2,3,4,5, but then we see pread block 2 so stop fadvising for that run of blocks? > That turned out to require only a small tweak and one new variable. It > avoids those stalls on reads of sequential clusters > > io_combine_limit, with no change in behaviour for pure sequential > streams and random streams containing sequential clusters <= > io_combine_limit that I'd previously been fixating on. Hmm. My understanding must be incorrect because I don't see how this would behave differently for these two IO patterns fadvise 2,3,4,5, pread 2 fadvise 2,100,717,999, pread 2 > I've added a > patch for that to the v2 of my read stream improvements series[1] for > experimentation... will post shortly. I don't think you've posted those yet. I'd like to confirm that these work as expected before we merge the bitmap heap scan code. > I also see a couple of other reasons why streaming BHS can be less > aggressive with I/O than master: the silly arbitrary buffer queue cap, > there's already a patch in the series for that but I have a slightly > better one now and plan to commit it today, and silly heuristics for > look-ahead distance reduction also related to sequential detection, > which I'll explain with a patch on the other thread. All of these are > cases where I was basically a bit too chicken to open the throttle all > the way in early versions. Will post those at [1] too after lunch... > more soon... I'd like to hear more about the buffer queue cap, as I can't say I remember what that is. I'd also be interested to see how these other patches affect the BHS performance. Other than that, we need to decide on effective_io_concurrency defaults, which has also been discussed on this thread. - Melanie
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