Skip to content

Change prefetch logic in vacuum #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2025

Conversation

knizhnik
Copy link

See https://neondb.slack.com/archives/C03QLRH7PPD/p1745003314183649

Vacuum doesn't use prefetch because this strange logic in lazy_scan_heap:

			/* And only up to the next unskippable block */
			if (next_prefetch_block + prefetch_budget > vacrel->next_unskippable_block)
				prefetch_budget = vacrel->next_unskippable_block - next_prefetch_block;

Solution:

Disable prefetch only if vacuum jumps to next skippable block (there is SKIP_PAGES_THRESHOLD) which cancel seqscan and perform jump only if gap iOS larger enough).

Copy link

@MMeent MMeent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the reason why so much was changed here. Specifically, I don't understand why you changed so much of heap_vac_scan_next_block, and vacrel's layout was modified.

@knizhnik knizhnik requested a review from MMeent May 8, 2025 06:35
@knizhnik knizhnik force-pushed the vacuum_prefetch_fix_v17 branch from 561b8b7 to b67f1e3 Compare May 8, 2025 16:16
@knizhnik knizhnik merged commit 0d59c91 into REL_17_STABLE_neon May 9, 2025
1 check passed
@knizhnik knizhnik deleted the vacuum_prefetch_fix_v17 branch May 9, 2025 04:51
github-merge-queue bot pushed a commit to neondatabase/neon that referenced this pull request May 9, 2025
## Problem
See https://neondb.slack.com/archives/C03QLRH7PPD/p1745003314183649

Vacuum doesn't use prefetch because this strange logic in
`lazy_scan_heap`:

```
			/* And only up to the next unskippable block */
			if (next_prefetch_block + prefetch_budget > vacrel->next_unskippable_block)
				prefetch_budget = vacrel->next_unskippable_block - next_prefetch_block;
```
## Summary of changes

Disable prefetch only if vacuum jumps to next skippable block (there is
SKIP_PAGES_THRESHOLD) which cancel seqscan and perform jump only if gap
is large enough).


Postgres PRs:
neondatabase/postgres#620
neondatabase/postgres#621
neondatabase/postgres#622
neondatabase/postgres#623

---------

Co-authored-by: Konstantin Knizhnik <[email protected]>
lubennikovaav pushed a commit that referenced this pull request May 9, 2025
* Change prefetch logic in vacuum

* Fix mistyping

---------

Co-authored-by: Konstantin Knizhnik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants