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 1sdddF-00HE1W-RO for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Aug 2024 22:35:17 +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 1sdddE-000hLv-5T for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Aug 2024 22:35:16 +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 1sdddD-000hLm-PM for pgsql-hackers@lists.postgresql.org; Mon, 12 Aug 2024 22:35:15 +0000 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sdddA-004XQG-IL for pgsql-hackers@postgresql.org; Mon, 12 Aug 2024 22:35:15 +0000 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-81f8f0198beso233470439f.1 for ; Mon, 12 Aug 2024 15:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723502110; x=1724106910; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=DfPWApuRgmjDM0ni9dr2krEBMxHfIntSNPh5q9fqq+8=; b=YHT9UechC/C8ocKtKZ4tXxVTVyrN9saang7LUN/AmpCqAcaT8mXiIXfylOh8OueXlV hDKUHHrdmi1vQK4oLpkVghovW5YB7vGNmiAtEsJ+yLIxwoA+eqVZ2K5SO8y3D/fJvrIo UOOKJqbul6iGFVaqB+qOynLXuXJCW0Fw8FteihNXrngoTpPZXlJ6UYOFE7P5kYfHY56h qj6YyZWbKHJFgSFsRWv+kqNNV0Xy4DpBJa1d9V+sOt2HSyCBs50hPRRY4K8q1H8AhqJZ ykJjUn2e7CidgnVaen8VM9uaeTqCR5Z/wIZgduEHKGSpMMByjzJJrDB0YAkWYDHDtjh9 8VHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723502110; x=1724106910; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DfPWApuRgmjDM0ni9dr2krEBMxHfIntSNPh5q9fqq+8=; b=rmhcirnGcfa5FhJfvAtk+1t40TtOMrKPSFYfXfnxrLQfOPtLjd7hnzGcZgnA505ZS4 jH25Y+hoFWz8DrRDT+HNTg84bAuzcJVT/pytWpf+DMyfzuLwdQhEpNO1qH79yC5cIWzp YIi2uMsZJRo0KIRdKcZjyRBzn+eT8AEEGs5/SO517aS6Iqp5s+O8XawnUs6NnfXlGSoe 1Z02r58Jxw6HREXOJwFq75ezn8hTgDjbzSeRLkH+nVu+XPBs1tCVVIsXG30pjoSYlv7N gdr1Xx4aMcULssqkoqzHSxaqzz19GK7+GMbqtFLeoNC7FJuYpA4Nwpap9q40/qhbjPFc oGTQ== X-Forwarded-Encrypted: i=1; AJvYcCUJWtlrcdcQOlZmQoMjP0QhyDOzV7FWlArx9pKWAdPL4Vapi7c4Rljk8jdGAb4O2BJstlzak2uFBltxV5Cl+ZUoB0fEzXdBXyBWjbU6 X-Gm-Message-State: AOJu0YzR/v2GkCj8FPMbrlzll/8gsJQ5mGQk64vBHQVHXW17RyWGWfce jnFO68DpZyRH6cZWk2IxPseam1ZL7+wKW/to1CP1+OcnnsNgHepU X-Google-Smtp-Source: AGHT+IFATNio2eJo6FhC4srleqKbRrwv+B5tQX8Y2XSrf8fw+lAlH6OzbvJa/uCdlMmIq+XABbuovg== X-Received: by 2002:a05:6602:6d8a:b0:81f:d520:782e with SMTP id ca18e2360f4ac-824c997800fmr209985139f.10.1723502109820; Mon, 12 Aug 2024 15:35:09 -0700 (PDT) Received: from [192.168.87.22] (c-73-74-200-24.hsd1.il.comcast.net. [73.74.200.24]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-822672d5d36sm197708039f.49.2024.08.12.15.35.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Aug 2024 15:35:09 -0700 (PDT) Message-ID: <2b5ac681-11d5-470d-af40-89ead9a868aa@gmail.com> Date: Mon, 12 Aug 2024 17:35:08 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Restart pg_usleep when interrupted To: Nathan Bossart , Heikki Linnakangas Cc: Bertrand Drouvot , Tom Lane , Robert Haas , "pgsql-hackers@postgresql.org" References: <9D64CD7C-CA24-4FF4-9421-3A1A63F87DAC@gmail.com> <526E6A51-FE30-47C4-85C8-F2D18877607F@gmail.com> Content-Language: en-US From: "Imseih (AWS), Sami" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > Skimming the last few messages of that thread [0], it looks like Bertrand > is exploring ways to avoid so many interrupts. I guess the unavoidable > question is whether this work is still worthwhile given that improvement. The way the instrumentation in [0] dealt with interrupts was too complex, which is why it seemed better to handle the restart the remainder of the sleep in the sleep function >> On the patch itself: Making the sleeps in vacuum uninterruptible means that >> vacuum will be more slow to respond to interrupts. If you SIGTERM a vacuum >> process, or hit CTRL-C, you *would* want to exit the sleep ASAP. > Since the delay will typically be pretty small (2 milliseconds by default > for autovacuum), I'm assuming this won't ordinarily be noticeable. But I > do think it is an important consideration. > At most, the sleep will be 100ms for vacuum. > > Tom raised that concern earlier in this thread > (https://www.postgresql.org/message-id/2100439.1719610468%40sss.pgh.pa.us), > but it seems the discussion wandered off to the details of how to do > the sleep, and left that unaddressed. > Doing something like pg_sleep, using WaitLatch [1], was explored. However this does not support microsecond sleeps which was allowed in 720de00af49 Thomas shared WaitLatchUs [2], which supports higher precision sleeps, but it requires epoll_pwait(2) on the system, thus it's not very portable. Using nanosleep with remain time and checking for drift was the most portable approach. Regards, Sami [0] https://commitfest.postgresql.org/49/5027/ [1] https://www.postgresql.org/message-id/67072E39-3B4E-4240-8373-AC45E23721E7%40gmail.com [2] https://www.postgresql.org/message-id/CA+hUKGKVbJE59JkwnUj5XMY+-rzcTFciV9vVC7i=LUfWPds8Xw@mail.gmail.com