Re: [HACKERS] Another aspect of set_ps_display ()

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [HACKERS] Another aspect of set_ps_display ()
Дата
Msg-id 200702162134.l1GLYGV16394@momjian.us
обсуждение исходный текст
Ответ на Re: [HACKERS] Another aspect of set_ps_display ()  (Bruce Momjian <bruce@momjian.us>)
Список 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@momjian.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@momjian.us>          http://momjian.us
  EnterpriseDB                               http://www.enterprisedb.com

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

В списке pgsql-patches по дате отправления:

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: patch adding new regexp functions
Следующее
От: Robert Treat
Дата:
Сообщение: Re: [pgsql-patches] pg_standby