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 1sbhml-000pvV-P3 for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Aug 2024 14:37:07 +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 1sbhmj-007qqb-UG for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Aug 2024 14:37:05 +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 1sbhmj-007qqT-Iw for pgsql-hackers@lists.postgresql.org; Wed, 07 Aug 2024 14:37:05 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sbhmh-003e54-95 for pgsql-hackers@postgresql.org; Wed, 07 Aug 2024 14:37:04 +0000 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-39b3e12754eso6758665ab.1 for ; Wed, 07 Aug 2024 07:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723041421; x=1723646221; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2dwqefJrW9rwKNczJFJLQZg3FlWMNIdrY4uVLwJBFYg=; b=J11m3d0AmpuOKHCnWsWDWb0SODvatoHdqXIDKZJjI90dAzOvfZg/g5Qxmq+kfVBnsV B7hnvCW3Q9l6V81S0vbsMpxCnm4CQC0J6PrdrQsy0AckuuGTAwvhxwEkTXaEcAFLrDUJ TKeWnrOXpLenNQBS3IdBWFNFeAX0pdmoy5YWjTMfbkr3cyke7lq7jiXKNaw0QTemiT1C H5oLpvU6xVwXctygCyjnFJcIfiVYD6la6McumCfOhfDx2e7D/nZMS3ZVNN6JoFxWneSY ZI8HF7/Pq8jLpZNoEPTH2lDbtGs65T9PrJZu712q7vIHr/0XHLjCQENpCIg+4pBZyBOq h3XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723041421; x=1723646221; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2dwqefJrW9rwKNczJFJLQZg3FlWMNIdrY4uVLwJBFYg=; b=fO/3uxOgsJffiPvaDHRh/H0CNk9FYP8xmLwm2MMiYXLcrA51WxsspH15Y+UMmslY5B A2oHxZ8UBH5A7A7qgpuZ8V+VeWAiJn4nnkK5FlrRNhxbjW1AxEKK0LnJoUl7AuvorYce PR2a4Tx6Y4aQQVyakWOS5LnBtJIAlPNf2JY5ro4GZZsYa9OXiYYhGTfD6nHYpSNz2l6Q R9oiS33ziPn4VSSJTbuzZapgo92EQ6RFA6z1bYYI3dnB9H3jYJyJSuDu9c2DgPvKtwNG X3gRmgaIebCOPae/zHucyFE/MgHkYUeKMOmhn0yCQFKlXNTje28uITnHhhb1XMAJhe/1 GtNA== X-Forwarded-Encrypted: i=1; AJvYcCUxaiISK70JZgPJMcjbwS6F6JXkGWtuGKlo21p4m7j/Y8zpIGdgVkQmXEPl5VW2SfTPscSTmp7yaTJwzHiIRWyHJdZ9mqrGxvf7UwKd X-Gm-Message-State: AOJu0YxOa5sYAzQFjz0pax3kDBnm6sab3HK2lCMZlmqMsvGDOiVAgBNS iz6Dq4iZbo+/+/irV/EybU5wV7uWIVi1iMeYBxnRxEux+go6Ay7P X-Google-Smtp-Source: AGHT+IFo95uJeOhInmCfMEUftqVKSp+QyospbsgBUTVKcuwkNJcPb/X6H1+0glbn9pI9I9dsxsXLgA== X-Received: by 2002:a92:d38d:0:b0:375:9ff9:7cf4 with SMTP id e9e14a558f8ab-39b1fb78dffmr169255925ab.4.1723041421467; Wed, 07 Aug 2024 07:37:01 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39b20ae3537sm45396855ab.61.2024.08.07.07.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 07:37:01 -0700 (PDT) Date: Wed, 7 Aug 2024 09:36:59 -0500 From: Nathan Bossart To: Bertrand Drouvot Cc: Sami Imseih , Tom Lane , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: Restart pg_usleep when interrupted Message-ID: References: <33287B8A-3CA0-494F-87D3-C9D85C6468FE@gmail.com> <19E276C9-2C2B-435A-B275-8FA22222AEB8@gmail.com> <50E1D6AD-3E51-4E45-95A7-7B20DC037DCB@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Aug 07, 2024 at 06:00:53AM +0000, Bertrand Drouvot wrote: > + SleepEx((microsec < 500 ? 1 : (microsec + 500) / 1000), FALSE); I think this deserves a comment. > +#define INSTR_TIME_ADD_MICROSEC(x,t) \ > + ((x).ticks += t * NS_PER_US) I'd add parentheses around "t" to ensure any expressions given as "t" are evaluated first. Also, do we need to worry about overflow here? It looks like the rest of instr_time.h is oblivious about overflow, so maybe this is better discussed in a separate thread... -- nathan