Re: [HACKERS] Another aspect of set_ps_display ()

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: "Strong, David" <david(dot)strong(at)unisys(dot)com>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] Another aspect of set_ps_display ()
Date: 2007-02-16 21:34:16
Message-ID: 200702162134.l1GLYGV16394@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Applied.

---------------------------------------------------------------------------

Bruce Momjian wrote:
>
> I did some research on this item from October, 2006. I was struck by
> the memset of 2344 for every proc title change on popular platforms like
> Linux.
>
> The attached patch reduces the memset to only span the length needed
> since the last title change. This should significantly reduce the proc
> title overhead.
>
> Now that we are using strlcpy(), we still need this code because
> strlcpy() doesn't span the entire buffer if not needed, and sometimes
> the clobber character is a space, rather than a zero byte.
>
> ---------------------------------------------------------------------------
>
> Strong, David wrote:
> > We were just analyzing some more OProfile and ltrace data against
> > Postgres 8.2Beta1 and we noticed a number of calls as follows:
> >
> >
> > strlen("postgres: tpc tpc 192.168.1.200("...) = 58
> > memset(0xbffff6b2, '\000', 2344) = 0xbffff6b2
> >
> >
> > We have tracked this down to the following code in the set_ps_display ()
> > function:
> >
> >
> > #ifdef PS_USE_CLOBBER_ARGV
> > {
> > int buflen;
> >
> > /* pad unused memory */
> > buflen = strlen(ps_buffer);
> > MemSet(ps_buffer + buflen, PS_PADDING, ps_buffer_size - buflen);
> > }
> > #endif /* PS_USE_CLOBBER_ARGV */
> >
> >
> > If set_ps_display () moves to use the strlcpy () function call, this
> > code might be redundant. Even if the StrNCpy () call is kept, this code
> > may still be redundant as StrNCpy () will zero fill the ps_buffer.
> >
> > A MemSet () call on the ps_buffer has to be added to the init_ps_display
> > () function, if this code is removed to clear the buffer before use.
> >
> > David
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: Don't 'kill -9' the postmaster
>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://www.enterprisedb.com
>
> + If your life is a hard drive, Christ can be your backup. +

>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthew T. O'Connor 2007-02-16 21:43:34 Re: autovacuum next steps
Previous Message Tom Lane 2007-02-16 21:09:25 Re: Confusing message on startup after a crash while recovering

Browse pgsql-patches by date

  From Date Subject
Next Message Robert Treat 2007-02-16 22:44:45 Re: [pgsql-patches] pg_standby
Previous Message David Fetter 2007-02-16 18:28:39 Re: patch adding new regexp functions