Re: Faster str to int conversion (was Table with large number of int columns, very slow COPY FROM)

From: Andres Freund <andres(at)anarazel(dot)de>
To: Alex Tokarev <dwalin(at)dwalin(dot)ru>, pgsql-hackers(at)postgresql(dot)org
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Faster str to int conversion (was Table with large number of int columns, very slow COPY FROM)
Date: 2018-07-07 20:01:58
Message-ID: 20180707200158.wpqkd7rjr4jxq5g7@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

Hi,

On 2017-12-08 13:44:37 -0800, Andres Freund wrote:
> On 2017-12-08 10:17:34 -0800, Andres Freund wrote:
> > the strtoll is libc functionality triggered by pg_atoi(), something I've
> > seen show up in numerous profiles. I think it's probably time to have
> > our own optimized version of it rather than relying on libcs.
>
> Attached is a hand-rolled version. After quickly hacking up one from
> scratch, I noticed we already kind of have one for int64 (scanint8), so
> I changed the structure of this one to be relatively similar.
>
> It's currently using the overflow logic from [1], but that's not
> fundamentally required, we could rely on fwrapv for this one too.
>
> This one improves performance of the submitted workload from 1223.950ms
> to 1020.640ms (best of three). The profile's shape changes quite
> noticeably:

FWIW, here's a rebased version of this patch. Could probably be polished
further. One might argue that we should do a bit more wide ranging
changes, to convert scanint8 and pg_atoi to be also unified. But it
might also just be worthwhile to apply without those, given the
performance benefit.

Anybody have an opinion on that?

Greetings,

Andres Freund

Attachment Content-Type Size
v1-0001-Hand-code-string-to-integer-conversion-for-perfor.patch text/x-diff 27.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2018-07-07 21:15:09 Re: [HACKERS] Bug in to_timestamp().
Previous Message David Fetter 2018-07-07 19:52:13 Re: How can we submit code patches that implement our (pending) patents?

Browse pgsql-performance by date

  From Date Subject
Next Message Mariel Cherkassky 2018-07-08 13:06:50 where can I download the binaries of plpython extension
Previous Message Peter Eisentraut 2018-07-07 07:47:47 Re: Trigger overhead/performance and alternatives?