On Thu, Nov 27, 2014 at 1:26 AM, Tomas Vondra <tv@fuzzy.cz> wrote:
> On 26.11.2014 23:06, Maxim Boguk wrote:
> >
> >
> > I'm not sure I understand what you mean.
> >
> > The timestamp *IS* updated on every write - see this:
> >
> >
> https://github.com/postgres/postgres/blob/REL9_2_STABLE/src/backend/postmaster/pgstat.c#L3469
> >
> >
> > I mean that usually 99.9% writes goes through mmap, which update the
> > pgstat.tmp file timestamp (but not update last_statwrite value).
>
> I don't follow. Can you explain what you mean by the mmap? I don't see
> any mmap stuff in pgstat.c, nor I remember dealing with mmap in my
> patches in this area ...
>
Hm I had been wrong. I seen mmap call on strace after every statistic
collector file rewrite and I thought that all writes to that file goes
through memory mapped structure instead of full file writes every time when
someone need fresh data.
However, point still open - there are no reason to write a new file from
scratch if no activity had been received from stat socket since the last
write (the same point valid for per-database stat files in 9.3+).
And check
https://github.com/postgres/postgres/blob/REL9_2_STABLE/src/backend/postmaster/pgstat.c#L3972
looks like redundant in that case?
Kind Regards,
Maksym