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 1tFTHN-00DBGy-1C for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Nov 2024 07:13:05 +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 1tFTHL-00Crx6-Ms for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Nov 2024 07:13:03 +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 1tFTHL-00Crwd-CG for pgsql-hackers@lists.postgresql.org; Mon, 25 Nov 2024 07:13:03 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tFTHJ-003eep-35 for pgsql-hackers@lists.postgresql.org; Mon, 25 Nov 2024 07:13:02 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3823eaad37aso3100077f8f.0 for ; Sun, 24 Nov 2024 23:13:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732518779; x=1733123579; 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=Xs4WhK3FX+75XCVRloZKNae+OYdqN/KfwWvCRUeXGTs=; b=hMLo+Y6NBUxh0mbAD++R3/M6BPFoYNwXSss0gcA3OFSaWQNbRk5l0+SSmDyZR1MVv9 8jnfBBh7JD+Ur3rMeBJVMkJ7YSnEterccgCiMo5SLmUhBFhD6GnIu5RrjojZ/4OZBP/f zF7KBfQMIZ6YyFih25uv/xPDA03cmpJ5aB1DUC9e004ifO4tg0Zk9Gl7rnFJ2xMcwCmK J2SbEN5caXS5mnZ40I8gXUeAkFr5YtX0fzA/JEmoL7AFOlf6a5xbcuG+rNzW3VPopYH0 WHGzEXF2ja/WGpa6vjL5uglHkHZGBB84xWAUOl/eiqGOwdp9n6J5dNSBxXaEhzQylBv0 uR4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732518779; x=1733123579; 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=Xs4WhK3FX+75XCVRloZKNae+OYdqN/KfwWvCRUeXGTs=; b=rJ8GyiqW2m1Ajrf/sewiAesNkuazJCwtiXfWydCbX2SWReXplFEXlDqDUmneRbPjV+ B0GB2Af9bpc6c5PQF5nspiAfbm3JN+rqZptkBJKe5vIAAErxYIziXRKaxYHFXmByOyy0 Mcld2i0k9bSDQeSFZomQ0LlvusU11tzt44/qX9f/etQ7L2mMsxtZxkVuOIND9F2gBo8M hQWNeZvtqzZPeyWHO6TAu32w3cOT2Iaca6QvYi26gBAFeo1HSLNTDHx9NOZM2gSVRErc MAMueM6iGRBujUYpsxKeav8FT4tLMpa51PG8FJy1HHDS20YnyyAYI1rXgscXaLxZrFk6 3PcA== X-Forwarded-Encrypted: i=1; AJvYcCXWLaOV7+y7ONjyddRV5WHnZR56OCc/UyhV9xVGfQ+B3dx2l9ut4wXtwiGmbES9xTjou9+oX+iK39u1u8GU@lists.postgresql.org X-Gm-Message-State: AOJu0YyoIKawFa7IPvjUn2uDgsNN46pFKJhVwAJI7k5kUFLZly1m7ejo 7JDwS5H18gC8Rg/MtSCq5iJk0uYluro8HRdFz8/H/nLABgKt02mq X-Gm-Gg: ASbGncsG7QaM9C0aW9QII6XaIjxfPw+YFTHzvPmc4V6nvY8mimt6JYvmTN5q+YDW3o5 kjOkqsaBgO2AlE1+mwzWY01TDmh9kE5FY6IFDaPUOunzQ3kSxWlXtk4JB1L9vNkQE5/Y3tY+SO+ nPwu+mvLG86Ae88OprDrP3hOrTAFAGS3xyL15r3mwIOblNGSg9Ak+racCaMaqC2Oyo1U0Ax0Fs0 Y3TFmT0ThsA+RQfDg1B5CGFzsa2SqtHcs0yMdfTAK3GIDSoMXenrBASW37ytZYudvoOfZ3ZsrXh 6Q5L13qaneceDYI6K46NteGHRSmmgUtuyzWmbS4iyH3g1YqAY0CE2SqrS+3iT8by1m8PEcJoxUj N X-Google-Smtp-Source: AGHT+IFfG0JulfawUU0Lb8sRsdk6FSMIGX7P7ihPhZiiGfRnyHaSLfKo9kbXa8El46ko4vr3QpJmOg== X-Received: by 2002:a5d:64a9:0:b0:382:3754:38e7 with SMTP id ffacd0b85a97d-38260602103mr8909415f8f.23.1732518778480; Sun, 24 Nov 2024 23:12:58 -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-3825fb2679dsm9648049f8f.45.2024.11.24.23.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2024 23:12:58 -0800 (PST) Date: Mon, 25 Nov 2024 07:12: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 Mon, Nov 25, 2024 at 10:06:44AM +0900, Michael Paquier wrote: > On Fri, Nov 22, 2024 at 07:49:58AM +0000, Bertrand Drouvot wrote: > > On Fri, Nov 22, 2024 at 10:36:29AM +0900, Michael Paquier wrote: > >> Hmm. created_entry only matters for pgstat_init_function_usage(). > >> All the other callers of pgstat_prep_pending_entry() pass a NULL > >> value. > > > > I meant to say all the calls that passe "create" as true in pgstat_get_entry_ref(). > > Ah, OK, I think that I see your point here. > > I am wondering how much this would matter as well for custom stats, > but we're not there yet without at least one release out and folks try > new things with these APIs and variable-numbered kinds. Not sure here, could custom stats start incrementing before the database system is ready to accept connections? > pgstat_prep_pending_entry() to return NULL even if "create" is true > may be a good thing, at the end, because that's the only way I can see > based on the current APIs where we could say "Sorry, but the stats > have not been loaded yet, so you cannot try to do anything related to > the dshash". Yeah, same here. > From my view having a kind of barrier would be cleaner in the long > run, but it's true that it may not be mandatory, as well. pg_stat_io > is currently OK to be called because the stats are loaded for > auxiliary processes because it uses fixed-numbered stats in shmem. > And it means we already have early calls that add stats getting > overwritten once the stats are loaded from the on-disk file (Am I > getting this part right?). Yeah, we can already see that, for example, the background writer could enter pgstat_io_flush_cb() before the stats are reset or restored. > Anyway, do we really require that for the sake of this thread? We > know that there's only one of each auxiliary process at a time, and > they keep a footprint in pg_stat_io already. So we could just limit > outselves to live database backends, WAL senders and autovacuum > workers, everything that's not auxiliary and spawned on request? I think that's a fair starting point and that we will not lose any informations doing so (as you said there is only one of each auxiliary process at a time, so that one could already see their stats from pg_stat_io). The only cons that I can see is that we will not be able to merge the flush cb but I don't think that's a blocker (the flush are done in shared memory so the impact on performance should not be that much of an issue). I'll come back with a new version implementing the above. [1]: https://www.postgresql.org/message-id/Zz9sno%2BJJbWqdXhQ%40ip-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