-
Notifications
You must be signed in to change notification settings - Fork 1
Cooling-stage clock sweep (batched sweep + HOT/COOL evictor + strategy removal) #34
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,11 +27,11 @@ INSERT INTO heaptest (a, b) | |||||||||||
| FROM generate_series(1,50) gs); | ||||||||||||
|
|
||||||||||||
| -- pg_stat_io test: | ||||||||||||
| -- verify_heapam always uses a BAS_BULKREAD BufferAccessStrategy, whereas a | ||||||||||||
| -- sequential scan does so only if the table is large enough when compared to | ||||||||||||
| -- shared buffers (see initscan()). CREATE DATABASE ... also unconditionally | ||||||||||||
| -- uses a BAS_BULKREAD strategy, but we have chosen to use a tablespace and | ||||||||||||
| -- verify_heapam to provide coverage instead of adding another expensive | ||||||||||||
| -- verify_heapam reads the heap through the buffer manager; with the | ||||||||||||
| -- cooling-stage clock sweep there are no per-strategy IO contexts, so the | ||||||||||||
| -- reads are counted in the 'normal' context. CREATE DATABASE ... likewise | ||||||||||||
| -- reads through the normal context, but we have chosen to use a tablespace | ||||||||||||
| -- and verify_heapam to provide coverage instead of adding another expensive | ||||||||||||
| -- operation to the main regression test suite. | ||||||||||||
| -- | ||||||||||||
| -- Create an alternative tablespace and move the heaptest table to it, causing | ||||||||||||
|
|
@@ -43,7 +43,7 @@ INSERT INTO heaptest (a, b) | |||||||||||
| SET allow_in_place_tablespaces = true; | ||||||||||||
| CREATE TABLESPACE regress_test_stats_tblspc LOCATION ''; | ||||||||||||
| SELECT sum(reads) AS stats_bulkreads_before | ||||||||||||
| FROM pg_stat_io WHERE context = 'bulkread' \gset | ||||||||||||
| FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset | ||||||||||||
|
Comment on lines
45
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||
| BEGIN; | ||||||||||||
| ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc; | ||||||||||||
| -- Check that valid options are not rejected nor corruption reported | ||||||||||||
|
|
@@ -56,10 +56,10 @@ COMMIT; | |||||||||||
|
|
||||||||||||
| -- verify_heapam should have read in the page written out by | ||||||||||||
| -- ALTER TABLE ... SET TABLESPACE ... | ||||||||||||
| -- causing an additional bulkread, which should be reflected in pg_stat_io. | ||||||||||||
| -- causing additional reads, which should be reflected in pg_stat_io. | ||||||||||||
| SELECT pg_stat_force_next_flush(); | ||||||||||||
| SELECT sum(reads) AS stats_bulkreads_after | ||||||||||||
| FROM pg_stat_io WHERE context = 'bulkread' \gset | ||||||||||||
| FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset | ||||||||||||
| SELECT :stats_bulkreads_after > :stats_bulkreads_before; | ||||||||||||
|
|
||||||||||||
| CREATE ROLE regress_heaptest_role; | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,7 +161,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) | |
| reldatabase = bufHdr->tag.dbOid; | ||
| forknum = BufTagGetForkNum(&bufHdr->tag); | ||
| blocknum = bufHdr->tag.blockNum; | ||
| usagecount = BUF_STATE_GET_USAGECOUNT(buf_state); | ||
| usagecount = BUF_STATE_GET_COOLSTATE(buf_state); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This silently changes the user-visible semantics of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change alters the user-visible semantics of the |
||
| pinning_backends = BUF_STATE_GET_REFCOUNT(buf_state); | ||
|
|
||
| if (buf_state & BM_DIRTY) | ||
|
|
@@ -605,7 +605,7 @@ pg_buffercache_summary(PG_FUNCTION_ARGS) | |
| if (buf_state & BM_VALID) | ||
| { | ||
| buffers_used++; | ||
| usagecount_total += BUF_STATE_GET_USAGECOUNT(buf_state); | ||
| usagecount_total += BUF_STATE_GET_COOLSTATE(buf_state); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| if (buf_state & BM_DIRTY) | ||
| buffers_dirty++; | ||
|
|
@@ -655,7 +655,7 @@ pg_buffercache_usage_counts(PG_FUNCTION_ARGS) | |
|
|
||
| CHECK_FOR_INTERRUPTS(); | ||
|
|
||
| usage_count = BUF_STATE_GET_USAGECOUNT(buf_state); | ||
| usage_count = BUF_STATE_GET_COOLSTATE(buf_state); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| usage_counts[usage_count]++; | ||
|
|
||
| if (buf_state & BM_DIRTY) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
\gsetvariables are still namedstats_bulkreads_before/stats_bulkreads_after, but this query now deliberately measures thenormalcontext (the comment above was rewritten to say the reads are no longer bulkreads). The names now contradict what they hold. Since these exact lines are already being touched, rename them to reflect the new semantics (e.g.stats_normal_reads_before) for both\gsetsites and the comparison on the following line. This also requires the matching update incontrib/amcheck/expected/check_heap.out.