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 1jYtEa-0007F6-3t for pgsql-hackers@arkaria.postgresql.org; Wed, 13 May 2020 15:23:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jYtEZ-00028e-0h for pgsql-hackers@arkaria.postgresql.org; Wed, 13 May 2020 15:23:47 +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 1jYtEY-00028X-QJ for pgsql-hackers@lists.postgresql.org; Wed, 13 May 2020 15:23:46 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jYtEW-0004kv-Hm for pgsql-hackers@postgresql.org; Wed, 13 May 2020 15:23:45 +0000 Received: by mail-wm1-x341.google.com with SMTP id m12so22075647wmc.0 for ; Wed, 13 May 2020 08:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JC3YFjIqhd2fYyOJWFF6elG5nJJ8qTE60Z/D7wSfOjI=; b=EYA3p9xT/PLedmqMGazdca9eR1bhbekI1tFO5VlRx1CXg1foTwd4AJeL+vX5ujdzMR VGkCv7I8QSqFMYO7foY3+t+hxFDYH0wzbopc4A0zW+yQ0HkL6xGVOfQBrXv75+YTWqHr CcQJlpcvTSa5DNLWOXKW12SlXwcCVv2CVUUqbS/BOjEA/X8xRMhvIJTEdU1USJ7bfUkF qAzxrb5BMivwkp5hYqPJMcguD/4Lc4cCPFDFec33ax8YzMvEM/9Zl5gSAb7sPt2U25Wr IT4vYmQ1nxdASlF+LDZ3HZ4xMilTCyeesIiTn3/Jg6ggobhkKRTvlYv9DDoT/bDe0OOq 8blw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JC3YFjIqhd2fYyOJWFF6elG5nJJ8qTE60Z/D7wSfOjI=; b=Jb+rQP5v1GBGDC3WbGTr8vZ/O0xX8stDHyoyC/W+wWymYgTrqA8ytDruPujb74YCSf vorAd7Fg7+XK36E+2ISaoc5DmoPzoaqGrjSeYMlj68i0iaa9ZkdVO4/nGjXcwtS2N3dx Qnw+LGcwhchS3w0VPryzV35D5+oBMj7NmuHuo/BDMz/hD8xQd9BjH4dDiwQUTAuaK29R 3kJUVLt7bAbPYnKuoGnmcL17JyoryPfqSBS8FjcQ4z/rHv3B/jWz90wTeEPe7iDT8P7Q 5uHwrTsNB2AQErQpu9hxKY3oKgxNEUO/2QsQOAX+q5wUDhTonWFRm+rLgIOtGMT48iVC a5mQ== X-Gm-Message-State: AGi0PuYzHBD7DftbUl6449AltnfU4h4HU2IOwdZEuXlg+aGGyb9jwOms cwplE/C7l0bo27+Xzj2feStmFA== X-Google-Smtp-Source: APiQypLrIv/ht4r7wnomXShQkijoHV63BGpI+dFhOmsxELSOCEAlEU04kkx4WHfo0YJpHnQFToNZug== X-Received: by 2002:a1c:5403:: with SMTP id i3mr46130462wmb.10.1589383423156; Wed, 13 May 2020 08:23:43 -0700 (PDT) Received: from localhost (ip-86-49-253-141.net.upcbroadband.cz. [86.49.253.141]) by smtp.gmail.com with ESMTPSA id z10sm17438610wmi.2.2020.05.13.08.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 08:23:42 -0700 (PDT) Date: Wed, 13 May 2020 17:23:39 +0200 From: Tomas Vondra To: Tom Lane Cc: Fujii Masao , Alvaro Herrera , Masahiko Sawada , "tsunakawa.takay@fujitsu.com" , "pgsql-hackers@postgresql.org" Subject: Re: SLRU statistics Message-ID: <20200513152339.s7ossibhr6wai4p7@development> References: <49b8ad17-f6d9-a086-a952-ff1fec3ac1b3@oss.nttdata.com> <20200502105500.hwhba3d6s3hlrqf6@development> <20200502165905.brfxv6dk5vjdbgti@development> <976bbb73-a112-de3c-c488-b34b64609793@oss.nttdata.com> <20200513082159.myflgcs5fnhnujbk@development> <32135.1589379999@sss.pgh.pa.us> <20200513145739.wlnbse5rw3vvscyr@development> <1196.1589382107@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1196.1589382107@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, May 13, 2020 at 11:01:47AM -0400, Tom Lane wrote: >Tomas Vondra 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