Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtEW3-00013B-BG for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Feb 2019 16:33:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gtEW2-0006DK-6P for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Feb 2019 16:33:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtEW1-0006DD-SA for pgsql-hackers@lists.postgresql.org; Mon, 11 Feb 2019 16:33:06 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gtEVy-0006o9-L9 for pgsql-hackers@lists.postgresql.org; Mon, 11 Feb 2019 16:33:04 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id DA62D21C7BAB for ; Mon, 11 Feb 2019 19:33:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.31] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 9012F21C6E33 for ; Mon, 11 Feb 2019 19:33:01 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1549902781; bh=4z5aaR92d70S2ovbsZaUKFxJndR1S+g+a9Hp+1OSWi0=; h=Subject:To:References:From:Date:In-Reply-To; b=go38pdSqdpPcfd8yAU6BauNkxCew14FBUwPa1g2YYZOYY9lAcRuwPef7hbzwiQuTi zUynjDMbWFu2NNlki11Fv6IOU40aUVj/SU+tUiRjpjEg/j0CipSVhvqoEETqmC9RUW G/wOD8ubEQUsvOCYwFcHM83sxl63VSnRs7MzLB/U= Subject: Re: [PATCH] xlogreader: do not read a file block twice To: pgsql-hackers@lists.postgresql.org References: <2ddf4a32-517e-d6f4-d992-4a63b6035bfd@postgrespro.ru> From: Grigory Smolkin Message-ID: <87e30af6-f85a-dc95-4574-95cded028786@postgrespro.ru> Date: Mon, 11 Feb 2019 19:32:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <2ddf4a32-517e-d6f4-d992-4a63b6035bfd@postgrespro.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hm, looks like it could speed up PostgreSQL recovery, but is it safe? On 02/11/2019 07:25 PM, Arthur Zakirov wrote: > Hello hackers, > > Grigory noticed that one of our utilities has very slow performance > when xlogreader reads zlib archives. We found out that xlogreader > sometimes reads a WAL file block twice. > > zlib has slow performance when you read an archive not in sequential > order. I think reading a block twice in same position isn't > sequential, because gzread() moves current position forward and next > call gzseek() to the same position moves it back. > > It seems that the attached patch solves the issue. I think when reqLen > == state->readLen the requested block already is in the xlogreader's > buffer. > > What do you think? > -- Grigory Smolkin Postgres Professional: http://www.postgrespro.com The Russian Postgres Company