From: Tom Lane Date: Fri, 21 Dec 2001 15:22:09 +0000 (+0000) Subject: Use MemSet() rather than a loop to do blank-padding on PS_USE_CLOBBER_ARGV X-Git-Tag: REL7_2_BETA5~187 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12d17deb4f34833a49d8c3f465668249b37d83bc;p=postgresql Use MemSet() rather than a loop to do blank-padding on PS_USE_CLOBBER_ARGV machines. I have just been observing some scenarios where set_ps_display accounts for more than 10% of the backend CPU, and this loop has to be the reason. --- diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c index c2f1b8975d..c6e335561f 100644 --- a/src/backend/utils/misc/ps_status.c +++ b/src/backend/utils/misc/ps_status.c @@ -5,7 +5,7 @@ * to contain some useful information. Mechanism differs wildly across * platforms. * - * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.11 2001/11/06 01:15:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.12 2001/12/21 15:22:09 tgl Exp $ * * Copyright 2000 by PostgreSQL Global Development Group * various details abducted from various places @@ -265,13 +265,11 @@ set_ps_display(const char *activity) #ifdef PS_USE_CLOBBER_ARGV { - char *cp; + int buflen; /* pad unused memory */ - for (cp = ps_buffer + strlen(ps_buffer); - cp < ps_buffer + ps_buffer_size; - cp++) - *cp = PS_PADDING; + buflen = strlen(ps_buffer); + MemSet(ps_buffer + buflen, PS_PADDING, ps_buffer_size - buflen); } #endif /* PS_USE_CLOBBER_ARGV */ #endif /* not PS_USE_NONE */