Ryu floating point output patch

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Ryu floating point output patch
Date: 2018-12-13 19:41:55
Message-ID: 87r2el1bx6.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

This is a mostly cleaned-up version of the test patch I posted
previously for floating-point output using the Ryu algorithm.

Upstream source: github.com/ulfjack/ryu/ryu at commit 795c8b57a

From the upstream, I've taken only specific files which are
Boost-licensed, removed code not of interest to us, removed C99-isms,
applied project style for things like type names and use of INT64CONST,
removed some ad-hoc configuration #ifs in favour of using values
established by pg_config.h, and ran the whole thing through pgindent and
fixed up the resulting wreckage.

On top of that I made these functional changes:

1. Added an alternative fixed-point output format so that values with
exponents not less than -4 and less than the default precision for the
type are formatted in fixed-point, as sprintf does.

2. Exponents now always have a sign and at least two digits, also as per
sprintf formatting rules.

The fixed-point output hasn't been micro-optimized to the same extent as
the rest of the code, and there is a measurable performance effect - but
it's not that significant compared to the speedup over the existing code.

As for the extent of that speedup: in my tests, float8 output is now as
fast or marginally faster than bigint output, and roughly one order of
magnitude faster than the existing float8 output.

This version of the patch continues to use extra_float_digits to select
whether Ryu output is used - but I've also changed the default, so that
Ryu is used unless you explicitly set extra_float_digits to 0 or less.

This does mean that at the moment, about 13 regression tests fail on
this patch due to the higher precision of float output. I have
intentionally not yet adjusted those results, pending discussion.

Andrew (irc:RhodiumToad)

Attachment Content-Type Size
ryu.patch text/x-patch 99.2 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-12-13 19:46:11 Re: Connections hang indefinitely while taking a gin index's LWLock buffer_content lock
Previous Message Alexander Korotkov 2018-12-13 19:40:59 Re: Connections hang indefinitely while taking a gin index's LWLock buffer_content lock