Another aspect of set_ps_display () - Mailing list pgsql-hackers

From Strong, David
Subject Another aspect of set_ps_display ()
Date
Msg-id B6419AF36AC8524082E1BC17DA2506E80316D38C@USMV-EXCH2.na.uis.unisys.com
Whole thread Raw
In response to Re: Faster StrNCpy  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: PL/pgSQL Todo, better information in errcontext from plpgsql
Next
From: Tom Lane
Date:
Subject: Re: Digging gram.y