Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?)
Melanie Plageman <melanieplageman@gmail.com>
Attachments
- v9-0003-Remove-superfluous-bgwriter-stats.patch (text/x-patch) patch v9-0003
- v9-0001-Allow-bootstrap-process-to-beinit.patch (text/x-patch) patch v9-0001
- v9-0002-Add-system-view-tracking-accesses-to-buffers.patch (text/x-patch) patch v9-0002
On Thu, Sep 23, 2021 at 5:05 PM Melanie Plageman <melanieplageman@gmail.com> wrote: > > The attached v8 patchset is rewritten to add in an additional dimension > -- buffer type. Now, a backend keeps track of how many buffers of a > particular type (e.g. shared, local) it has accessed in a particular way > (e.g. alloc, write). It also changes the naming of various structures > and the view members. > > Previously, stats reset did not work since it did not consider live > backends' counters. Now, the reset message includes the current live > backends' counters to be tracked by the stats collector and used when > the view is queried. > > The reset message is one of the areas in which I still need to do some > work -- I shoved the array of PgBufferAccesses into the existing reset > message used for checkpointer, bgwriter, etc. Before making a new type > of message, I would like feedback from a reviewer about the approach. > > There are various TODOs in the code which are actually questions for the > reviewer. Once I have some feedback, it will be easier to address these > items. > > There a few other items which may be material for other commits that > I would also like to do: > 1) write wrapper functions for smgr* functions which count buffer > accesses of the appropriate type. I wasn't sure if these should > literally just take all the parameters that the smgr* functions take + > buffer type. Once these exist, there will be less possibility for > regressions in which new code is added using smgr* functions without > counting this buffer activity. Once I add these, I was going to go > through and replace existing calls to smgr* functions and thereby start > counting currently uncounted buffer type accesses (direct, local, etc). > > 2) Separate checkpointer and bgwriter into two views and add additional > stats to the bgwriter view. > > 3) Consider adding a helper function to pgstatfuncs.c to help create the > tuplestore. These functions all have quite a few lines which are exactly > the same, and I thought it might be nice to do something about that: > pg_stat_get_progress_info(PG_FUNCTION_ARGS) > pg_stat_get_activity(PG_FUNCTION_ARGS) > pg_stat_get_buffers_accesses(PG_FUNCTION_ARGS) > pg_stat_get_slru(PG_FUNCTION_ARGS) > pg_stat_get_progress_info(PG_FUNCTION_ARGS) > I can imagine a function that takes a Datums array, a nulls array, and a > ResultSetInfo and then makes the tuplestore -- though I think that will > use more memory. Perhaps we could make a macro which does the initial > error checking (checking if caller supports returning a tuplestore)? I'm > not sure if there is something meaningful here, but I thought I would > ask. > > Finally, I haven't removed the test in pg_stats and haven't done a final > pass for comment clarity, alphabetization, etc on this version. > I have addressed almost all of the issues mentioned above in v9. The only remaining TODOs are described in the commit message. most critical one is that the reset message doesn't work.
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