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.96) (envelope-from ) id 1w094a-001eeT-35 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 02:13:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w094Y-0078AU-07 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 02:13:18 +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.96) (envelope-from ) id 1w094X-0078AM-2M for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 02:13:18 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w094V-0000000240d-1I2X for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 02:13:17 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-66325f30570so39372a12.1 for ; Tue, 10 Mar 2026 19:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773195194; cv=none; d=google.com; s=arc-20240605; b=ALCP/05VCbJnAw2Nhp5GFOTnXhlDyrikD07sMmAZuLmXEF7k4wqLvXbGpXLxYdvOgU gSxdl1mnk7+PZIpujW783TyQnd5RKPh72W1ZNj3i9793udfJB7XC+PrNFcoJ51PeaLm7 +huGWuPtm8TSm8r3Q/moJZO+a3uriQPIvm07yLPHp7+kBfAmhymdZZ4E+Uy6LoqkylkN dHReLu0+/gGEd7eH94PGiAc+Tfm0zlhnGLkr/nqBz9XqvAGtLaeQpjnEFmAaPJa++mA1 Kg7EXcp/cRKtHnwMq9FPc/HzqKpQw/1Lvq9OiZC1ZXWB5bVc387qQKU47qbrfxbLKI7v OKLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8GcShdxsmLjQOUzpdqlpT1QYNZDwIYXN0JPrwc6kn9I=; fh=o1RNqW3VHlmYu0991lFdj+VPrNRmyQZAGuUx/mOgl5Y=; b=ZOa6McTf8Ibm3GytB53CxYQgUotd9IAS/rZrgYUgl99nINCk4UTlLxDlusT7fitWDK 4hnnBKRXOzFAVvHQQE7kgF7DfLRUM2uOmdUqfOpgxs7Qk21m3pOt9d9aiT0wxBqyCcSY AMLu5sfRCQRdfRo40UdKgOxigBkQz906tdHzJyjxVptOqR4F57DMQjXxndJHpVzbu3Oe sifPomaTwttwIT8UhK+uNeYe6BWO6bogMPay0UjcYohmgfCVdtkCoVaRq0xy3NHb4KQF J7acv3fY7TJVrio80r8SgRZAQxICrVF5nB+k0LvTX7FhiQOR+5oKWPEUnlcRwtMdEP8z ZUPQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773195194; x=1773799994; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8GcShdxsmLjQOUzpdqlpT1QYNZDwIYXN0JPrwc6kn9I=; b=SHlSKg78gqC3geZN/8ZIHCVYcTTJQrPvEWkdTStyi6QzUJLtMy7QPS7Jmca/QlaAIG SD97Vyhpjlxl4tXsuJ18BjFfdZWYIx7KhfCunjQ/uW6CXjGbaPc/lNfJDerS1Ow57Zo/ tDIok8QMdG3ozS1/4fKgqC8m3OasY+DXznx4rOjrTu2/pHNbgRD4JDA2XrmFtfyjZYMy Zaf9kTzbxcq6QadAxu65FuDZOlppuO/Esud+eiPBhn7BCHMGwO77xPDH9+KzaXelHVFX ZJrebLU4h9WnL7z2rJQLL+z5edj2XnakWM1vqfmoFfC1a82y2f6oQpcl0pe4RypohhWH SvzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773195194; x=1773799994; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8GcShdxsmLjQOUzpdqlpT1QYNZDwIYXN0JPrwc6kn9I=; b=HLQLQdjE/OS1WMGEP6hD5f2sOt2z28wEQOGx7YUMd29OUGpuOfsIXsXaMq0qDe7Ze+ s/EK3sb2uFEycLd0GlRhPjzKygLjtM1llgDWKK3xFpCMvknE7UdX+8+8ix0ipETrBUVi CyquwuBFpHU2y3BICP5qwGaY76MicFK2gyD7M+AsplSUE6+JnTecGcrArabIFMWyyYVq j4bVJeSoVi6ccYA3hrYxqTr9yYarMF3oct4Wrp335dvtDBathDU67n3j5YSG60VoVIL1 pJ+W8kDlg3xZ5zyvXZRLV8bTSuaf13UZ8dV6oPR/dDdCj3Id4NbC0J+jSprV0t2MH6pw GJFA== X-Forwarded-Encrypted: i=1; AJvYcCWqVGc7U4remeSRdGku657NZZ8md/rmIIQ2lb2Za0HWEJQu7qDp6MOKnjoDydphpxxaBZoGhWhXnaRIeHgD@lists.postgresql.org X-Gm-Message-State: AOJu0YynsY40m0zlCCOp+6I2+bnXw3zINnKt9iG908MYJoCOExpkp96W DhZGPKNiz2BSVsLKNIl7KrEHoUjR07CdYSWuAdjPZ5Uhzql1k37kqV83Wui9drjaOikq7EmpVFp xH0wD7kxNW9S8f9n6amJZi3uPTX/jCSU= X-Gm-Gg: ATEYQzyHMCDR/qBQyK9jsE4CLvokJk+8cZnS6Hz5Sj3H3Ux+21guHH9WnYmmYZXIpC/ bdwfdFZkUMRacTGDsEBkHPLiTmMLm+MUEt8yk8aLwAMuov2vRbtAiZYXyx67CmvHd6uCtZg9XWp 8e/lUTQ3U9HEUNsLHZJT3DcihveXHJMuKu7CJHvmWp0f5PxWrZc1HImu1NS7C6mztbmEP/YmPlC 5mNb7PT1zJnfn+0ng7sCmWmeN7gAUCCbfqrnql3GzHzSfRqeZBLTpzTLifPbrKDBidcjb0c8wkA x6oI5kCR3s2Cx9OzfEFt8jO+8EZrPtLD/ZC3w8otoPMHR6H5mTaufVztu/LTQRjMxUwZe5hNT1+ CJM4skP3i X-Received: by 2002:a05:6402:51d1:b0:65c:b71:e69e with SMTP id 4fb4d7f45d1cf-6631798dcb0mr407834a12.8.1773195194137; Tue, 10 Mar 2026 19:13:14 -0700 (PDT) MIME-Version: 1.0 References: <6vfwrw7xci7pccrfcne5ekvjw5l2uvjsjzpmgi356h7y2rkojx@6ogr34zctcue> In-Reply-To: <6vfwrw7xci7pccrfcne5ekvjw5l2uvjsjzpmgi356h7y2rkojx@6ogr34zctcue> From: Xuneng Zhou Date: Wed, 11 Mar 2026 10:13:02 +0800 X-Gm-Features: AaiRm53USe1qCQuY2JcwXbWPl1V9ZyK_5nHAZOGbPlLapwaccSlkrsm3y8Ocw2s Message-ID: Subject: Re: Streamify more code paths To: Andres Freund Cc: Michael Paquier , pgsql-hackers , Nazir Bilal Yavuz Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, Mar 11, 2026 at 7:28=E2=80=AFAM Andres Freund = wrote: > > Hi, > > On 2026-03-10 21:23:26 +0800, Xuneng Zhou wrote: > > On Tue, Mar 10, 2026 at 6:28=E2=80=AFPM Michael Paquier wrote: > > Thanks for running the benchmarks! The performance gains for hash, > > gin, bloom_vacuum, and wal_logging is insignificant, likely because > > these workloads are not I/O-bound. The default number of I/O workers > > is three, which is fairly conservative. When I ran the benchmark > > script with a higher number of I/O workers, some runs showed improved > > performance. > > FWIW, another thing that may be an issue is that you're restarting postgr= es > all the time, as part of drop_caches(). That means we'll spend time relo= ading > catalog metadata and initializing shared buffers (the first write to a sh= ared > buffers page is considerably more expensive than later ones, as the backi= ng > memory needs to be initialized first). > > I found it useful to use the pg_buffercache extension (specifically > pg_buffercache_evict_relation()) to just drop the relation that is going = to be > tested from shared_buffers. Good point. I'll switch to using pg_buffercache_evict_relation() to evict only the target relation, keeping the cluster running. That should reduce measurement noise to some extend. > > > > pgstattuple_large base=3D 12429.3ms patch=3D 11916.8ms 1.= 04x > > > ( 4.1%) (reads=3D206945->12983, io_time=3D6501.91->32.24ms) > > > > > pgstattuple_large base=3D 12642.9ms patch=3D 11873.5ms 1.= 06x > > > ( 6.1%) (reads=3D206945->12983, io_time=3D6516.70->143.46ms) > > > > Yeah, this looks somewhat strange. The io_time has been reduced > > significantly, which should also lead to a substantial reduction in > > runtime. > > It's possible that the bottleneck just moved, e.g to the checksum computa= tion, > if you have data checksums enabled. > > It's also worth noting that likely each of the test reps measures > something different, as likely > psql_run "$ROOT" "$PORT" -c "UPDATE heap_test SET data =3D data || '!' = WHERE id % 5 =3D 0;" > > leads to some out-of-page updates. > > You're probably better off deleting some of the data in a transaction tha= t is > then rolled back. That will also unset all-visible, but won't otherwise c= hange > the layout, no matter how many test iterations you run. > > > I'd also guess that you're seeing a relatively small win because you're > updating every page. When reading every page from disk, the OS can do > efficient readahead. If there are only occasional misses, that does not = work. > Yeah, the repeated UPDATE changes the table layout across reps. I'll switch= to: BEGIN; DELETE FROM heap_test WHERE id % N =3D 0; ROLLBACK; This clears the visibility map bits without altering the physical layout, so every rep measures the same table state. > > > method=3Dio_uring > > pgstattuple_large base=3D 5551.5ms patch=3D 3498.2ms 1.59= x > > ( 37.0%) (reads=3D206945=E2=86=9212983, io_time=3D2323.49=E2=86=92207.= 14ms) > > > > I ran the benchmark for this test again with io_uring, and the result > > is consistent with previous runs. I=E2=80=99m not sure what might be > > contributing to this behavior. > > What does a perf profile show? Is the query CPU bound? The runtime in my run of pgstattuple was reduced significantly due to the reduction in I/O time. I don=E2=80=99t think running perf on my setup would reveal anything particularly meaningful. The script has an option to run with perf, so perhaps Michael could try it to see whether the query becomes CPU-bound, if he=E2=80=99s interested and has tim= e. > > Another code path that showed significant performance improvement is > > pgstatindex [1]. I've incorporated the test into the script too. Here > > are the results from my testing: > > > > method=3Dworker io-workers=3D12 > > pgstatindex_large base=3D 233.8ms patch=3D 54.1ms 4.32= x > > ( 76.8%) (reads=3D27460=E2=86=921757, io_time=3D213.94=E2=86=926.31ms) > > > > method=3Dio_uring > > pgstatindex_large base=3D 224.2ms patch=3D 56.4ms 3.98= x > > ( 74.9%) (reads=3D27460=E2=86=921757, io_time=3D204.41=E2=86=924.88ms) > > Nice! > > > Greetings, > > Andres Freund -- Best, Xuneng