Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1daZ8x-0008D5-5C for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jul 2017 03:07:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1daZ8w-0007dq-MZ for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jul 2017 03:07:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1daZ7J-0004e4-PT for pgsql-hackers@postgresql.org; Thu, 27 Jul 2017 03:05:38 +0000 Received: from bay.acenet.us ([173.230.252.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1daZ7B-0006T3-NP for pgsql-hackers@postgresql.org; Thu, 27 Jul 2017 03:05:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=St2PAEqSXpP3rMpDcupw2tXh9NPPiIHa9YlCRvX5hlA=; b=YcVteDK6+c0dVBUfz9PDKQrXFa 3p3zQTRAi71+EcaBrf1yVU9cnFF7QYaoL8I/vDFz7CErdhJqKN39+af2WPgLarBVzyVaJpsQc3IpK pk+5l0LTXHqPkX3Y4kBNDa5nNChvmHg8LsvItUoFnJI/Fv8MoVVXSfNbmVmoxxvyQ0Ipu6aZwKMWl jibYU+/EnI+97LptmjGEzNkR1aMdaJh0T+2O9JBiWMjt3Shc2k9KV+QOfEFasFYswLYwg3d4s+WQs FH8H3IEdv07DCmNEiI4rXXuOy98fVyqApapjNuiwezMbl+kFhM3BbgJ3x+7R1oI4Ke8+XMIHD0riu rh4uLIZw==; Received: from [50.102.16.86] (port=49929) by bay.acenet.us with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1daZ77-004B7p-MG; Wed, 26 Jul 2017 23:05:26 -0400 Subject: Re: AdvanceXLInsertBuffer vs. WAL segment compressibility To: Michael Paquier , Heikki Linnakangas References: <579297F8.7020107@anastigmatix.net> <5797D953.6040806@anastigmatix.net> <20160802183347.GD32575@momjian.us> <20943eba-bbb9-390c-01b1-e6704ce33c7b@iki.fi> <594C9457.6000708@anastigmatix.net> <59506148.1010708@anastigmatix.net> <2b9ed9a4-56a6-a4db-0abf-3527d993e2d4@iki.fi> Cc: Robert Haas , Bruce Momjian , PostgreSQL Hackers From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <59795874.9020503@anastigmatix.net> Date: Wed, 26 Jul 2017 23:05:24 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=-95.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap+anastigmatix.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 07/17/17 11:29, Michael Paquier wrote: > FWIW, I would rather see any optimization done in > AdvanceXLInsertBuffer() instead of seeing a second memset re-zeroing > the WAL page header after its data has been initialized by > AdvanceXLInsertBuffer() once. Is that an aesthetic 'rather', or is there a technical advantage you have in mind? I also began by looking at how to stop AdvanceXLInsertBuffer() initializing headers and taking locks when neither is needed. But Heikki's just-rezero-them suggestion has a definite simplicity advantage. It can be implemented entirely with a tight group of lines added to CopyXLogRecordToWAL, as opposed to modifying AdvanceXLInsertBuffer in a few distinct places, adding a parameter, and changing its call sites. There's a technical appeal to making the changes in AdvanceXLInsertBuffer (who wants to do unnecessary initialization and locking?), but the amount of unnecessary work that can be avoided is proportional to the number of unused pages at switch time, meaning it is largest when the system is least busy, and may be of little practical concern. Moreover, optimizing AdvanceXLInsertBuffer would reveal one more complication: some of the empty pages about to be written out may have been initialized opportunistically in earlier calls to AdvanceXLInsertBuffer, so those already have populated headers, and would need rezeroing anyway. And not necessarily just an insignificant few of them: if XLOGChooseNumBuffers chose the maximum, it could even be all of them. That might also be handled by yet another conditional within AdvanceXLInsertBuffer. But with all of that in view, maybe it is just simpler to have one loop in CopyXLogRecordToWAL simply zero them all, and leave AdvanceXLInsertBuffer alone, so no complexity is added when it is called from other sites that are arguably hotter. Zeroing SizeOfXLogShortPHD bytes doesn't cost a whole lot. -Chap -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers