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 1rXlNz-00CWfk-Ig for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Feb 2024 17:07:00 +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 1rXlNx-00CDMN-4J for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Feb 2024 17:06:57 +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 1rXlNw-00CDME-Mw for pgsql-hackers@lists.postgresql.org; Wed, 07 Feb 2024 17:06:56 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rXlNu-005ZXr-4B for pgsql-hackers@postgresql.org; Wed, 07 Feb 2024 17:06:55 +0000 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-7bee8858a8aso36567039f.0 for ; Wed, 07 Feb 2024 09:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707325613; x=1707930413; 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=OGouH4KEWTbRyyvc1Q+xBubRkyoBszR+hH4+tz8dw/I=; b=aaiUPuaIO8Z9ZvGF/FGstPUN5q8lULzKzxNxAsE3lnxIG/IzeG+WBt0qvVBmBw1goq uwdJQaCgAqPeeRwlLEw+7VTKLsZyEMsl157XM0QTsKN+HxziuaYipbkxoaLQSk84o8P3 ivQx/8yZN0hn7c+F4YN3yGY2LjnOdAXBenZ+J5IG1KMO7frRD/WSHRSt5CLIJ3EOR8yh 2KTCc0B6cSmZzgNdaAP7LTCrk+3/IrWanb7/zj3zIYw0SOcPRlZ8604VLlYCCo+ajVhJ xMPbfpFn5+ARWcLytGsK8wn0e8QaWlNjdnlvGAxYW3SqCvIdO49zkdJq7RfDEnoVLq57 NTpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707325613; x=1707930413; 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=OGouH4KEWTbRyyvc1Q+xBubRkyoBszR+hH4+tz8dw/I=; b=X8nvl/gITcak2k52MdmyA6Sadzd+vzAS34o811jL8H718UyBfvcYJbVnnzQB2lNijq lmLOMkIlUnhBFLee5lsd+hbUlYX16Gs1or3YxI1wkm9lhSh/W/inr6GrSP7L12MZVKxH k5iUZHoH20ZacjKm7IlzosuVAZ1BQ34kD1r13wdftYvlWRuoAFVe/XEeo+UdvlQVUEJd CNz5tBAKJYV8Pj9Yyn9JIm+ZN9RdNL3/BefSGgeRCGe9QQYRw/bvbo+vUwQrXblVJ4mW 2ACtMqBzsUKsDubErAnmSz27wQm0xs5lF7R4iZSYbQ7bZtKaez0s7Ttv9nrmlABWKHFA jb8w== X-Gm-Message-State: AOJu0YxuKlQwdtTBjrsJXycbaUsrtVAbCGzJefRcWs4GHD9n7S4XtPVs ZmBqR57W2nuArfZlEQGCbEuB+41ixcMxB2q+NjPBay4NUs/0m5c2 X-Google-Smtp-Source: AGHT+IGqxb0ROKM8Kj2RiYWmU/rTIWENgpq+ZbdcWz6Mw3v4JaXEbJo/dYJ1xHn+H61qCUVu5euUTQ== X-Received: by 2002:a5e:df42:0:b0:7c3:fdfc:3731 with SMTP id g2-20020a5edf42000000b007c3fdfc3731mr2460262ioq.2.1707325612926; Wed, 07 Feb 2024 09:06:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWZkZGYPp+Zas111u3cm3YjaOJl/iuSQkBjiFNduwgzlTELj64eKnVtGfMVAO6czjxytX3PQ4o6jy7ATXW8mIJv8A== Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id t12-20020a05663836cc00b0047153f09f83sm195587jau.13.2024.02.07.09.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 09:06:52 -0800 (PST) Date: Wed, 7 Feb 2024 11:06:50 -0600 From: Nathan Bossart To: Andres Freund Cc: pgsql-hackers@postgresql.org, noah@leadboat.com Subject: Re: common signal handler protection Message-ID: <20240207170650.GA80671@nathanxps13> References: <20231121212008.GA3742740@nathanxps13> <20240207023941.GA67817@nathanxps13> <20240207024853.pg55gxzmqxi3nrmr@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240207024853.pg55gxzmqxi3nrmr@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Feb 06, 2024 at 06:48:53PM -0800, Andres Freund wrote: > On 2024-02-06 20:39:41 -0600, Nathan Bossart wrote: >> I finally spent some time trying to measure this overhead. Specifically, I >> sent many, many SIGUSR2 signals to postmaster, which just uses >> dummy_handler(), i.e., does nothing. I was just barely able to get >> wrapper_handler() to show up in the first page of 'perf top' in this >> extreme case, which leads me to think that the overhead might not be a >> problem. > > That's what I'd expect. Signal delivery is fairly heavyweight, getpid() is one > of the cheapest system calls (IIRC only beat by close() of an invalid FD on > recent-ish linux). If it were to become an issue, we'd much better spend our > time reducing the millions of signals/sec that'd have to involve. Indeed. I'd like to get this committed (to HEAD only) in the next few weeks. TBH I'm not wild about the weird caveats (e.g., race conditions when pqsignal() is called within a signal handler), but I also think it is unlikely that they cause any issues in practice. Please do let me know if you have any concerns about this. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com