Re: BitmapHeapScan streaming read user and prelim refactoring
Tomas Vondra <tomas@vondra.me>
On 2/10/25 19:02, Melanie Plageman wrote: > On Sun, Feb 9, 2025 at 9:27 AM Tomas Vondra <tomas@vondra.me> wrote: >> >> >> 2) ryzen >> -------- >> >> This "new" machine has multiple types of storage. The cached results (be >> it in shared buffers or in page cache) are not very interesting. 0003 >> helps a bit (~15%), but other than that it's just random noise. >> >> The "uncached" results starting on page 23 are much more interesting. In >> general 0001, 0002 and 0004 have little impact, it seems just random >> noise. So in the rest I'll focus on 0003. >> >> For the single nvme device (device: data), it seems mostly fine. It's >> green, even though there are a couple "localized regressions" for eic=0. >> I haven't looked into those yet. >> >> For the nvme RAID (device: raid-nvme), it's looks almost exactly the >> same, except that with parallel query (page 27) there's a clear area of >> regression with eic=1 (look for "column" of red cells). That's a bit >> unfortunate, because eic=1 is the default value. > > It'll be hard to look into all of these, so I think I'll focus on > trying to reproduce something with eic=1 that I can reproduce on my > machine. So far, I can reproduce a regression with the following and > the data file attached. > Yes, that approach makes perfect sense. I don't think anyone can investigate all the regressions, it's enough to investigate one specimen for each of the main "patterns". > # initdb and get set up with shared_buffers 1GB > psql -c "create table bitmap_scan_test (a bigint, b bigint, c text) > with (fillfactor = 25)" > psql -c "copy bitmap_scan_test from '/tmp/bitmap_scan_test.data'" > psql -c "create index on bitmap_scan_test (a)" > psql -c "vacuum analyze" > psql -c "checkpoint" > > pg_ctl stop > echo 3 | sudo tee /proc/sys/vm/drop_caches > pg_ctl start > psql -c "SET max_parallel_workers_per_gather = 4;" \ > -c "SET effective_io_concurrency = 1;" \ > -c "SET parallel_setup_cost = 0;" \ > -c "SET parallel_tuple_cost = 0;" \ > -c "SET enable_seqscan = off;" \ > -c "SET enable_indexscan = off;" \ > -c "SET work_mem = 65536;" > > psql -c "EXPLAIN SELECT * FROM bitmap_scan_test WHERE (a BETWEEN -33 > AND 10015) OFFSET 1000000;" > psql -c "SELECT * FROM bitmap_scan_test WHERE (a BETWEEN -33 AND > 10015) OFFSET 1000000;" > > It's not a huge regression and planner doesn't naturally pick parallel > bitmap heap scan for this, but I don't have a SATA drive right now, so > I focused on something I could reproduce. > > One thing I noticed when I was playing around with the script is that > depending on the values chosen by random(), there were differences in > timing. From your script, it looks like the $from and $to won't be the > same for master and the patch each time (they are set in the inner > most nesting level, below where $build is set). Am I understanding > correctly? > Yes. The values for the WHERE conditions are generated randomly, and the idea is that it evens out for multiple runs. Maybe not with only 3 runs per query, but it should be good enough to show patterns (e.g. when the runs with eic=1 show regression). >> Anyway, the results look sensible. It might be good to investigate some >> of the regressions, and I'll try doing that if I find the time. But I >> don't think that's necessarily a blocker - every patch of this type will >> have a hardware where the heuristics doesn't quite do the right thing by >> default. Which is why we have GUCs to tune it if appropriate. > > Yea, I definitely won't be able to look into all of the regressions. > So, I guess we have to ask if we are willing to make the tradeoff. > I'm at peace with that. Certainly for the "localized" regressions, and cases when bitmapheapscan would not be picked. The eic=1 case makes me a bit more nervous, because it's default and affects NVMe storage. Would be good to know why is that, or perhaps consider bumping up eic default. Not sure. regards -- Tomas Vondra
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