Re: Suppressing useless wakeups in walreceiver

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Suppressing useless wakeups in walreceiver
Date: 2022-10-10 18:10:14
Message-ID: 20221010181014.GC993859@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 10, 2022 at 10:51:14AM -0700, Nathan Bossart wrote:
>> + /* Find the soonest wakeup time, to limit our nap. */
>> + nextWakeup = INT64_MAX;
>> + for (int i = 0; i < NUM_WALRCV_WAKEUPS; ++i)
>> + nextWakeup = Min(state.wakeup[i], nextWakeup);
>> + nap = Max(0, (nextWakeup - now + 999) / 1000);

Hm. We should probably be more cautious here since nextWakeup is an int64
and nap is an int. My guess is that we should just set nap to -1 if
nextWakeup > INT_MAX.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2022-10-10 18:17:47 Re: [patch] \g with multiple result sets and \watch with copy queries
Previous Message Corey Huinker 2022-10-10 17:58:02 Re: [patch] \g with multiple result sets and \watch with copy queries