Re: BitmapHeapScan streaming read user and prelim refactoring
Tomas Vondra <tomas.vondra@enterprisedb.com>
Attachments
- i5-uncached-cyclic.pdf (application/pdf)
- relative-all-optimal-readahead-small.png (image/png)
- relative-all-optimal-no-readahead-small.png (image/png)
On 3/14/24 19:16, Melanie Plageman wrote: > ... > > Attached v6 is rebased over your new commit. It also has the "fix" in > 0010 which moves BitmapAdjustPrefetchIterator() back above > table_scan_bitmap_next_block(). I've also updated the Streaming Read API > commit (0013) to Thomas' v7 version from [1]. This has the update that > we theorize should address some of the regressions in the bitmapheapscan > streaming read user in 0014. > Based on the recent discussions in this thread I've been wondering how does the readahead setting for the device affect the behavior, so I've modified the script to test different values for this parameter too. Considering the bug in the v7 patch (reported yesterday elsewhere in this thread), I had to use the v6 version for now. I don't think it makes much difference, the important parts of the patch do not change. The complete results are far too large to include here (multiple MBs), so I'll only include results for a small subset of parameters (one dataset on i5), and some scatter charts with all results to show the overall behavior. (I only have results for 1M rows so far). Complete results (including the raw CSV etc.) are available in a git repo, along with jupyter notebooks that I started using for experiments and building the other charts: https://github.com/tvondra/jupyterlab-projects/tree/master If you look at the attached PDF table, the first half is for serial execution (no parallelism), the second half is with 4 workers. And there are 3 different readahead settings 0, 1536 and 12288 (and then different eic values for each readahead value). The readahead values are chosen as "disabled", 6x128kB and the default that was set by the kernel (or wherever it comes from). There are pretty clear patterns: * serial runs with disabled readahead - The patch causes fairly serious regressions (compared to master), if eic>0. * serial runs with enabled readahead - there's still some regression for lower matches values. Presumably, at higher values (which means larger fraction of the table matches) the readahead kicks in, leaving the lower values as if readahead was not enabled. * parallel runs - The regression is much smaller, either because the parallel workers issue requests almost as if there was readahead, or maybe it implicitly disrupts the readahead. Not sure. The other datasets are quite similar, feel free to check the git repo for complete results. One possible caveat is that maybe this affects only cases that would not actually use bitmap scans? But if you check the attached scatter charts (PNG), that only show results for cases where the planner would actually pick bitmap scans on it's own, there are plenty such cases. For the 0012 patch (chart on left), there's almost no such problem - the results are very close to master. Similarly, there are regressions even on the chart with readahead, but it's far less frequent/significant. The question is whether readahead=0 is even worth worrying about? If disabling readahead causes serious regressions even on master (clearly visible in the PDF table), would anyone actually run with it disabled? But I'm not sure that argument is very sound. Surely there are cases where readahead may not detect a pattern, or where it's not supported for some arbitrary reason (e.g. I didn't have much luck with this on ZFS, perhaps other filesystems have similar limitations). But also what about direct I/O? Surely that won't have readahead by kernel, right? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
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