Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?)
Melanie Plageman <melanieplageman@gmail.com>
Attachments
- v5-0001-Add-system-view-tracking-shared-buffer-actions.patch (text/x-patch) patch v5-0001
On Wed, Aug 11, 2021 at 4:11 PM Melanie Plageman <melanieplageman@gmail.com> wrote: > > On Tue, Aug 3, 2021 at 2:13 PM Andres Freund <andres@anarazel.de> wrote: > > > > > @@ -2895,6 +2948,20 @@ FlushBuffer(BufferDesc *buf, SMgrRelation reln) > > > /* > > > * bufToWrite is either the shared buffer or a copy, as appropriate. > > > */ > > > + > > > + /* > > > + * TODO: consider that if we did not need to distinguish between a buffer > > > + * flushed that was grabbed from the ring buffer and written out as part > > > + * of a strategy which was not from main Shared Buffers (and thus > > > + * preventable by bgwriter or checkpointer), then we could move all calls > > > + * to pgstat_increment_buffer_action() here except for the one for > > > + * extends, which would remain in ReadBuffer_common() before smgrextend() > > > + * (unless we decide to start counting other extends). That includes the > > > + * call to count buffers written by bgwriter and checkpointer which go > > > + * through FlushBuffer() but not BufferAlloc(). That would make it > > > + * simpler. Perhaps instead we can find somewhere else to indicate that > > > + * the buffer is from the ring of buffers to reuse. > > > + */ > > > smgrwrite(reln, > > > buf->tag.forkNum, > > > buf->tag.blockNum, > > > > Can we just add a parameter to FlushBuffer indicating what the source of the > > write is? > > > > I just noticed this comment now, so I'll address that in the next > version. I rebased today and noticed merge conflicts, so, it looks like > v5 will be on its way soon anyway. > Actually, after moving the code around like you suggested, calling pgstat_increment_buffer_action() before smgrwrite() in FlushBuffer() and using a parameter to indicate if it is a strategy write or not would only save us one other call to pgstat_increment_buffer_action() -- the one in SyncOneBuffer(). We would end up moving the one in BufferAlloc() to FlushBuffer() and removing the one in SyncOneBuffer(). Do you think it is still worth it? Rebased v5 attached.
Commits
-
Stabilize pg_stat_io writes test
- ef719e7b32fc 16.0 landed
-
Fix flakey pg_stat_io test
- 1be0fdb9de55 16.0 landed
-
Suppress more compiler warnings in new pgstats code.
- b1b86820d84e 16.0 landed
-
Suppress compiler warnings in new pgstats code.
- 728560db7d86 16.0 landed
-
Add tests for pg_stat_io
- 10a082bf7215 16.0 landed
-
Create regress_tblspc in test_setup
- 9c83bbcf7ef6 16.0 landed
-
Add pg_stat_io view, providing more detailed IO statistics
- a9c70b46dbe1 16.0 landed
-
pgstat: Track more detailed relation IO statistics
- f30d62c2fc60 16.0 landed
-
pgstat: Infrastructure for more detailed IO statistics
- 28e626bde00e 16.0 landed
-
doc: Fix some issues in logical replication section
- 4f74f5641d53 16.0 cited
-
Manual cleanup and pgindent of pgstat and bufmgr related code
- 250c8ee07ede 16.0 landed
-
Have the planner consider Incremental Sort for DISTINCT
- 3c6fc58209f2 16.0 cited
-
Use actual backend IDs in pg_stat_get_backend_idset() and friends.
- d7e39d72ca1c 16.0 cited
-
Remove redundant call to pgstat_report_wal()
- 1bdd54e662d5 16.0 landed
-
Add BackendType for standalone backends
- 0c679464a837 16.0 landed
-
Initialize backend status reporting during bootstrap.
- 3b34645678d1 15.0 landed