Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sYZb6-00CQjA-N9 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jul 2024 23:16:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sYZb5-0041M0-5L for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jul 2024 23:16:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sYZb4-0041Ln-RG for pgsql-hackers@lists.postgresql.org; Mon, 29 Jul 2024 23:16:06 +0000 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sYZb2-0029CN-Oh for pgsql-hackers@postgresql.org; Mon, 29 Jul 2024 23:16:06 +0000 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-7a1d7a544e7so284374485a.3 for ; Mon, 29 Jul 2024 16:16:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722294962; x=1722899762; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+yrwZh3MXReinVWajiiX3Hl5VTGkfjKGCLDU2Aou1wo=; b=hqDHpOzkM5aK9fPRT5bo3DPBMsZ2MAYs4MxXGF6dzeIGm3LbQP3pkh/gGdFDUXx2Vf grI6WmIkk7MaONtcoub2V04vi8CK+WEWPKQZL1TjasY+o/+RD2GBZF0dVxpHSZjO6EUy mbdc6ZB7RMSu0a+Xk/bI7Bk/U9D0iDXKnUiq58agWvUbanoku29IdoFjbPpZyLfnJ6Qd PldBHgRg5ca7NwIVtjygl+Q7iz8fXKjJmg4xJZ2As4di0g+5wskem1gyYwGu4UiP5SG/ i2GKLBR+O5v/j6qQp9RG5KYLlX7SwY16Q/ErxT0l3C7S3BJ9/M+u4lKKHVf6MVC6gHqJ KMCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722294962; x=1722899762; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+yrwZh3MXReinVWajiiX3Hl5VTGkfjKGCLDU2Aou1wo=; b=KZmOf0ZcmMPv+gpm8pMZ9979voxkWePcTU8dkXkeuRm0G/HxNynXORa8NlUo62YJCV /DLPBYCAA7Nsw1iCPVJH1hS0rGM+VMolNws0zUk9NCU1tn1RuBbltMIMu0ZGHrQpyiRN z3NkAQVV1zoCbGgKalQXEdtovHjkCcbQssCOWrGb/rpaKSA1FSxqwKoKcYc36hgFJXPL 1/Efr5BE1LOXxnMFcYLRKImxDVYPIZ2WyoNRpeY5E6J109Z5XXrJeE2ORWqzsl299fld KRFvBgWlio0jADlMgsyQzQsGvHyCEzHH4DJrsOXzALYpYhwMT3VStQ2FuXJW5evMjvlt unlA== X-Forwarded-Encrypted: i=1; AJvYcCUaaCdrL7qJNWA44B+hOR56bAQzTtjfzmnZFCe9fcpwc4nTAlNwDfJON7P44DyxE+mqjW9PnrbLf58CRy+hShz/HRWXTi5cM5LccPYc X-Gm-Message-State: AOJu0Yy0dJOmcGctTMz52cAJO1IIR5Pw6PogJxTgcE4qEjGC/EmynT6v YNKCYnhTMMEyD1OCccoj2iWdeusc7AtVHqMBlNXVZniyF6mbbZ5X X-Google-Smtp-Source: AGHT+IE1aOY+13CSVQky915J8asb3fqddd9R3mgz9CzEy//R9JDEQh0uCsKgiFWLhPct5/UVBl9dPw== X-Received: by 2002:a05:620a:4244:b0:79f:176f:747a with SMTP id af79cd13be357-7a1e52fbf14mr904011985a.66.1722294961616; Mon, 29 Jul 2024 16:16:01 -0700 (PDT) Received: from smtpclient.apple ([52.94.133.142]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1d739517csm578312285a.15.2024.07.29.16.16.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jul 2024 16:16:01 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: Restart pg_usleep when interrupted From: Sami Imseih In-Reply-To: Date: Mon, 29 Jul 2024 18:15:49 -0500 Cc: Nathan Bossart , Tom Lane , Robert Haas , "pgsql-hackers@postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <33287B8A-3CA0-494F-87D3-C9D85C6468FE@gmail.com> References: <2F781744-69B8-4BC2-A6EF-3998DCCDB634@gmail.com> <01A15AEA-C35C-41DF-8E81-3B5A0B523939@gmail.com> <521A6F3B-77E1-4F3F-B15E-BCF26D52C698@gmail.com> To: Bertrand Drouvot X-Mailer: Apple Mail (2.3774.600.62) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Jul 26, 2024, at 3:27=E2=80=AFAM, Bertrand Drouvot = wrote: >=20 > Hi, >=20 > On Thu, Jul 25, 2024 at 05:27:15PM -0500, Sami Imseih wrote: >> I am attaching v3 of the patch which addresses the comments made >> earlier by Bertrand about the comment in the patch [1]. >=20 > Thanks! >=20 > Looking at it: >=20 > 1 =3D=3D=3D >=20 > + struct instr_time start_time; >=20 > I think we can get rid of the "struct" keyword here. >=20 > 2 =3D=3D=3D >=20 > + struct instr_time current_time; > + struct instr_time elapsed_time; >=20 > Same as above. Will fix those 2. >=20 > 3 =3D=3D=3D >=20 > I gave more thoughts and I think it can be simplified a bit to reduce = the > number of operations in the while loop. >=20 > What about relying on a "absolute" time that way: >=20 > instr_time absolute; > absolute.ticks =3D start_time.ticks + msec * 1000000; >=20 > and then in the while loop: >=20 > while (nanosleep(&delay, &remain) =3D=3D -1 && errno =3D=3D EINTR) > { > instr_time current_time; > INSTR_TIME_SET_CURRENT(current_time); >=20 > if (current_time.ticks > absolute.ticks) > { > break; While I agree this code is cleaner, myy hesitation there is we don=E2=80=99= t=20 have any other place in which we access .ticks directly and the=20 common practice is to use the intsr_time.h APIs. What do you think? Regards, Sami=20