X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D020A528EE for ; Wed, 10 Aug 2005 01:48:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73571-10 for ; Wed, 10 Aug 2005 04:48:14 +0000 (GMT) Received: from mail.Mi8.com (nycgw01.mi8.com [63.240.6.42]) by svr1.postgresql.org (Postfix) with ESMTP id 49BC95282F for ; Wed, 10 Aug 2005 01:48:13 -0300 (ADT) Received: from 172.16.1.118 by mail.Mi8.com with ESMTP (- GW01 Welcome to Mi8 Corporation www.Mi8.com); Wed, 10 Aug 2005 00:48:08 -0400 X-Server-Uuid: F1A2E19A-84E4-48DD-8F48-B475613F58B2 Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by d01smtp03.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 10 Aug 2005 00:48:08 -0400 Received: from 24.5.173.15 ([24.5.173.15]) by MI8NYCMAIL06.Mi8.com ( [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Wed, 10 Aug 2005 00:48:07 -0500 User-Agent: Microsoft-Entourage/11.1.0.040913 Date: Tue, 09 Aug 2005 21:48:02 -0700 Subject: Re: COPY FROM performance improvements From: "Luke Lonergan" To: "Tom Lane" Cc: "Alon Goldshuv" , pgsql-patches@postgresql.org Message-ID: In-Reply-To: <29007.1123387696@sss.pgh.pa.us> MIME-Version: 1.0 X-OriginalArrivalTime: 10 Aug 2005 04:48:08.0352 (UTC) FILETIME=[B4166A00:01C59D66] X-WSS-ID: 6EE7588227K5953989-01-01 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.591 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, RCVD_NUMERIC_HELO X-Spam-Level: * X-Archive-Number: 200508/81 X-Sequence-Number: 17028 Tom, > As best I can tell, my version of CopyReadAttributes is significantly > quicker than Alon's, approximately balancing out the fact that my > version of CopyReadLine is slower. I did the latter first, and would > now be tempted to rewrite it in the same style as CopyReadAttributes, > ie one pass of memory-to-memory copy using pointers rather than buffer > indexes. I think you are right, with the exception that Alon's results prove out that the net result of your patch is 20% slower than his. I think with your speedup of CopyReadAttributes and some additional work on CopyReadLine the net result could be 50% faster than Alon's patch. The key thing that is missing is the lack of micro-parallelism in the character processing in this version. By "inverting the loop", or putting the characters into a buffer on the outside, then doing fast character scanning inside with special "fix-up" cases, we exposed long runs of pipeline-able code to the compiler. I think there is another way to accomplish the same thing and still preserve the current structure, but it requires "strip mining" the character buffer into chunks that can be processed with an explicit loop to check for the different characters. While it may seem artificial (it is), it will provide the compiler with the ability to pipeline the character finding logic over long runs. The other necessary element will have to avoid pipeline stalls from the "if" conditions as much as possible. Anyway, thanks for reviewing this code and improving it - it's important to bring speed increases to our collective customer base. With Bizgres, we're not satisfied with 12 MB/s, we won't stop until we saturate the I/O bus, so we may get more extreme with the code than seems reasonable for the general audience. - Luke