Use MemSet() rather than a loop to do blank-padding on PS_USE_CLOBBER_ARGV
authorTom Lane <[email protected]>
Fri, 21 Dec 2001 15:22:09 +0000 (15:22 +0000)
committerTom Lane <[email protected]>
Fri, 21 Dec 2001 15:22:09 +0000 (15:22 +0000)
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.

src/backend/utils/misc/ps_status.c

index 9abb9733be2e32a8140fc74473c01a16f9452626..bfb85ee9c57ac4864b630900d0a1d0e0b79a84b9 100644 (file)
@@ -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 */