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 1vDdUT-00Cj0U-V4 for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Oct 2025 06:47:33 +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 1vDdUS-00B9EI-Pp for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Oct 2025 06:47:31 +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 1vDdUS-00B9EA-F1 for pgsql-hackers@lists.postgresql.org; Tue, 28 Oct 2025 06:47:31 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vDdUO-004eUa-2N for pgsql-hackers@postgresql.org; Tue, 28 Oct 2025 06:47:30 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-782e93932ffso4153959b3a.3 for ; Mon, 27 Oct 2025 23:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761634046; x=1762238846; 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=0CeXjyJ1rkCR3MXUlGWiKjJMtr15NgbXtOHeWAUE2Pw=; b=YHk9HzSWPlsqwEy5gUkRtM/RwSAO0kDs6KqBC1ZG2uq0eLeGJu2KUoa52ej/4h+uK2 mM0RaY6SdFKjHtFTKdVV5qtMywX0C9JyChymhXliFNaOJgphDYzEtzhuda6kWVdI55nh +/wW1djOwoYbJp+932/p7ew4QPW/U+jSsi6NHJIRPtIytlF+gB2BykIgXFQtw7PfRoBR zfntDfLukMlzwaI/lUZ2RE7DVogBo0/gIBrUROkLJXiPkgoNg24WILo9g5UEqTfdYYR6 2IajK5RgtdnUQ1OmZRDy+40fxWlOUAIj2eqv2nbbdQJjf5Q8Kv7d6o6T85xiV3X6Og8X xt0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761634046; x=1762238846; 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=0CeXjyJ1rkCR3MXUlGWiKjJMtr15NgbXtOHeWAUE2Pw=; b=KXZzI6WjEFiZXapECTJ/LozaVqVVtfoJM696dQIU/7ySE0HE5KEGSWoL6mVrILF+jt 3aUNNSyQfwro7ekRGMFR7kinwamNyNZnSMzt6MZhMILFIB4XfPPfWohflrNxlBcoifK/ ldNagT/aTOBWADThHSBttdEsGB0mkSwqbFi5qpdl1IZiobNzWPMimVYiSJvt3Q47UfRR 4yxpsEM/L2ym8pSuYMDTzlMXuvCRbOZUczJpsz3T0voBH6CPp7l5Sq/XnrZiEH8gvZvF Ogik2S/TnlaTnlzyuRtXlL5fq/+uSP9n/uyR0PrVaSIm46Y4EX42BAKS+wsf/LiO69Oy gZQg== X-Gm-Message-State: AOJu0YxGH5L6+4DLk7O+FqSLy9kW/RzOfCf+yNoM2/NWb2hNsP3vXyf8 7MEtBRxVlRlA+8zBoO3YpsWZOx9kIVtyZ/lOAv4hzoL8Nym3LkiBIvU4xr9RBKe97ck= X-Gm-Gg: ASbGncvBnpEmXBq58vPgMVgSImZQrtFqC6k2pnnhZHcddJcv/IN/6mj7yIcGv4yPB7x 1dWGGv/VbsAODCAAgEFG/4SDJihVJaWI1AXPcWrErVmaXqViZMfgmBWMzaCz0xCt9K5OjE0dcui nRNcOST68QLyoMzuk4hXKFJ95Ax/r29ixSDwMe7FdwpO7FbgY8bSX27KIbHZ38k6l0gdpAh0yAC G8dPOizj31D+e3KMv56hz4cLRIFvePGpsua0961Z3ee/pipn46zCpFW32LJJfe4FduKUiCfRQnG 9fgGBN/c9V2d5tIRhzXXWnvJTFg4yYjqpeeYay4rGMHBGrnfh64dJ8SoND80nxC+8qz4DATdIsO BfBp/TgNvVbt0O9VxRsoEI4Sc5mPi22Jj0Cmk1kwDDUGsfVzVog8GeRBki+Yv1cScS7IbO3HDwU ZSrtM6+uf7ER8= X-Google-Smtp-Source: AGHT+IHaTkXrGT6PwBX45KP2r6VRJNQrV5FbN4VHYW8VxHWIxzg7P8z/1DxOkEpCrMRW7Ig/82wHVw== X-Received: by 2002:a17:902:f684:b0:266:cb8c:523 with SMTP id d9443c01a7336-294cb671778mr33027515ad.48.1761634046016; Mon, 27 Oct 2025 23:47:26 -0700 (PDT) Received: from smtpclient.apple ([170.178.170.211]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29498e42f5csm102930955ad.104.2025.10.27.23.47.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Oct 2025 23:47:25 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: Optimize LISTEN/NOTIFY From: Chao Li In-Reply-To: <38de1036-d8cf-420c-b845-edb5a946b191@app.fastmail.com> Date: Tue, 28 Oct 2025 14:46:50 +0800 Cc: pgsql-hackers Content-Transfer-Encoding: quoted-printable Message-Id: <87E40BF8-8877-4DBD-9040-99AF8A4E6358@gmail.com> References: <6899c044-4a82-49be-8117-e6f669765f7e@app.fastmail.com> <165530.1752362320@sss.pgh.pa.us> <02a7cd37-e2fc-4212-8b19-f8c239c95fb8@app.fastmail.com> <96f00bf1-cc9d-4520-9d02-9e14e7767c88@app.fastmail.com> <30c2aa7d-dd6c-4b68-a2e4-f217a1a34acf@app.fastmail.com> <0b4d402a-9ac2-4aa8-acf8-8231dbe579ea@app.fastmail.com> <3095599.1758644879@sss.pgh.pa.us> <0dc6a2cc-5216-4dc1-9dd2-430cafc6095b@app.fastmail.com> <52CC167F-763B-4ECA-B0B4-DAB381816828@gmail.com> <9186C6D0-F7A9-482A-9183-89E530B57E36@gmail.com> <1073593.1759423179@sss.pgh.pa.us> <4bd5e6c4-6fa7-44bb-869d-59a32a331fa8@app.fastmail.com> <85828f29-e72e-4400-94f3-9a69bc8dc239@app.fastmail.com> <2495353.1759860890@sss.pgh.pa.us> <8aeae418-92a6-4bbd-9c06-9574c79e59f7@app.fastmail.com> <2531672.1759868124@sss.pgh.pa.us> <474efa78-337c-41cd-a73a-f845a0115109@app.fastmail.com> <2749343.1759949176@sss.pgh.pa.us> <8bfca2be-1ec0-4e15-aafb-0b7b661fe936@app.fastmail.com> <9eba307f-f2fb-48f0-9507-2e197f39ef9e@app.fastmail.com> <8c71183a-0d28-4bcf-a806-78446ff95404@app.fastmail.com> <1009807.1760476747@sss.pgh.pa.us> <1F7227F5-C33D-4E2C-8511-33F1468590D0@gmail.com> <0a5a20d3-4621-46b3-b2ab-903f63a20dea@app.fastmail.com> <6F913129-ABEF-4004-AAF3-F22FC34!29AE8@gmail.com> <1547585.1760645808@sss.pgh.pa.us> <14865EB6-0BF4-462B-9072-10BDAC10C052@gmail.com> <0BCA1C2D-B92C-459E-B1A6-6D06BA4C62CF@gmail.com> <55d24cbb-e9ef-491f-a99b-b3dbd7cecdf9@app.fastmail.com> <38574cad-e90d-47b7-a015-753bb6bbc360@app.fastmail.com> <66631FB7-5BEA-4ED5-A694-9AD8B9CCFEE8@gmail.com> <4b7b49a5-5e1a-44a8-93e0-60457d15cb1d@app.fastmail.com> <82DEA2B6-6FC5-4A79-BDE3-1FD72F104A6E@gmail.com> <38de1036-d8cf-420c-b845-edb5a946b191@app.fastmail.com> To: Joel Jacobson X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Oct 28, 2025, at 14:41, Joel Jacobson wrote: >=20 > On Tue, Oct 28, 2025, at 02:02, Chao Li wrote: >>>> =46rom this perspective, we need to add a new field=20 >>>> adviancingTillPos to QueueBackendStatus. (This field was also = missing=20 >>>> from my proposed patch). >>>=20 >>> I'm doubtful yet another field is worth the added complexity cost. >>>=20 >>> Before increasing the complexity further, I think we should first >>> try to simulate somewhat realistic workloads, to see if we actually >>> have a problem first. >>>=20 >>> /Joel >>>=20 >>=20 >> I don=E2=80=99t think that=E2=80=99s extra complexity, IMO, that just = ensure =E2=80=9Cdirect=20 >> advancement=E2=80=9D to be fully functional. >=20 > An extra field is by definition extra complexity; > If it's worth it depends on how much we would gain from it, > that's why I'm doubtful it's worth it. >=20 > The extra adviancingTillPos field would only avoid wakeups in some > scenarios, if you study the example given by Arseniy, it's easy to see > why we would really need something like a the list of skip ranges > Arseniy suggested, per backend, for it to be complete, > but that's even more complexity. >=20 > I don't think it's too bad for a backend to read through the entire > queue, even if it contains some entires that are not interesting, when = a > backend is awaken, processing is fast, that's not the big cost here, > what really costs is the context switches. But I've been wrong before, > so could be wrong again of course. This is just based on my intuition. >=20 >> But anyway, we should run some load tests to verify every solution to=20= >> see how much they really improve. Do you already have or plan to work=20= >> on a load test script? >=20 > Yes, I'm currently working on a combined benchmark / correctness test = suite. >=20 Cool. Then we can run the benchmark and decide. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/