Re: [WIP Patch] Using 128-bit integers for sum, avg and statistics aggregates

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [WIP Patch] Using 128-bit integers for sum, avg and statistics aggregates
Date: 2014-10-28 13:21:38
Message-ID: CAHyXU0xbDcX=OsddFxjkgTpwNRYUX0nx8P-fd_sXpJ4Hqhve5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Oct 25, 2014 at 9:38 AM, Andreas Karlsson <andreas(at)proxel(dot)se> wrote:
> Hi,
>
> There was recently talk about if we should start using 128-bit integers
> (where available) to speed up the aggregate functions over integers which
> uses numeric for their internal state. So I hacked together a patch for this
> to see what the performance gain would be.
>
> Previous thread:
> http://www.postgresql.org/message-id/20141017182500.GF2075@alap3.anarazel.de
>
> What the patch does is switching from using numerics in the aggregate state
> to int128 and then convert the type from the 128-bit integer in the final
> function.
>
> The functions where we can make use of int128 states are:
>
> - sum(int8)
> - avg(int8)
> - var_*(int2)
> - var_*(int4)
> - stdev_*(int2)
> - stdev_*(int4)
>
> The initial benchmark results look very promising. When summing 10 million
> int8 I get a speedup of ~2.5x and similarly for var_samp() on 10 million
> int4 I see a speed up of ~3.7x. To me this indicates that it is worth the
> extra code. What do you say? Is this worth implementing?

yes.

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2014-10-28 13:24:18 Re: Directory/File Access Permissions for COPY and Generic File Access Functions
Previous Message Robert Haas 2014-10-28 13:07:34 Re: Directory/File Access Permissions for COPY and Generic File Access Functions