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 1jYtK1-0007Nb-ER for pgsql-hackers@arkaria.postgresql.org; Wed, 13 May 2020 15:29:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jYtK0-0003FL-CP for pgsql-hackers@arkaria.postgresql.org; Wed, 13 May 2020 15:29:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYtJW-0000aa-UI for pgsql-hackers@lists.postgresql.org; Wed, 13 May 2020 15:28:54 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jYtJT-0007ZG-VI for pgsql-hackers@postgresql.org; Wed, 13 May 2020 15:28:54 +0000 Received: by mail-wm1-x343.google.com with SMTP id k12so26954729wmj.3 for ; Wed, 13 May 2020 08:28:51 -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=phByneJoZ1um9LPjWxMW5KFkhPRRHEmoeqDSoHZOF80=; b=t+wHr0ZVJFVJsiGWXzqdRhPDOJkw9MSeF/iV7SFQUVQyNRTz0sxhBGR+CdQUelE1vz N6XD/xxE/Mo9bLNvE+pkDZmQZV6iiePUISavCalBRKRd73q5+u3XNb5Fo93OQZt0Ubgd BM1pyZGrXie2AyTpoWpG6yu0V57WI75fqGIulNJgcAFUDJ59OwEprRm974nVWOL2Wc9b gj5ppBqK4/0thSL9NUBKMZSwstlNHksOklYpNrHwLIWktgpIUPiOCV3WLVQXIM0Ox02I oBRp1pQCXxt78+dseovWaIFBpJbUrW3cfJXkfL16UWAMRk5yj1DP94Xw/jIQofn5rdZw tHbg== 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=phByneJoZ1um9LPjWxMW5KFkhPRRHEmoeqDSoHZOF80=; b=riSs7vg1OWqXZDS484rZaUrf+DnNOey8WPOImWvJB8MeAM0hOn/t8XE8Qc+N3M5bdN MEOgZIIGuCw2AHIZS99rbD1P39HVRLjjhegU+g1n88ADAt1esEYtQWs4wl7gn8olWTYl a/X9qi6JWrfPky7A1aT/vj9W1jpFW/3yPHNE6pDZ4TLivkTI5sdbmrX2LI+faRoFFqh+ TE3uqftsIMCGUTcN5XMO2KXjVCPEsZLJRzmrlj1NyCaB5yts/SDmzMSOlczCT+VU9cmD E9n3hlTAxqPgCJ7PZUq0gJmtQvk6hT4y+DpskKdazwQmJoDOCEIr+WaV6u9Q8SxX0Kxg 1KtA== X-Gm-Message-State: AGi0PuYebSTV8E6fXACF4cWRxl+Ny26r2Zd+M5x3vsvQUCBM92+/jL9k KFdnO6BACae5OA3OJkK/eQc6lw== X-Google-Smtp-Source: APiQypKxb0xnXcpjcaACb9jqJMp+F8c1iGDqNVMpqTQtg9ZqrT/KcSpDzxk4iafaCG6VyO0yUlZ0/Q== X-Received: by 2002:a1c:5944:: with SMTP id n65mr32525048wmb.73.1589383731012; Wed, 13 May 2020 08:28:51 -0700 (PDT) Received: from localhost (ip-86-49-253-141.net.upcbroadband.cz. [86.49.253.141]) by smtp.gmail.com with ESMTPSA id n13sm7626205wrs.2.2020.05.13.08.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 08:28:50 -0700 (PDT) Date: Wed, 13 May 2020 17:28:46 +0200 From: Tomas Vondra To: Fujii Masao Cc: Tom Lane , Alvaro Herrera , Masahiko Sawada , "tsunakawa.takay@fujitsu.com" , "pgsql-hackers@postgresql.org" Subject: Re: SLRU statistics Message-ID: <20200513152846.goee2c5xrly52ga2@development> References: <20200502000818.nn4kpewiput42bnb@development> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, May 13, 2020 at 11:46:30PM +0900, Fujii Masao wrote: > > >On 2020/05/13 23:26, Tom Lane wrote: >>Fujii Masao writes: >>>On 2020/05/13 17:21, Tomas Vondra wrote: >>>>On Wed, May 13, 2020 at 04:10:30PM +0900, Fujii Masao wrote: >>>>>Also I found another minor issue; SLRUStats has not been initialized to 0 >>>>>and which could update the counters unexpectedly. Attached patch fixes >>>>>this issue. >> >>>Pushed both. Thanks! >> >>Why is that necessary? A static variable is defined by C to start off >>as zeroes. > >Because SLRUStats is not a static variable. No? > I think it counts as a variable with "static storage duration" per 6.7.8 (para 10), see [1]. I wasn't aware of this either, but it probably means the memset is unnecessary. Also, it seems a bit strange/confusing to handle this differently from BgWriterStats. And that worked fine without the init for years ... [1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services