Skip to content

Commit 08882ce

Browse files
Reduce CPU utilisation of WALSender process. Process was using 10% CPU
doing nothing, caused by naptime specified in milliseconds yet units of pg_usleep() parameter is microseconds. Correctly specifying units reduces call frequency by 1000. Reduction in CPU consumption verified.
1 parent 16a4186 commit 08882ce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/replication/walsender.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*
3131
*
3232
* IDENTIFICATION
33-
* $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.10 2010/03/16 09:09:55 heikki Exp $
33+
* $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.11 2010/03/24 20:11:12 sriggs Exp $
3434
*
3535
*-------------------------------------------------------------------------
3636
*/
@@ -67,7 +67,7 @@ bool am_walsender = false; /* Am I a walsender process ? */
6767
int MaxWalSenders = 0; /* the maximum number of concurrent walsenders */
6868
int WalSndDelay = 200; /* max sleep time between some actions */
6969

70-
#define NAPTIME_PER_CYCLE 100 /* max sleep time between cycles (100ms) */
70+
#define NAPTIME_PER_CYCLE 100000L /* max sleep time between cycles (100ms) */
7171

7272
/*
7373
* These variables are used similarly to openLogFile/Id/Seg/Off,
@@ -396,7 +396,7 @@ WalSndLoop(void)
396396
* sleep into NAPTIME_PER_CYCLE (ms) increments, and check for
397397
* interrupts after each nap.
398398
*/
399-
remain = WalSndDelay;
399+
remain = WalSndDelay * 1000L;
400400
while (remain > 0)
401401
{
402402
if (got_SIGHUP || shutdown_requested || ready_to_stop)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy