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 1i9X8I-0002yE-W2 for pgsql-hackers@arkaria.postgresql.org; Sun, 15 Sep 2019 16:12:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i9X8H-0006fx-CD for pgsql-hackers@arkaria.postgresql.org; Sun, 15 Sep 2019 16:12:13 +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 1i9X8G-0006fi-WC for pgsql-hackers@lists.postgresql.org; Sun, 15 Sep 2019 16:12:13 +0000 Received: from xvm-110-146.dc2.ghst.net ([46.226.110.146] helo=fetter.org) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1i9X8A-0000k6-AC for pgsql-hackers@postgresql.org; Sun, 15 Sep 2019 16:12:11 +0000 Received: by fetter.org (Postfix, from userid 1001) id 9792040B05; Sun, 15 Sep 2019 18:12:03 +0200 (CEST) Date: Sun, 15 Sep 2019 18:12:03 +0200 From: David Fetter To: Andrey Borodin Cc: PostgreSQL Development Subject: Re: Efficient output for integer types Message-ID: <20190915161203.GL31596@fetter.org> References: <20190915071848.GK31596@fetter.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Sep 15, 2019 at 02:06:29PM +0500, Andrey Borodin wrote: > > 15 сент. 2019 г., в 12:18, David Fetter написал(а): > > > > Please find attached a couple of patches intended to $subject. > > > > This patch set cut the time to copy ten million rows of randomly sized > > int8s (10 of them) by about a third, so at least for that case, it's > > pretty decent. > > Hi! Looks cool. > > Just curious if for any fixed base and square here > > + while(uvalue >= base) > { > + const int i = (uvalue % square) * 2; > + uvalue /= square; > + vallen += 2; > + memcpy(convert + sizeof(convert) - vallen, digits + i, 2); > + } > > compiler will have a chance to avoid idiv instruction? That could very well be. I took the idea (and most of the code) from the Ryū implementation Andrew Gierth committed for 12. > Maybe few specialized functions could work better than generic > algorithm? Could be. What do you have in mind? I'm guessing that the ones for decimals, that being both the most common case and the least obvious as to how to optimize, would give the most benefit. Best, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate