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 1sSLn5-006XdW-Pv for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2024 19:18:47 +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 1sSLn3-00ArYY-2o for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2024 19:18:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sSLn2-00ArYQ-Kv for pgsql-hackers@lists.postgresql.org; Fri, 12 Jul 2024 19:18:44 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sSLmz-001kCx-GY for pgsql-hackers@postgresql.org; Fri, 12 Jul 2024 19:18:43 +0000 Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-8036ce66134so97947439f.3 for ; Fri, 12 Jul 2024 12:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720811920; x=1721416720; 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=SjUl3l5dj2gmIvLK7sMSS4MsCVJzPQRrG/XnHd81zHE=; b=ms2AZ0od2mmsUl/bltTQJ4BbKjgpHUSJVUhaoc6A+76RUVYIcqARukUSIX14oU1VK2 ryptYlwxG1HJEFPktlG1CYM/ovO9QgvF3dB39KvbXum+sbJFI19AujGNzmYfkq+izvn0 T/+GILnUpdhKeBODtpXKlrkoVcq44Z3xhR99+hO+jmgMDX2bALTG2Glx9+V4erIJfgPJ C4w9ukGezfHkLspFAwEQI5i82/+y8NZ7OJZyssPA3j2W1C/hCLVTwDlZcji23StGOTKT AqRIUr5UCClr/KWyVR24jFxWLhmcFCdU9/M3LUWuMuFb96wKB00e0BRCPgvjlBe/6Nf/ ZE5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720811920; x=1721416720; 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=SjUl3l5dj2gmIvLK7sMSS4MsCVJzPQRrG/XnHd81zHE=; b=YAMLJFjxtSZrdb7d+ZNix1Evt5j9saVfjGo0XB7sQy1eu+GOZ7sT6SDdzL9gi/kHnt a9HEKDoLkGHWs8yQ0z6BZnYJ0IUOb7uLIJ+X+5ftgXl8qntBoxtF7PQyyWA0QAN32Mjk uJE+NDnMwnHuG7ESTTTK9fgsiMhDc4G+sgWz2pezEGJo+EuOKwKC/9mwEcS1TFWDAJKx DSbstgmVFqTKjVhxVw9wa96ZjD9q3m7x+QP+Lcr1DnWR9uWZP+FZO5KKENVbcfxqHzlJ UnY10pRqiruS7LQgNle4XjjuntZ44Hj2BuL6Dj1LiyiadKSzpA7R6vCrqYGZT2SfX7Qc s2Ow== X-Forwarded-Encrypted: i=1; AJvYcCXZihQlnYpz6EnUka3fPQK86V/fTe7Mr3Yxes4TcvIJqcUiRzCkTKDP4+SHzu2NwliEOkqmKo+Qfk0/VNF7V4dZiuGLkyvXrqXVb5YV X-Gm-Message-State: AOJu0YwfpM4ch7Ltty/iplMx3BWN5AYG2b6ZpSd3TowOorR/39PtRtc9 m7IcIT9azqDLZQI+fjsOo6izKRLKdKCY3I7+awQMaPDFaE8c3MHM X-Google-Smtp-Source: AGHT+IFpNOEZLh6eRdO3bn4k35onlkNnc1G9YGtdEqZCGSIAjzOWxdhElrc2LVlAc+mARv3nlukGQg== X-Received: by 2002:a6b:f107:0:b0:803:cc64:e0d4 with SMTP id ca18e2360f4ac-803cc64e3famr1090536839f.3.1720811920044; Fri, 12 Jul 2024 12:18:40 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c0b1c12accsm2576413173.153.2024.07.12.12.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 12:18:39 -0700 (PDT) Date: Fri, 12 Jul 2024 14:18:37 -0500 From: Nathan Bossart To: Sami Imseih Cc: Bertrand Drouvot , Tom Lane , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: Restart pg_usleep when interrupted Message-ID: References: <373D199B-2312-431D-8018-F2808913F979@gmail.com> <3712E898-03DA-4E03-AF51-D3E24DE68216@gmail.com> <2F781744-69B8-4BC2-A6EF-3998DCCDB634@gmail.com> <01A15AEA-C35C-41DF-8E81-3B5A0B523939@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01A15AEA-C35C-41DF-8E81-3B5A0B523939@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jul 12, 2024 at 12:14:56PM -0500, Sami Imseih wrote: > 1/ TimestampDifference has a dependency on gettimeofday, > while my proposal utilizes clock_gettime. There are old discussions > that did not reach a conclusion comparing both mechanisms. > My main conclusion from these hacker discussions [1], [2] and other > online discussions on the topic is clock_gettime should replace > getimeofday when possible. Precision is the main reason. > > 2/ It no longer uses the remain time. I think the remain time > is still required here. I did a unrealistic stress test which shows > the original proposal can handle frequent interruptions much better. My comment was mostly about coding style and not about gettimeofday() versus clock_gettime(). What does your testing show when you don't have the extra check, i.e., struct timespec delay; struct timespec remain; delay.tv_sec = microsec / 1000000L; delay.tv_nsec = (microsec % 1000000L) * 1000; while (nanosleep(&delay, &remain) == -1 && errno == EINTR) delay = remain; -- nathan