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 1uvhDt-00HWcg-GD for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Sep 2025 19:08:18 +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 1uvhDs-00727n-26 for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Sep 2025 19:08:16 +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 1uvhDr-00727f-K1 for pgsql-hackers@lists.postgresql.org; Mon, 08 Sep 2025 19:08:16 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uvhDp-001CvG-1l for pgsql-hackers@postgresql.org; Mon, 08 Sep 2025 19:08:14 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-7742adc1f25so1827587b3a.2 for ; Mon, 08 Sep 2025 12:08:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1757358492; x=1757963292; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=zSSnSqPc423uLb3pQihiIUrEupEYmSQeAboXHB6OrDc=; b=vNadoJp9KOGBrXQHeNEPuN+8yXqP028T7MK8IQjuzTuVVdjv4kd0wenBStqkOxy9+j Yf1MvxNqF+tsAUW7pE8qMJaGjFbmiWhLKUovnoGMxTb36WMT4jL7P+7BdrxM29JvP4Al /lWNmi980E8hT6h9mb24qqpiAnNicP3I1bTZfA2sr8U/UmVgpENtI/lSixvu6rUhI1ar t5S9t1znHrKG+hrkslnl4KDYkzMiLiJBJOdmERNCK0FPa7NtC3wIVIgXHBqYPwcWbHf8 OgoNVhN2E7u4YzfC+p3FvTWWx1CNKF9PiJCNcnDDZakqABcqy1dxutB4Bvq12vL8aowT diVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757358492; x=1757963292; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zSSnSqPc423uLb3pQihiIUrEupEYmSQeAboXHB6OrDc=; b=FFIUfUExPZRGigx0eUtBtA9i/21zFXhT/L6N2wDj2/8ky8qnpvQ9L41YJGUxVwib3s CtTzNCtGLg/R2poCwmYdOuxEfXv72ElxRx4W3nCeE3/zgYxcgwIgHEcr1VO8xl2HOjxF pE+CVkSxtv3t2zLdt4YeX0/sn1N1masGf0Qi42QB3J5oaNWK1ErzmrM2hVdMe22J8p8m 8tRR85FrjywgVb1jGOlx0myJj0hT4p2YU/Qi0qHaFmChC/UU3NRS3bQTCWas0tzi4L7X O222u/15+EfYgAIoPX93a8K/9jOEnD6C8jL7nSDxyAQtXseFDjNu1irDv+SGIF6fxnQ5 Ch2Q== X-Forwarded-Encrypted: i=1; AJvYcCX+z/qQoWghs/7fbUFAhFkIE+1gDSb3vgylRzaGUNRu/cFP9I6LTgVCpzMlp9RuVDN52yItpLtpEaMCas19@postgresql.org X-Gm-Message-State: AOJu0YyVV/S60CXpOe3q0D/tRc6SwJozo8+zvZ4Z/k35VsBkdtteDpsf 17gfAPrkcSaDvkLuntQnXBIEtTBlnGeQms6uYolLjsVDPdG6rOPa81ctFWaJ8fpmgQ== X-Gm-Gg: ASbGncsbtOp6tKIHZrS4X+wbFq3Kk8OxeVtO3YpD/wBMv+5weTRUWeTTmB1J/f5GdDo tUQIl0sr+5tKJxE/s1EBkH3gZl0LEttiXeeHg1vsZW7LjwDRexfWgpmz98W1qRxVI5AL9UqC4uT tjBB2L+/Uibey5JJk8qCO+qGSL0/6mwGUPZaA4cAeM3AC7rdRx9hFW1A4HbNLgeN1TeuFdWwMtj g24ABw6hg6VI2WsIb5TwJr0teKAmekWnO/CSYhM7cGOmQcQb3bqyzd0UGl/2NQsf1pkvA37dFaD 5RKB1IUkA6+lKEIS4ei6G/BLWKQ59nXEs3ew2wCh6VC7CgbQxXo8a2pD6LKBvtUYdpiXTtr+aaA TpKJfihHtdM9apdaRzan2Yr5nHXRFrlnw X-Google-Smtp-Source: AGHT+IFeOjEVBIVFuu79rYP60gOiQcd5MqL98Of8lnUXlrg15uIMpdXZjt/TyLcpUFIUm58beorawA== X-Received: by 2002:a05:6a00:2e07:b0:771:e06b:7edf with SMTP id d2e1a72fcca58-7742de14879mr11994212b3a.24.1757358492022; Mon, 08 Sep 2025 12:08:12 -0700 (PDT) Received: from [172.18.4.31] ([12.126.244.130]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-77277ca2a1dsm17872174b3a.80.2025.09.08.12.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 12:08:11 -0700 (PDT) Message-ID: Subject: Re: Should io_method=worker remain the default? From: Jeff Davis To: Thomas Munro Cc: Andres Freund , pgsql-hackers@postgresql.org Date: Mon, 08 Sep 2025 12:08:10 -0700 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2025-09-08 at 14:39 +1200, Thomas Munro wrote: > Some raw thoughts on this topic, and how we got here:=C2=A0 This type of > extreme workload, namely not doing any physical I/O, just copying the > same data from the kernel page cache to the buffer pool over and over > again, Isn't that one of the major selling points of AIO? It does "real readahead" from kernel buffers into PG buffers ahead of the time, so that the backend doesn't have to do the memcpy and checksum calculation. The benefit will be even larger when AIO eventually enables effective Direct IO, so that shared_buffers can be a larger share of system memory, and we don't need to move back-and-forth between kernel buffers and PG buffers (and recalculate the checksum). The only problem right now is that it doesn't (yet) work great when the concurrency is higher because: (a) we don't adapt well to saturated workers; and (b) there's lock contention on the queue if there are more workers and I believe both of those problems can be solved in 19. > is also the workload where io_method=3Dworker can beat > io_method=3Dio_uring (and other native I/O methods I've prototyped), > assuming io_workers is increased to a level that keeps up. Right, when the workers are not saturated, they *increase* the parallelism because there are more processes doing the work (unless you run into lock contention). > didn't matter much before the > checksums-by-default change went in just a little ahead of basic AIO > support. Yeah, the trade-offs are much different when checksums are on vs off. >=20 > Interesting that it shows up so clearly for Andres but not for you. When I increase the io_worker count, then it does seem to be limited by lock contention (at least I'm seeing evidence with -DLWLOCK_STATS). I suppose my case is just below some threshold. >=20 > BTW There are already a couple of levels of signal suppression: if > workers are not idle then we don't set any latches, and even if we > did, SetLatch() only sends signals when the recipient is actually > waiting, which shouldn't happen when the pool is completely busy. Oh, good to know. > +=C2=A0=C2=A0=C2=A0 nextWakeupWorker =3D (nextWakeupWorker + 1) % io_work= ers; >=20 > FWIW, I experimented extensively with wakeup distribution schemes=20 My patch was really just to try to test the two hypotheses; I wasn't proposing it. But I was curious whether a simpler scheme might be just as good, and looks like you already considered and rejected it. >=20 > I would value your feedback and this type of analysis on the thread > about automatic tuning for v19. OK, I will continue the tuning discussion there. Regarding $SUBJECT: it looks like others are just fine with worker mode as the default in 18. I have added discussion links to the "no change" entry in the Open Items list. I think we'll probably see some of the effects (worker saturation or lock contention) from my test case appear in real workloads, but affected users can change to sync mode until we sort these things out in 19. Regards, Jeff Davis