Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mq3Mv-0006IM-D7 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Nov 2021 01:16:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mq3Mu-0003FH-9Z for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Nov 2021 01:16:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mq3Mt-0003E2-RM for pgsql-hackers@lists.postgresql.org; Thu, 25 Nov 2021 01:16:08 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mq3Mo-0003w8-3k for pgsql-hackers@postgresql.org; Thu, 25 Nov 2021 01:16:06 +0000 Received: by mail-io1-xd2f.google.com with SMTP id z18so5551846iof.5 for ; Wed, 24 Nov 2021 17:16:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6sMY1xRZIVCLl6c8onLqQ7DPH/nkkAuRUYRWLqqHDHU=; b=VdPWje092RRrQ3oC4QzEwGak03FgChgi4V8PNSInfG0YGaqXMcBOAyjAb844nQH6FA S3KNILE8vyc3sV7FXOqvrh6NGLGknabcQ3erNDgiBtz06m1WBkp9YE1d0i7waoGF8Jl7 xTHJeh6cONPI1R0TbHMQyVAIw6Yk5sqGKW/u0HFb8HX8e6r1tWinwu51OM3BJ8d/AYfR rodrX6XF4Jicj49FaK+T/QRjFu3GFGy3fLIlaLI3DDQm7WTyYJNoz9OMFvwfn/vj6aGp eL2mi1kCXyWDC8ht0zfb4MNiHDdo3HImaBXilqct6V0g6qakoxvVEYz/kR0cIZEzYPh7 LtAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6sMY1xRZIVCLl6c8onLqQ7DPH/nkkAuRUYRWLqqHDHU=; b=PHEGkPIspZEYTdrHvoPw1lPDCEPncFrk7/LsqTj0risG6yp1+7iKKkAR9sMmIheNLx 1e+Jn2O5O4gy7yvEULtBOPvZvo8Es1beQYfDASA996ieOsiJDSgnkXQ2jy6Dyfsf/bH2 DperLtRwhZp4pmpo13JWLVzYrGDd9U2nX4IysT1a4loAFr4hwhn0n5EGV34To+Fo64s2 n4kQRa25ItCGL8crJGJzRCIHPK/KanBf0xGyLj98Ga+kIPKHWIiBVQ/1fJuVs3mgdz0o HhyrW7ipM27pWd2YO0nZPWHRSdqY955hC8kI4oQT7/9jkNeAcqXsFYmlGY4PXMytlWBM ziKA== X-Gm-Message-State: AOAM533cbkNAw501q7FMOLtP9UB+YE15Nu06CsCWo6axx5c4Gh6mqABg XMytg7Bk5pyiml8emihDvcxAcg== X-Google-Smtp-Source: ABdhPJxCiJpGxXpIshDCG/2TemPlMvHvSeq4e8EeuoES5cw4HMYA5VCuOZg8NHVHcAz3kpfBAvSP3Q== X-Received: by 2002:a02:6d41:: with SMTP id e1mr22124436jaf.74.1637802961084; Wed, 24 Nov 2021 17:16:01 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id a14sm879082ilv.86.2021.11.24.17.16.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 17:16:00 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id D5073800B45; Wed, 24 Nov 2021 19:15:59 -0600 (CST) Date: Wed, 24 Nov 2021 19:15:59 -0600 From: Justin Pryzby To: Melanie Plageman Cc: Andres Freund , Alvaro Herrera , Kyotaro Horiguchi , Magnus Hagander , pgsql-hackers@postgresql.org, Lukas Fittl , Thomas Munro Subject: Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?) Message-ID: <20211125011559.GC17618@telsasoft.com> References: <202109302315.65qtfrmgbpzt@alvherre.pgsql> <20211008175620.nspjy6wwmzvyzkrg@alap3.anarazel.de> <20211019192931.eeeohw6yrvqe6bol@alap3.anarazel.de> <20211119164952.mlw7ecj4xxliuuut@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks for working on this. I was just trying to find something like "pg_stat_checkpointer". You wrote beentry++ at the start of two loops, but I think that's wrong; it should be at the end, as in the rest of the file (or as a loop increment). BackendStatusArray[0] is actually used (even though its backend has backendId==1, not 0). "MyBEEntry = &BackendStatusArray[MyBackendId - 1];" You could put *_NUM_TYPES as the last value in these enums, like NUM_AUXPROCTYPES, NUM_PMSIGNALS, and NUM_PROCSIGNALS: +#define IOOP_NUM_TYPES (IOOP_WRITE + 1) +#define IOPATH_NUM_TYPES (IOPATH_STRATEGY + 1) +#define BACKEND_NUM_TYPES (B_LOGGER + 1) There's extraneous blank lines in these functions: +pgstat_sum_io_path_ops +pgstat_report_live_backend_io_path_ops +pgstat_recv_resetsharedcounter +GetIOPathDesc +StrategyRejectBuffer This function is doubly-indented: +pgstat_send_buffers_reset As support for C99 is now required by postgres, variables can be declared as part of various loops. + int io_path; + for (io_path = 0; io_path < IOPATH_NUM_TYPES; io_path++) Rather than memset(), you could initialize msg like this. PgStat_MsgIOPathOps msg = {0}; +pgstat_send_buffers(void) +{ + PgStat_MsgIOPathOps msg; + + PgBackendStatus *beentry = MyBEEntry; + + if (!beentry) + return; + + memset(&msg, 0, sizeof(msg)); -- Justin