Re: [GENERAL] query log corrupted-looking entries - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [GENERAL] query log corrupted-looking entries
Date
Msg-id 29860.1161202644@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] query log corrupted-looking entries  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [GENERAL] query log corrupted-looking entries  ("George Pavlov" <gpavlov@mynewplace.com>)
List pgsql-hackers
I wrote:
> I checked around with some kernel/glibc gurus in Red Hat, and the
> consensus seemed to be that we'd be better off to bypass fprintf() and
> just send message strings to stderr using write() --- ie, instead of
> elog.c doing
>             fprintf(stderr, "%s", buf.data);
> do
>             write(fileno(stderr), buf.data, strlen(buf.data));

I did some strace'ing of the backend, and observed that even for very
long messages (upwards of 100K) the fprintf results in a single write()
call.  This was true on both Fedora Core 5 and a pretty old HPUX version.
So it'd seem that most versions of libc already know about optimizing
fprintf-%s into a direct write(), and changing our code wouldn't change
the behavior.  It'd be interesting to verify whether it's the same on
George's machine though.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Simon Riggs"
Date:
Subject: Re: pg_internal.init is hazardous to your health
Next
From: "George Pavlov"
Date:
Subject: Re: [GENERAL] query log corrupted-looking entries