[PATCH] Use maintenance_io_concurrency for parallel index builds

Started by Jingtang Zhang3 months ago5 messageshackers

Thread notes

1 note#bug
hackorum-bot#bug
hackorum-bot
2 days ago

@global #bug

#bug
Jump to latest
#1Jingtang Zhang
mrdrivingduck@gmail.com

Hi,

Parallel B-tree, GIN, and BRIN index builds currently use
effective_io_concurrency for heap scans because the scans do not
pass READ_STREAM_MAINTENANCE to the read stream.

The attached patch passes the maintenance context through the existing
scan flags, making these scans use maintenance_io_concurrency.

Serial index builds appear to have the same issue. Passing the flag
there seems to require extending the table scan interface, which
could be follow-up work.

---
Regards,
Jingtang Zhang

Attachments:

t253714_1
v1-parallel-index-maintenance-io.patchapplication/octet-stream; name=v1-parallel-index-maintenance-io.patchDownload+11-5
#2Jingtang Zhang
mrdrivingduck@gmail.com
In reply to: Jingtang Zhang (#1)
Re: [PATCH] Use maintenance_io_concurrency for parallel index builds

Hi,

Attached is v2, regenerated with git format-patch to fix cfbot's
"Patch format detection failed" error. No code changes from v1.

---
Best regards,
Jingtang

Attachments:

t253714_2
v2-parallel-index-maintenance-io.patchapplication/octet-stream; name=v2-parallel-index-maintenance-io.patchDownload+11-6
#3Yuhang Qiu
iamqyh@gmail.com
In reply to: Jingtang Zhang (#2)
Re: [PATCH] Use maintenance_io_concurrency for parallel index builds

Hi Jingtang,

The problem is real, and the fix LGTM.

Passing the flag there seems to require extending the table scan
interface

Actually, no extension is needed: table_beginscan_common() already
accepts user_flags, so heapam_index_build_range_scan() can simply
call it directly and pass SO_MAINTENANCE.

BRIN's summarize_range() also goes through
heapam_index_build_range_scan(), so fixing the serial path would
switch it over. IMO, that counts as maintenance too.

Best regards,
Yuhang Qiu

#4Jingtang Zhang
mrdrivingduck@gmail.com
In reply to: Yuhang Qiu (#3)
Re: [PATCH] Use maintenance_io_concurrency for parallel index builds

Hi,

Actually, no extension is needed: table_beginscan_common() already
accepts user_flags, so heapam_index_build_range_scan() can simply
call it directly and pass SO_MAINTENANCE.

BRIN's summarize_range() also goes through
heapam_index_build_range_scan(), so fixing the serial path would
switch it over. IMO, that counts as maintenance too.

Thanks for the review. Attached is v3, which also handles serial index
builds by calling table_beginscan_common() directly, as you suggested.
This covers BRIN range summarization too, without changing the API.

---
Regards,
Jingtang Zhang

Attachments:

t253714_4
v3-index-maintenance-io.patchapplication/octet-stream; name=v3-index-maintenance-io.patchDownload+24-12
#5Jingtang Zhang
mrdrivingduck@gmail.com
In reply to: Jingtang Zhang (#4)
Re: [PATCH] Use maintenance_io_concurrency for parallel index builds

Hi all,

I found another maintenance path using effective_io_concurrency:
the sequential heap scan in heapam_relation_copy_for_cluster().
This affects VACUUM FULL and the sequential scan paths of CLUSTER
and REPACK.

Attached is v4, which also passes SO_MAINTENANCE for this scan.

---
Regards,
Jingtang Zhang

Attachments:

t253714_5
v4-index-maintenance-io.patchapplication/octet-stream; name=v4-index-maintenance-io.patchDownload+25-13