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 1whgEY-000MTM-2X for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 04:19:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whgEW-00AjAB-08 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 04:19:32 +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 1whgEV-00Aj9z-2J for pgsql-hackers@lists.postgresql.org; Thu, 09 Jul 2026 04:19:32 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1whgET-00000000Oy7-1s7b for pgsql-hackers@lists.postgresql.org; Thu, 09 Jul 2026 04:19:32 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-493e4ccccc2so3191545e9.2 for ; Wed, 08 Jul 2026 21:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783570769; x=1784175569; darn=lists.postgresql.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=khjtc+jhgytMwj91ysAUOwzXEDxIS/oJ2qUE8NUZXLY=; b=SffAm/8Q+3vfumde5iesW3zXy0fssw3ZkiKOJka8V0+9iJxtYMRrZaI6s92LM/GvWB Xqh2cMSJGthO9241NWI5h+Ven/Zk180j7aC87DBywiR4QZMZx5Oh1Jz3+ER3rnWVqsZf sr90kNnawUVx5WSC4DQtJNsVR/xlpROEzZ+0yPAMxTggYvGMUowHkZ8CPvRtGArUxq3x OHdqr2+iBYb0zhZuZtNBTpgXqGUzbzzn5nT+RkHoy7fz3c1En1mHFhd4uDSw8UeXdAyh CCUX9zGKaGFuRMBvB+mycPR5WtVQQOKLt5EcYmna2GzQT0nDcfJetbW8TNsD6zfYzFf4 p5qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783570769; x=1784175569; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=khjtc+jhgytMwj91ysAUOwzXEDxIS/oJ2qUE8NUZXLY=; b=O2Van+JWhWita4Nus+gFAJsawUw4aOlih9tvujj6Ixa1nCvVTNewI1ysNK1g/y95eG z6bAkCTI5NuibFpNOvFdI95BzP9oZ23oVAtuNcII8W/RexQePGvEf/nb7ussa32KBvu+ agplZaDE7SJ0V/qeGr56lIP5dm2oW8gqlZLOXQyadZhJN07Pm9KlWNcepji6x7MSjs0Z tMtM0KCa9N1yFePV4Vz2Dt/igx/AhDoY9wsW0oUhUSljOMwHL6mufeHn3zjICdMIG8IN zyhXj8IlTegkNUMJyNg8VBTdX4Nn373ppjgvH9gShQwOOgWsptvmWaQcl7QwDH3ZHeky hJ5Q== X-Forwarded-Encrypted: i=1; AHgh+RrXJZ2Cd9vtqb9W2xz5On5emBmeGnO01gWVlnqdfiZXGtv6WhJmpfJVnV4JgebJ3q5ixIRbewoKZ/yXerpm@lists.postgresql.org X-Gm-Message-State: AOJu0Yy6XzsgvoTVA7ETzwg4/hRfSWklnzeEPEzU36yyn+PeXXQofYBT gi5eS/zo+bg4WXJcv4Xj+3teCCRZKHakgiPkKooClSW8KEpQgstYjj6j X-Gm-Gg: AfdE7ckd3cladvW4L+RMgC1JOOkF0cYAhKpxv7dP9Tg5/kcgxjK++p2as1oiak4nhoB CaEcOPgazMnzxc6orxHp73GU5WTnVfT2xLzVg2dT5XouxG+ycLKCiaBTUpO80FD9sXQTT3f5ia8 Jw0Kd09raM84y4FA4433NB0OLS2DYCls2cDemvcquyjFntgioH05XQgd+UL15aJG0qsq02jZEvz vzbgpLh/aGDyVsy0/oyiD3s26JkrG3j3qjA3+V773RPDxBdZ+cZUPfZNGWx5yB5/EKIVzpnWwcU 9JhEp0xA0wRlkNbJkwEtaLYji34+mJ0x04iz1DDD1cucTVUXCf+E+YBgT6Kos2Q86PNYvzCD4l0 HIdrhpjNpXK2o+mVqCG7hnRR8yzuRgPOcmlhud1TXE9qnwJE7sPqx7CvektUqQoOQcwhhDmwLbI iD0XGZRiCdge9cwQiniAPLHSBN0BB4hK9boVSe5PwgZenh6YQnmxHjYUlPBn0o2acGfQA7ruH0 X-Received: by 2002:a05:600c:3b0d:b0:493:bc88:ddcf with SMTP id 5b1f17b1804b1-493e68df940mr45650505e9.23.1783570768499; Wed, 08 Jul 2026 21:19:28 -0700 (PDT) Received: from bdtpg (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47a9de1d91bsm52483450f8f.4.2026.07.08.21.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 21:19:27 -0700 (PDT) Date: Thu, 9 Jul 2026 04:19:26 +0000 From: Bertrand Drouvot To: Andres Freund Cc: Michael Paquier , pgsql-hackers@lists.postgresql.org Subject: Re: Add per-backend AIO statistics Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, Jul 08, 2026 at 02:08:00PM -0400, Andres Freund wrote: > Hi, > > On 2026-07-08 15:52:20 +0900, Michael Paquier wrote: > > On Tue, Jul 07, 2026 at 11:02:03AM +0000, Bertrand Drouvot wrote: > > > 1/ pg_aios that lists all AIO handles that are currently in use. That shows > > > what's happening right now, but not what has happened. > > > > > > 2/ pg_stat_get_backend_io() that shows how much IO was done, but not how it > > > was done. There's no way to see whether IOs ran synchronously or > > > asynchronously, whether a backend was stalling on handle exhaustion, or how > > > completions are distributed across backends. > > > > While the information may be useful, one thing that sounds very > > important to me is how this impacts workloads by default. > > > > Andres is usually able to catch bottlenecks that everybody else is > > unable to see, so perhaps checking with him the location of these > > extra function calls would be a good first step. Your proposal goes > > down to pgaio_io_stage(), pgaio_io_process_completion() and > > pgaio_submit_staged() to track these counter increments. > > I think the overhead might be ok, Thanks for the feedback. > but I am rather doubtful that all of this > information is actually useful. You're adding quite a few counters for each > IO, do we actually need that? > > E.g. what do we gain from counting: > - started (if you want to see the number of IOs that are in progress, > cumulative stats are the wrong tool) > - executed_async (that's just the number of IOs minus executed_sync) > - completed_self (that's just the number of IOs minus executed_other) Yeah, we can remove some fields (as they're derivable). > Separately, I'm doubtful it makes sense to have only per-backend stats for > this. I think you'd almost always want the stats for exited backend > (e.g. parallel workers) too. Indeed, adding a global view would capture their activity. > Unfortunately I'm pretty doubtful that pgstat_backend.c is the right > architectural direction. It'll just end up implementing all kinds of stats, > since we'll incrementally want more and more per-backend stats. I think what > we'd want is rather something where for each applicable stats kind we have a > shared counter for all exited backends and then per-backend counters for live > backends, with helpers to aggregate the exited + live stats to a total. That's a very nice proposal that would avoid the double counting. OTOH, that's also a major re-design that would benefit all existing per-backend stats kinds. I can see 2 options: 1/ step 1: Implement per-backend AIO stats (like proposed taking into account your remark about useless, derivable fields) + a global view. step 2: work on the re-design 2/ step 1: work on the redesign step 2: Add AIO stats based on the re-design The pros of 1/ is that step 1 would most probably land in 20, providing more user visibility (+ it could be used or improved during the AIO write project). Step 2 is a much larger project that might not land in 20. The cons, would be double counting (as there is no need to try to implement something like [1] as we are going to re-design anyway). I'll be tempted to vote for 1/ to provide faster added value. What do you (Andres, Michael) think? [1]: https://postgr.es/m/aNVWe2tR1jj5Tsct@ip-10-97-1-34.eu-west-3.compute.internal Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com