Re: pg_stat_io not tracking smgrwriteback() is confusing

From: Andres Freund <andres(at)anarazel(dot)de>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org>
Subject: Re: pg_stat_io not tracking smgrwriteback() is confusing
Date: 2023-05-04 16:57:38
Message-ID: 20230504165738.4e2hfoddoels542c@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2023-04-24 21:29:48 -0400, Melanie Plageman wrote:
> 1) Does it make sense for writebacks to count the number of blocks for
> which writeback was requested or the number of calls to smgrwriteback() or
> the number of actual syscalls made? We don't actually know from outside
> of mdwriteback() how many FileWriteback() calls we will make.

The number of blocks is the right thing IMO. The rest is just some
micro-optimization.

> 2) I'm a little nervous about not including IOObject in the writeback
> context. Technically, there is nothing stopping local buffer code from
> calling IssuePendingWritebacks(). Right now, local buffer code doesn't
> do ScheduleBufferTagForWriteback(). But it doesn't seem quite right to
> hardcode in IOOBJECT_RELATION when there is nothing wrong with
> requesting writeback of local buffers (AFAIK). What do you think?

I think it'd be wrong on performance grounds ;). We could add an assertion to
ScheduleBufferTagForWriteback(), I guess, to document that fact?

> 3) Should any restrictions be added to pgstat_tracks_io_object() or
> pgstat_tracks_io_op()? I couldn't think of any backend types or IO
> contexts which would not do writeback as a rule. Also, though we don't
> do writeback for temp tables now, it isn't nonsensical to do so. In
> this version, I didn't add any restrictions.

I think the temp table restriction could be encoded for now, I don't forsee
that changing anytime soon.

About other restrictions: Anything that triggers catalog access can trigger
buffers to be written back. Checkpointer and bgwriter don't do catalog access,
but have explicit writeback calls. WAL receiver, WAL writer, syslogger and
archiver are excluded on a backend type basis. I think the startup process
will use the normal backend logic, and thus also trigger writebacks?

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jehan-Guillaume de Rorthais 2023-05-04 17:30:06 Re: Memory leak from ExecutorState context?
Previous Message Andres Freund 2023-05-04 16:46:54 Re: pg_stat_io not tracking smgrwriteback() is confusing