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 1t8gRD-005QM1-KG for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Nov 2024 13:51:10 +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 1t8gRA-006Iv0-PI for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Nov 2024 13:51:09 +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 1t8gRA-006Ius-FG for pgsql-hackers@lists.postgresql.org; Wed, 06 Nov 2024 13:51:09 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t8gR6-000WBs-Dw for pgsql-hackers@lists.postgresql.org; Wed, 06 Nov 2024 13:51:08 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-37d4ac91d97so5694010f8f.2 for ; Wed, 06 Nov 2024 05:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730901064; x=1731505864; 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=23qKkv0VQS+5XkI/rB3vulcSYFaoOzRcWcdCHucSmgE=; b=VplfHIb43DB/A0oks+IW2O2r1JckHowgtnUOe5aOQJ8+QM965+fdxGK7GQrM5eWreu FJZNAOe1hKbcbpFuAGlXvttcYvRmpkT1a/GEeFiQD1RdRk4W7DoXUUhy6f989RmTz5rB 8zv8EkE1aloB1D+paK/gkvhU0u+bfyp46Pq1+NgD1V/rk0SqWnJ4FGiBjl52r343SCAs D7t84aHA6teFC97yb9VidqiehcuHhwAJWNpRPQA2eO5bDgGU+XsPZI6nWIlKdlVy7uGQ Ajo1RJEbmFw42EPzeK9yJ4qSctpiIUmvLQYgMbglZGlVQA5lPiKsvcrYXVbyow6ag8YO nk/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730901064; x=1731505864; 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=23qKkv0VQS+5XkI/rB3vulcSYFaoOzRcWcdCHucSmgE=; b=wx5MG6nW0KGKuVu8B+3h6lb5h6i4m5QSkk1MpUvMm4QZQr7D6+SAbPeXBGLx6Zn+4v jSA5nnrfZFp+t0LY4SXXqhp5intdo07Dxspan2tzTU7uCh9GOLmb8YDi+OGXgZEGh1V6 y8sEV8oXXEgOxqNd5laafYD88SEzE5mmrxkrqGysyKB9uyZYtZW6O7h70ANovZ/fQVsH 5n8SBzYT9G/30ItyO3tsOrB7QNE12bnen3IaP0WeXX5zY1cFgtpznQdhgICI9Y4kcoWw xOF3DNc6S8uMLpclKj7dII794rH3X6RJ1ZigOAwthG2YiVS3ZiHFW41GWcLs8i0GO+if 6q4A== X-Forwarded-Encrypted: i=1; AJvYcCWSyEK13vkUg4D3q3c2JHYmfXQK4HNTGCST2irNfADzDWdMn0Yfjw6OEgUfP1j+vhlD9Q8f1gUplhZZbpNK@lists.postgresql.org X-Gm-Message-State: AOJu0YzbI7NI0sazvrtkVt5a2E74AvCMN6qmhYasqweKKXjGO0fZk1V+ xm11m6I4xWGcAGS0YKV9gWvj0r/VKWUHQol49VTPjcMcHs6NboQk X-Google-Smtp-Source: AGHT+IFkQ+jeVKU2YRUz4z5Uk7CwpQVw+hyZa5zZa/BApijEiuI3BomiKjx7HaN0QIAqd4wkaB+OcA== X-Received: by 2002:a05:6000:4014:b0:37c:d1ea:f1ce with SMTP id ffacd0b85a97d-381c7a6a643mr17511543f8f.25.1730901063743; Wed, 06 Nov 2024 05:51:03 -0800 (PST) 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-381c10e741dsm19111065f8f.50.2024.11.06.05.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 05:51:03 -0800 (PST) Date: Wed, 6 Nov 2024 13:51:02 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: Nazir Bilal Yavuz , Alvaro Herrera , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org Subject: Re: per backend I/O 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, Nov 06, 2024 at 08:39:07AM +0900, Michael Paquier wrote: > On Tue, Nov 05, 2024 at 05:37:15PM +0000, Bertrand Drouvot wrote: > > I'm starting working on option 2, I think it will be easier to discuss with > > a patch proposal to look at. > > > > If in the meantime, one strongly disagree with option 2 (means implement a brand > > new PGSTAT_KIND_BACKEND and keep PGSTAT_KIND_IO), please let me know. > > Sorry for the late reply, catching up a bit. No problem at all, thanks for looking at it! > As you are quoting in [1], you do not expect the backend-io stats and > the more global pg_stat_io to achieve the same level of consistency as > the backend stats would be gone at restart, and wiped out when a > backend shuts down. Yes. > So, splitting them with a different stats kind > feels more natural because it would be possible to control how each > stat kind behaves depending on the code shutdown and reset paths > within their own callbacks rather than making the callbacks of > PGSTAT_KIND_IO more complex than they already are. Yeah, thanks for sharing your thoughts. > And pg_stat_io is > a fixed-numbered stats kind because of the way it aggregates its stats > with a number states defined at compile-time. > > Is the structure you have in mind different than PgStat_BktypeIO? Very close. > Perhaps a split is better anyway with that in mind. The in-progress patch (not shared yet) is using the following: " typedef struct PgStat_Backend { TimestampTz stat_reset_timestamp; BackendType bktype; PgStat_BktypeIO stats; } PgStat_Backend; " The bktype is used to be able to filter the stats correctly when we display them. > The amount of memory required to store the snapshots of backend-IO > does not worry me much, TBH, but you are worried about a high turnover > of connections that could cause a lot of bloat in the backend-IO > snapshots because of the persistency that these stats would have, > right? Not only a high turnover but also a high number of entries created in the hash. Furthermore I don't see any use case of relying on stats_fetch_consistency while querying other backend's stats. > If possible, supporting snapshots would be > more consistent with the other stats. I have I mind to support the snapshots _only_ when querying our own stats. I can measure the memory impact if we use them also when querying other backends stats too (though I don't see a use case). > Just to be clear, I am not in favor of making PgStat_HashKey larger > than it already is. That's not needed, the patch I'm working on stores the proc number in the objid field of the key. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com