From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Cc: tsunakawa.takay@fujitsu.com <tsunakawa.takay@fujitsu.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: SLRU statistics
Date: Wed, 13 May 2020 17:23:39 +0200
Message-ID: <20200513152339.s7ossibhr6wai4p7@development> (raw)
In-Reply-To: <1196.1589382107@sss.pgh.pa.us>
References: <49b8ad17-f6d9-a086-a952-ff1fec3ac1b3@oss.nttdata.com>
<20200502105500.hwhba3d6s3hlrqf6@development>
<20200502165905.brfxv6dk5vjdbgti@development>
<976bbb73-a112-de3c-c488-b34b64609793@oss.nttdata.com>
<b8784fe6-1401-ab35-aa14-d57b5bb8e312@oss.nttdata.com>
<20200513082159.myflgcs5fnhnujbk@development>
<b407746a-4fb6-7128-9391-c3765eb44718@oss.nttdata.com>
<32135.1589379999@sss.pgh.pa.us>
<20200513145739.wlnbse5rw3vvscyr@development>
<1196.1589382107@sss.pgh.pa.us>
On Wed, May 13, 2020 at 11:01:47AM -0400, Tom Lane wrote:
>Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
>> On Wed, May 13, 2020 at 10:26:39AM -0400, Tom Lane wrote:
>>> Why is that necessary? A static variable is defined by C to start off
>>> as zeroes.
>
>> But is it a static variable? It's not declared as 'static' but maybe we
>> can assume it inits to zeroes anyway? I see we do that for
>> BgWriterStats.
>
>Sorry, by "static" I meant "statically allocated", not "private to
>this module". I'm sure the C standard has some more precise terminology
>for this distinction, but I forget what it is.
>
Ah, I see. I'm no expert in reading C standard (or any other standard),
but a quick google search yielded this section of C99 standard:
-------------------------------------------------------------------------
If an object that has static storage duration is not initialized
explicitly, then:
- if it has pointer type, it is initialized to a null pointer;
- if it has arithmetic type, it is initialized to (positive or unsigned)
zero;
- if it is an aggregate, every member is initialized (recursively)
according to these rules;
- if it is au nion, the first named member is initialized (recursively)
according to these rules
-------------------------------------------------------------------------
I assume the SLRU variable counts as aggregate, with members having
arithmetic types. In which case it really should be initialized to 0.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tomas.vondra@2ndquadrant.com, tgl@sss.pgh.pa.us, masao.fujii@oss.nttdata.com, alvherre@2ndquadrant.com, masahiko.sawada@2ndquadrant.com, tsunakawa.takay@fujitsu.com
Subject: Re: SLRU statistics
In-Reply-To: <20200513152339.s7ossibhr6wai4p7@development>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox