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 1slNr0-007FuE-KS for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Sep 2024 07:21:31 +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 1slNqz-008GVB-Kw for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Sep 2024 07:21:29 +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 1slNqz-008GUA-AZ for pgsql-hackers@lists.postgresql.org; Tue, 03 Sep 2024 07:21:29 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1slNqw-000PUS-RC for pgsql-hackers@lists.postgresql.org; Tue, 03 Sep 2024 07:21:28 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4280ca0791bso42725685e9.1 for ; Tue, 03 Sep 2024 00:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725348085; x=1725952885; darn=lists.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=cPFN4nTZqjWIC6t7ff4USVmo6hSWNqpCqqeoQ7HOhcA=; b=aTmGEHe9cUIpGxp1EzhRx1SImfm2PKeQc3pugtsdPfTp9PhBNrmxy6hqTiH6Troy/f EldLYTzeCqpckine6b8I8G1B/1CKx0tiTlgS5crFUFDG5OGR0s5UKzpKTJh+w0uS8cdx vNNCBL2jIiAk9yXL6R0PPHTj0yfk4wX4GvOshD478PQRoBwlLy3CQTIhf4i33Noe0FrA 2QzMBPpflEYnL272ziEIzQOhppHtVo6AiX0gSh3ZWlDVQXZPwJkqeI+MBRxHt/lMUafu fmJFs5hjw6F+6rFEQRPP25q7fugIKQ6TpJZ0w0u+5B6tSVCQsfRU3jvivPTpwgzN/eZZ 0yWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725348085; x=1725952885; 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=cPFN4nTZqjWIC6t7ff4USVmo6hSWNqpCqqeoQ7HOhcA=; b=GkgVQ0iGz1bz1Mwz/4FCRgaRxUaZp3nDwc2+zdtlpT/DFemqmfX3EFHhw7FZ5GW8u0 veKf9pDVRfvOXs1xhHxI56I/0PeuQFYCAGGeJ9DSnwNJME/wU23ycQHcDqqqKkPI9nSy uVq3HFApYn3ST5b00Qw9VqccswPw+BtwNDIgfxv1i6QrSuG6WrQOSRrPMxh6xp1TYO83 5jlb89XZsFeHN9W7YhJsKd/bvyEuTOaAyxsQcynSsG+BcTw3L9hShvhkovZTc++VV7CM BBmuY4Ob6oIu9g8sEr3gPTQtuJNb2LhX5QLctv0VY3TCrppuNiZB8/walJegplBh05kD muvA== X-Gm-Message-State: AOJu0Yz8AsYlCwSlZbpsgHUmC7vUp2S/qIw1vmShX9i0tgk/GGOTqU9P bV0ij8zL/T2k388EaNYGsqWDzmJ/4HfhPJ56LnyzPSlxp8TZmf+h X-Google-Smtp-Source: AGHT+IH0oBJ++rEZ+t11PV5K1ERTc3kteVcVkdYT/Q4QxuvtkVcDHWgFj1XKWA9zr7bF5D0Zt8Z/Hw== X-Received: by 2002:adf:ee4c:0:b0:374:cbdd:480d with SMTP id ffacd0b85a97d-374cbdd4866mr3200099f8f.36.1725348084723; Tue, 03 Sep 2024 00:21:24 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3749ef7ea08sm13374867f8f.68.2024.09.03.00.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 00:21:24 -0700 (PDT) Date: Tue, 3 Sep 2024 07:21:23 +0000 From: Bertrand Drouvot To: Kyotaro Horiguchi Cc: pgsql-hackers@lists.postgresql.org Subject: Re: per backend I/O statistics Message-ID: References: <20240903.153749.1724225439695895017.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240903.153749.1724225439695895017.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Sep 03, 2024 at 03:37:49PM +0900, Kyotaro Horiguchi wrote: > At Mon, 2 Sep 2024 14:55:52 +0000, Bertrand Drouvot wrote in > > Hi hackers, > > > > Please find attached a patch to implement $SUBJECT. > > > > While pg_stat_io provides cluster-wide I/O statistics, this patch adds a new > > pg_my_stat_io view to display "my" backend I/O statistics and a new > > pg_stat_get_backend_io() function to retrieve the I/O statistics for a given > > backend pid. > > > > I'm not sure about the usefulness of having the stats only available > from the current session. Since they are stored in shared memory, > shouldn't we make them accessible to all backends? Thanks for the feedback! The stats are accessible to all backends thanks to 0002 and the introduction of the pg_stat_get_backend_io() function. > However, this would > introduce permission considerations and could become complex. Not sure that the data exposed here is sensible enough to consider permission restriction. > When I first looked at this patch, my initial thought was whether we > should let these stats stay "fixed." The reason why the current > PGSTAT_KIND_IO is fixed is that there is only one global statistics > storage for the entire database. If we have stats for a flexible > number of backends, it would need to be non-fixed, perhaps with the > entry for INVALID_PROC_NUMBER storing the global I/O stats, I > suppose. However, one concern with that approach would be the impact > on performance due to the frequent creation and deletion of stats > entries caused by high turnover of backends. > The pros of using the fixed amount are: - less code change (I think as I did not write the non fixed counterpart) - probably better performance and less scalabilty impact (in case of high rate of backends creation/ deletion) Cons is probably allocating shared memory space that might not be used ( sizeof(PgStat_IO) is 16392 so that could be a concern for a high number of unused connection). OTOH, if a high number of connections is not used that might be worth to reduce the max_connections setting. "Conceptually" speaking, we know what the maximum number of backend is, so I think that using the fixed amount approach makes sense (somehow I think it can be compared to PGSTAT_KIND_SLRU which relies on SLRU_NUM_ELEMENTS). > Just to be clear, the above comments are not meant to oppose the > current implementation approach. They are purely for the sake of > discussing comparisons with other possible approaches. No problem at all, thanks for your feedback and sharing your thoughts! Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com