From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: WIP: Make timestamptz_out less slow. |
Date: | 2015-07-28 07:10:29 |
Message-ID: | 20150728071029.GB5000@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2015-07-28 10:59:15 +1200, David Rowley wrote:
> It won't be quite as fast as what you've written, but I think it will be
> much neater and more likely to be used in other places if we invent a
> function like pg_ltoa() which returns a pointer to the new end of string.
>
> Also if we're specifying padding with zeros then we can skip the reverse
> part that's in pg_ltoa(), (normally needed since the numeric string is
> build in reverse)
>
> The code could then be written as:
>
> str = pg_int2str_pad(str, year, 4);
> *str++ = '-';
> str = pg_int2str_pad(str, tm->tm_mon, 2);
> *str++ = '-';
> str = pg_int2str_pad(str, tm->tm_mday, 2);
>
> etc
>
> I've used this method before and found it to be about 10 times faster than
> snprintf(), but I was reversing the string, so quite likely it be more than
> 10 times.
Yes, that might be worthwhile to try. Certainly would look less
ugly. Willing to give it a try?
> I'm interested to see how much you're really gaining by manually unrolling
> the part that builds the fractional part of the second.
It seems to help a fair amount, but this really was more a quick POC
than something serious. My theory why it helps is that each loop
iteration is independent of the previous one and thus can take full
advantage of the pipeline.
Regards,
Andres
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Langote | 2015-07-28 07:16:22 | Typo in a comment in set_foreignscan_references |
Previous Message | Ashutosh Bapat | 2015-07-28 06:31:06 | Re: Autonomous Transaction is back |