From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Melanie Plageman <melanieplageman(at)gmail(dot)com> |
Cc: | Justin Pryzby <pryzby(at)telsasoft(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Geoghegan <pg(at)bowt(dot)ie>, pgsql-hackers(at)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com> |
Subject: | Re: Option to not use ringbuffer in VACUUM, using it in failsafe mode |
Date: | 2023-04-04 00:37:10 |
Message-ID: | CAApHDvpARCzjDwKqv5HR43JhfsvCgr_7d2m6akVBbYSTgm4Lpw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, 4 Apr 2023 at 02:49, Melanie Plageman <melanieplageman(at)gmail(dot)com> wrote:
> v9 attached.
I've made a pass on the v9-0001 patch only. Here's what I noted down:
v9-0001:
1. In the documentation and comments, generally we always double-space
after a period. I see quite often you're not following this.
2. Doc: We could generally seem to break tags within paragraphs into
multiple lines. You're doing that quite a bit, e.g:
linkend="glossary-buffer-access-strategy">Buffer Access
Strategy</glossterm>. <literal>0</literal> will disable use of a
2. This is not a command
<command>BUFFER_USAGE_LIMIT</command> parameter.
<option> is probably what you want.
3. I'm not sure I agree that it's a good idea to refer to the strategy
with multiple different names. Here you've called it a "ring buffer",
but in the next sentence, you're calling it a Buffer Access Strategy.
Specifies the ring buffer size for <command>VACUUM</command>. This size
is used to calculate the number of shared buffers which will be reused as
part of a <glossterm linkend="glossary-buffer-access-strategy">Buffer
Access Strategy</glossterm>. <literal>0</literal> disables use of a
4. Can you explain your choice in not just making < 128 a hard error
rather than clamping?
I guess it means checks like this are made more simple, but that does
not seem like a good enough reason:
/* check for out-of-bounds */
if (result < -1 || result > MAX_BAS_RING_SIZE_KB)
postgres=# vacuum (parallel -1) pg_class;
ERROR: parallel workers for vacuum must be between 0 and 1024
Maybe the above is a good guide to follow.
To allow you to get rid of the clamping code, you'd likely need an
assign hook function for vacuum_buffer_usage_limit.
5. I see vacuum.sgml is full of inconsistencies around the use of
<literal> vs <option>. I was going to complain about your:
<literal>ONLY_DATABASE_STATS</literal> option. If
<literal>ANALYZE</literal> is also specified, the
<literal>BUFFER_USAGE_LIMIT</literal> value is used for both the vacuum
but I see you've likely just copied what's nearby.
There are also plenty of usages of <option> in that file. I'd rather
see you use <option>. Maybe there can be some other patch that sweeps
the entire docs to look for <literal>OPTION_NAME</literal> and
replaces them to use <option>.
6. I was surprised to see you've added both
GetAccessStrategyWithSize() and GetAccessStrategyWithNBuffers(). I
think the former is suitable for both. GetAccessStrategyWithNBuffers()
seems to be just used once outside of freelist.c
7. I don't think bas_nbuffers() is a good name for an external
function. StrategyGetBufferCount() seems better.
8. I don't quite follow this comment:
/*
* TODO: should this be 0 so that we are sure that vacuum() never
* allocates a new bstrategy for us, even if we pass in NULL for that
* parameter? maybe could change how failsafe NULLs out bstrategy if
* so?
*/
Can you explain under what circumstances would vacuum() allocate a
bstrategy when do_autovacuum() would not? Is this a case of a config
reload where someone changes vacuum_buffer_usage_limit from 0 to
something non-zero? If so, perhaps do_autovacuum() needs to detect
this and allocate a strategy rather than having vacuum() do it once
per table (wastefully).
9. buffer/README. I think it might be overkill to document details
about how the new vacuum option works in a section talking about
Buffer Ring Replacement Strategy. Perhaps it just worth something
like:
"In v16, the 256KB ring was made configurable by way of the
vacuum_buffer_usage_limit GUC and the BUFFER_USAGE_LIMIT VACUUM
option."
10. I think if you do #4 then you can get rid of all the range checks
and DEBUG1 elogs in GetAccessStrategyWithSize().
11. This seems a bit badly done:
int vacuum_buffer_usage_limit = -1;
int VacuumCostPageHit = 1; /* GUC parameters for vacuum */
int VacuumCostPageMiss = 2;
int VacuumCostPageDirty = 20;
I'd class vacuum_buffer_usage_limit as a "GUC parameters for vacuum"
too. Probably the CamelCase naming should be followed too.
12. ANALYZE too?
{"vacuum_buffer_usage_limit", PGC_USERSET, RESOURCES_MEM,
gettext_noop("Sets the buffer pool size for VACUUM and autovacuum."),
13. VacuumParams.ring_size has no comments explaining what it is.
14. vacuum_buffer_usage_limit seems to be lumped in with unrelated GUCs
extern PGDLLIMPORT int maintenance_work_mem;
extern PGDLLIMPORT int max_parallel_maintenance_workers;
+extern PGDLLIMPORT int vacuum_buffer_usage_limit;
extern PGDLLIMPORT int VacuumCostPageHit;
extern PGDLLIMPORT int VacuumCostPageMiss;
15. No comment explaining what these are:
#define MAX_BAS_RING_SIZE_KB (16 * 1024 * 1024)
#define MIN_BAS_RING_SIZE_KB 128
16. Parameter names in function declaration and definition don't match in:
extern BufferAccessStrategy
GetAccessStrategyWithNBuffers(BufferAccessStrategyType btype, int
nbuffers);
extern BufferAccessStrategy
GetAccessStrategyWithSize(BufferAccessStrategyType btype, int
nbuffers);
Also, line wraps at 79 chars. (80 including line feed)
17. If you want to test the 16GB upper limit, maybe going 1KB (or
8KB?) rather than 1GB over 16GB is better? 2097153kB, I think.
VACUUM (BUFFER_USAGE_LIMIT '17 GB') vac_option_tab;
David
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2023-04-04 01:15:46 | fairywren exiting in ecpg |
Previous Message | Tom Lane | 2023-04-03 23:39:14 | Re: Why enable_hashjoin Completely disables HashJoin |