Re: [HACKERS] Patch to log usage of temporary files

From: Bill Moran <wmoran(at)collaborativefusion(dot)com>
To: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Patch to log usage of temporary files
Date: 2007-01-03 21:20:53
Message-ID: 20070103162053.c08f6095.wmoran@collaborativefusion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

In response to "Simon Riggs" <simon(at)2ndquadrant(dot)com>:

> On Tue, 2007-01-02 at 18:20 -0500, Tom Lane wrote:
> > Bill Moran <wmoran(at)collaborativefusion(dot)com> writes:
> > > In response to Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
> > >> Please change things to save the stat() syscall when the feature is not
> > >> in use.
> >
> > > Do you have a suggestion on how to do that and still have the PG_TRACE1()
> > > work? That was specifically requested by Simon Riggs.
> >
> > Well, we are NOT paying a stat() call on every single file close,
> > whether Simon wants it or not.
>
> Simon doesn't/wouldn't want the stat() call on each file close.
>
> If you put the PG_TRACE macro outside of the if test, yet prior to the
> file close, you can pass the filename through like this
>
> PG_TRACE1(temp__file__cleanup, vfdP->fileName);
>
> That way DTrace can make its own call to find out filesize, if it would
> like to... and we don't need to stat() before each temp file close.
> That's much more flexible and useful, as well as better performance.

OK, I think I've managed to adjust this patch so that everyone is happy ;)
and it's better as well.

* PG_TRACE will work whether the GUC var is enabled or not, it sends the
fileName, as suggested by Simon
* stat() call is not made if trace_temp_files is disabled
* trace_temp_files is now an int: -1 disables, 0 and up equate to "log if
the file is this size or larger"
* Cleaned things up a bit -- should be more in line with PostgreSQL
coding standards
* failed stat is reported as LOG instead of ERROR

Done a bit of testing here, and everything seems to be in order.

--
Bill Moran
Collaborative Fusion Inc.

Attachment Content-Type Size
trace_log_files.diff text/x-diff 3.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2007-01-03 21:35:39 Re: [HACKERS] Patch to log usage of temporary files
Previous Message Simon Riggs 2007-01-03 21:13:16 Re: Execution Plan

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2007-01-03 21:35:39 Re: [HACKERS] Patch to log usage of temporary files
Previous Message Simon Riggs 2007-01-03 15:35:44 Re: [HACKERS] Patch to log usage of temporary files