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 1t6NRf-00CVZb-J7 for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Oct 2024 05:10:07 +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 1t6NRc-00FQhH-6H for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Oct 2024 05:10:04 +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 1t6NRb-00FQfJ-S8 for pgsql-hackers@lists.postgresql.org; Thu, 31 Oct 2024 05:10:04 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t6NRZ-003jai-CG for pgsql-hackers@lists.postgresql.org; Thu, 31 Oct 2024 05:10:03 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-431688d5127so4215815e9.0 for ; Wed, 30 Oct 2024 22:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730351398; x=1730956198; 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=RN8Jiz2va89uFBGS+GjAK9bwcM5qdSyhKaMBY9x1D8I=; b=NQ4SbLrPl8VER085SmGfbFq8XwqsW9CvizBNlXo7ZAHBAq91kyAXgfg8jqIL1U8qt3 oPdxUk4eypodIQ2alaQZZ80vi1M9m0VfcyCDEDd2pbOOHOmgNKBvWuHHaxMUtYZrppfW iCSSP2o88RRC0gtB3LLiikTxCBMlFAni0tMtvwetBTHPIdV5ZaJ95pAih9KVZoEYBG7J xHHc10UPIIllx0FmUQLtjH8ge9GLfgBI6WMqFljvM+crJ2iPthXJjsBjVg0Tn9Y4oLFo WfhnTiWRC9mTbutK6mYSU1wVqnaHVc6DcEZeWUDtAhi0gZZvL2LIL9hDYZ87R8n7QjJc rAdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730351398; x=1730956198; 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=RN8Jiz2va89uFBGS+GjAK9bwcM5qdSyhKaMBY9x1D8I=; b=dFMi6xybCf/SIpS1Uq9uU65XZXoMGd3KkGFR4Zcz4LwoxN8nz8YLJcUUc4RlKQzRXj xLkykZ3Xsg4YjgV4pCMO41fwD4SR93U06kaj20kQd4YQnut8H2Vyi8DjHU2TLktN9L6H KRL535sKe6PUYWmeWDvg+nqTv6ofh3a5xh6NGRRkiO5g0xUQBQXKBvn7+jBhYEUANLLu ySmechsxv+sQIc5C9LArc0Zscp1Fbb1koQp2wI5G0/21chedbyAxyZxSiofF+bMZerXI fd4QAK9SRIwCQsBMVUHYCjqHGgrJ4GRUYMI75fx49QQ5+BFQn59izMwUMA+kfoF3gAaj FNRQ== X-Forwarded-Encrypted: i=1; AJvYcCUnu6SHO08ZFjV8miMe+NBsX5BNII2NcAn6VT91/I3Z8rY2xegmHOyt54q3UXqPv5k4K2hAOHfLy8759lQ0@lists.postgresql.org X-Gm-Message-State: AOJu0YzDhpPngHvESpZd/oJMyc34izvtPH6KGyVW/hkElE3iUd2V3ghu 97j9rMtImsvHPWlCIEYKmCkbaIbORCh8Lb47P2dn9kCFMP5Hzw9Q X-Google-Smtp-Source: AGHT+IEymaCGwWqjn5W5beemTuukgDH9d8pvb4WeY4ALrQdyh7NEQCZ9l+8Ng6UilcwGsMblZu/Onw== X-Received: by 2002:a05:600c:4e0f:b0:431:12d0:746b with SMTP id 5b1f17b1804b1-4319ad294a4mr138441585e9.35.1730351398321; Wed, 30 Oct 2024 22:09:58 -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 5b1f17b1804b1-431bd947b2bsm41434895e9.25.2024.10.30.22.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 22:09:57 -0700 (PDT) Date: Thu, 31 Oct 2024 05:09:56 +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 Tue, Oct 08, 2024 at 04:28:39PM +0000, Bertrand Drouvot wrote: > > > On Fri, Sep 20, 2024 at 01:26:49PM +0900, Michael Paquier wrote: > > > > Okay, per the above and the persistency of the stats. > > Great, I'll work on an updated patch version then. > I spend some time on this during the last 2 days and I think we have 3 design options. === GOALS === But first let's sump up the goals that I think we agreed on: - Keep pg_stat_io as it is today: give the whole server picture and serialize the stats to disk. - Introduce per-backend IO stats and 2 new APIs to: 1. Provide the IO stats for "my backend" (through say pg_my_stat_io), this would take care of the stats_fetch_consistency. 2. Retrieve the IO stats for another backend (through say pg_stat_get_backend_io(pid)) that would _not_ take care of stats_fetch_consistency, as: 2.1/ I think that there is no use case (there is no need to get others backends I/O statistics while taking care of the stats_fetch_consistency) 2.2/ That could be memory expensive to store a snapshot for all the backends (depending of the number of backend created) - There is no need to serialize the per-backend IO stats to disk (no point to see stats for backends that do not exist anymore after a re-start). - The per-backend IO stats should be variable-numbered (not fixed), as per up-thread discussion. === OPTIONS === So, based on this, I think that we could: Option 1: "move" the existing PGSTAT_KIND_IO to variable-numbered and let this KIND take care of the aggregated view (pg_stat_io) and the per-backend stats. Option 2: let PGSTAT_KIND_IO as it is and introduce a new PGSTAT_KIND_BACKEND_IO that would be variable-numbered. Option 3: Remove PGSTAT_KIND_IO, introduce a new PGSTAT_KIND_BACKEND_IO that would be variable-numbered and store the "aggregated stats aka pg_stat_io" in shared memory (not part of the variable-numbered hash). Per-backend stats could be aggregated into "pg_stat_io" during the flush_pending_cb call for example. === BEST OPTION? === I would opt for Option 2 as: - The stats system is currently not designed for Option 1 and our goals (for example the shared_data_len is used to serialize but also to fetch the entries, see pgstat_fetch_entry()) so that would need some hack to serialize only a part of them and still be able to fetch them all). - Mixing "fixed" and "variable" in the same KIND does not sound like a good idea (though that might be possible with some hacks, I don't think that would be easy to maintain). - Having the per-backend as "variable" in its dedicated kind looks more reasonable and less error-prone. - I don't think there is a stats design similar to option 3 currently, so I'm not sure there is a need to develop something new while Option 2 could be done. - Option 3 would need some hack for (at least) the "pg_stat_io" [de]serialization part. - Option 2 seems to offer more flexibility (as compare to Option 1 and 3). Thoughts? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com