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 1tNSiX-00BBxf-J1 for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Dec 2024 08:14:09 +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 1tNSiT-00GMMV-SQ for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Dec 2024 08:14:07 +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 1tNSiT-00GMMN-HI for pgsql-hackers@lists.postgresql.org; Tue, 17 Dec 2024 08:14:06 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tNSiS-003G32-1F for pgsql-hackers@lists.postgresql.org; Tue, 17 Dec 2024 08:14:05 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3862d16b4f5so3237932f8f.0 for ; Tue, 17 Dec 2024 00:14:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734423241; x=1735028041; 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=yoMPiEkiAZRRuLepiZ8nRGdE2SnrtJrA2vAn55TMqkI=; b=Kf1GynJFoxwo5hpNE+XkCPDim+dzkcSU+ATkRzXvSEB7T0ATSi4TrgE1URCDJjwbds M/koO1hs/iWkax1pPYRKqFm95Dtw1Ibhqp8kNI7Zg0KRbuTeb6A3ruvlrJznQyTfV/fG hXwR2Ex5aY5L/O87rSlMcxh4JYctr5MyRZkrDOumOJjc8tVV1xIqWXgGHZ2Kcvn7sH6Q 9OfPn+Jxi9OkkfYGEaRAvY4FUBAUgc29ZSwhaD3lC/NdipnXJ5VDv+HNA2eKZ8zFqv0l EZdf0CWzpM+ak76sqSVqXtiZ4k47JZCD7cJIOVRORuJMhOhg6e20zm4mJyGWDMz197Ho RgGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734423241; x=1735028041; 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=yoMPiEkiAZRRuLepiZ8nRGdE2SnrtJrA2vAn55TMqkI=; b=BY47k0+KSNDgnle+hFumo8Vhg9FfZLp2FQkX64GUpyW/9Di5gpIOnXwa0PbQjdyCP2 wSuezyz4GgMBj1JyvJMQ5WYATYYvcfbBOyHCLDbmdKyNcFISUGKlyxvEwDclcCYj+ldb 3VVzDOq6Sz9MT5knZthdnWa/LE6YG/B4j/ON/an2UTXe0jpFuCVM40/TunaVqozAl3fA hvFjXs6wnGcV34Qle2WOb/KVmqHyjPiDYXpAF8nTcsyx3vM5oKBbDsOZFDJZ0XnfNQ0X ag7aEmjiDp0az04Qoui29+Go2Xjlym2cjwIblJ6yyTsQYJ3hoPoQ++OxFYYN7E8HYrT+ E3pw== X-Forwarded-Encrypted: i=1; AJvYcCW8dlRF6Q48MeMGT8eCsgqwin02GtDepaBvx+43kwdn2kl+CZesxg2U6pxp0yJNQhoWQUEz1LRW7aCZ4oEE@lists.postgresql.org X-Gm-Message-State: AOJu0YxhoPK6JVBjxfqNG2Yi1+zOjUCq1s/idRCu7TzqVAkyOGJJZSBS 4ABw/s4H0oqFTeKli8gtYwak6joO30BeZ5JG4DpkPTyj63emP7aA X-Gm-Gg: ASbGncuvw6kN7R6Y2w2qv2llEZ8O8l7wd3PpQfDuYy1ZH+eUxiq3V0L+XVwX2hJuOaH 9CQPb74ae8sF0bLBdeaz1AuxPJfcrVjLF6Pc1yVa4vBAHR9hl5Pu47hJHo6BEtlEglWRKQTLd3R UNnuPdb1gYkYCmpR5QFKNvo74RqEkylcQMNxO7kpHqAUoFZe5+eL+cvnvVnNd7R+d9U00+Qiwsz WqxCcAOaxs0qUvAGCKcHtPn1GYo7YHEtktHtGI4ZEpn0w/3R7yee3DlrWowvQrW4DiJV4LhknO5 TQI8/dQfivw8a4a9LW0gkM1QWYsliMSnJiLgG8SwlMq+242W/5K/qm92PYZ2M1/B2j2fcAVaUJM +/2OW5bk= X-Google-Smtp-Source: AGHT+IHuujvIuerisR++kLkAt+4RmB5UCgEI3OHSbRHseS9rVf4oZ4UlZyWPQaaAzvVkJ9sF9zV90Q== X-Received: by 2002:a05:6000:4009:b0:386:4332:cc99 with SMTP id ffacd0b85a97d-388db25a505mr1668310f8f.17.1734423241319; Tue, 17 Dec 2024 00:14:01 -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 5b1f17b1804b1-4363602c92csm109507685e9.15.2024.12.17.00.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 00:14:00 -0800 (PST) Date: Tue, 17 Dec 2024 08:13:59 +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, Dec 17, 2024 at 03:26:02PM +0900, Michael Paquier wrote: > On Mon, Dec 16, 2024 at 03:42:04PM +0000, Bertrand Drouvot wrote: > >> Perhaps there's an argument for an entirely separate > >> callback that would run before pgstat is plugged off, like a new > >> before_shmem_exit() callback registered after the entry is created? > > > > As the ProcKill() is run in shmem_exit() (and so after before_shmem_exit()), > > I think that the way we currently drop the backend stats entry is fine (unless > > I miss something about your concern). > > Looking closely at this one, I think that you're right as long as the > shutdown callback is registered before the entry is created. Yeah, which is the case. > Anyway, I have put my hands on v9. A couple of notes, while hacking > through it. See v9-0002 for the parts I have modified, that applies > on top of your v9-0001. Thanks! > You may have noticed fee2b3ea2ecdg, which led me to fix two comments > as these paths are not related to only database objects. Yeap ;-) > Added more documentation, tweaked quite a bit the comments, a bit less > the docs (no need for the two linkends) and applied an indentation. Looks good to me. > pg_stat_get_backend_io() can be simpler, and does not need the loop > with the extra LocalPgBackendStatus. It is possible to call once > pgstat_get_beentry_by_proc_number() and retrieve the PID and the > bktype for the two sanity checks we want to do on them. Looked at the changes you've done and agree that's simpler. > s/pgstat_fetch_proc_stat_io/pgstat_fetch_stat_backend/. Not sure about this one as being called in pg_stat_get_backend_io(). > s/pgstat_create_backend_stat/pgstat_create_backend/. LGTM. > I've been wondering for quite a bit about PgStat_BackendPendingIO and > PgStat_PendingIO, and concluded to define both in pgstat.h, with the > former being defined based on the latter to keep the dependency > between both at the same place. That's fine by me. Also: === 1 the changes in pgstat_flush_backend() make sense to me. === 2 - * Create the backend statistics entry for procnum. + * Create backend statistics entry for proc number. Yeah, "proc number" looks better as already used in multiple places. === 3 the changes in stats.sql look good to me. Having said that, v9-0002 looks good to me (except the pgstat_fetch_proc_stat_io renaming). Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com