Re: Why JIT speed improvement is so modest?

From: Andres Freund <andres(at)anarazel(dot)de>
To: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Why JIT speed improvement is so modest?
Date: 2019-12-06 17:36:07
Message-ID: 20191206173607.g6u3sz7oypq5mq3e@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2019-12-06 19:52:15 +0300, Konstantin Knizhnik wrote:
> On 06.12.2019 18:53, Robert Haas wrote:
> > On Thu, Nov 28, 2019 at 2:08 AM Konstantin Knizhnik
> > <k(dot)knizhnik(at)postgrespro(dot)ru> wrote:
> > > calls float4_accum for each row of T, the same query in VOPS will call
> > > vops_float4_avg_accumulate for each tile which contains 64 elements.
> > > So vops_float4_avg_accumulate is called 64 times less than float4_accum.
> > > And inside it contains straightforward loop:
> > >
> > > for (i = 0; i < TILE_SIZE; i++) {
> > > sum += opd->payload[i];
> > > }
> > >
> > > which can be optimized by compiler (loop unrolling, use of SIMD
> > > instructions,...).

I still fail to see what this has to do with the subject.

> > Part of the reason why the compiler can optimize that so well is
> > probably related to the fact that it includes no overflow checks.
>
> May it makes sense to use in aggregate transformation function which is not
> checking for overflow and perform this check only in final function?
> NaN and Inf values will be preserved in any case...

I mean I personally think it'd be ok to skip the overflow checks for
floating point operations, they're not all that useful in practice (if
not the opposite). But if you want correct overflow detection behaviour,
you cannot just check in the final function, as you cannot discern
between the state where infinity/NaN has been incorporated into the
transition state from cases where that has happened due to overflow etc.

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Nelson 2019-12-06 17:43:58 Re: Change atoi to strtol in same place
Previous Message Konstantin Knizhnik 2019-12-06 17:18:56 Re: Why JIT speed improvement is so modest?