Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f20RH-0005OK-QT for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Mar 2018 20:15:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f20RE-00008t-T6 for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Mar 2018 20:15:52 +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.89) (envelope-from ) id 1f20RD-00008j-US for pgsql-hackers@lists.postgresql.org; Fri, 30 Mar 2018 20:15:52 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f20R4-00085p-FW for pgsql-hackers@postgresql.org; Fri, 30 Mar 2018 20:15:51 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id E7C2220E06; Fri, 30 Mar 2018 16:15:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Fri, 30 Mar 2018 16:15:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=lTvLzq 7SLDpMbaKc9P0r56uzrwUgo/1G903ofSriPKA=; b=Gzs6d+N7I+fjwcoBdzAbBp TGddsaUw7fTtdjnzgOG8VIzM4tCpkY7nAq/FrTezZT7nlbMrLKI4iYSGNDAdl5dn Y19595nX02EAYrXh9U5nemu3EIaGJqr99yzo+vRE7/9xH8iidb6arkVY/63F0vTN 4ESKuRBiuKmqWyVovk4GYASCFQgUsV5jnffFD5R8kFaBoat4BR0Uv30W1U/cagUW 8cKvAJXADS6gSLtEzqdOgoMGzcUu8HYchZqLTtktGs6/oI/kkJhdxpKN6vP8JPvH Ix0W4y4FkJrc7CuXioTx5TevPnghFpCJ3eLS7pqKJtf3RMObL+96WirMSVL33+Aw == X-ME-Sender: Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id A495DE4408; Fri, 30 Mar 2018 16:15:39 -0400 (EDT) Subject: Re: file cloning in pg_upgrade and CREATE DATABASE To: Michael Paquier References: <20180319070636.GA4633@paquier.xyz> <20180319071415.GB4633@paquier.xyz> <20180320025849.GB4963@paquier.xyz> <678999c6-0967-d22a-e7d1-2a3aff83a77b@2ndquadrant.com> <20180322023831.GG2490@paquier.xyz> <9380bebc-3c16-42f0-d0e1-da7c235f8a58@2ndquadrant.com> <20180326061516.GC2759@paquier.xyz> Cc: pgsql-hackers From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Fri, 30 Mar 2018 16:15:39 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180326061516.GC2759@paquier.xyz> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/26/18 02:15, Michael Paquier wrote: > f8c183a has introduced the optimization that your patch is removing, > which was discussed on this thread: > https://www.postgresql.org/message-id/flat/4B78906A.7020309%40mark.mielke.cc Note that that thread is from 2010 and talks about creation of a database from the standard template being too slow on spinning rust, because we fsync too often. I think we have moved well past that problem size. I have run some more tests on both macOS and Linux with ext4, and my results are that the bigger the flush distance, the better. Before we made the adjustments for APFS, we had a flush size of 64kB, now it's 1MB and 32MB on macOS. In my tests, I see 256MB as the best across both platforms, and not flushing early at all is only minimally worse. You can measure this to death, and this obviously doesn't apply equally on all systems and configurations, but clearly some of the old assumptions from 8 years ago are no longer applicable. > I am not much into the internals of copy_file_range, but isn't there a > risk to have a large range of blocks copied to discard potentially > useful blocks from the OS cache? That's what this patch makes me worry > about. Performance is good, but on a system where the OS cache is > heavily used for a set of hot blocks this could cause performance side > effects that I think we canot neglect. How would we go about assessing that? It's possible, but if copy_file_range() really blows away all your in-use cache, that would be surprising. > Another thing is that 71d6d07 allowed a couple of database commands to > be more sensitive to interruptions. With large databases used as a base > template it seems to me that this would cause the interruptions to be > less responsive. The maximum file size that we copy is 1GB and that nowadays takes maybe 10 seconds. I think that would be an acceptable response time. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services