Re: Small improvement to compactify_tuples

From: Claudio Freire <klaussfreire(at)gmail(dot)com>
To: Sokolov Yura <funny(dot)falcon(at)postgrespro(dot)ru>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL-Dev <pgsql-hackers(at)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)gmail(dot)com>
Subject: Re: Small improvement to compactify_tuples
Date: 2017-09-25 14:48:45
Message-ID: CAGTBQpYP1EYoZ4brVmPEs=o5a34hZeiBYi_Py5xdcez6HqdxoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Sep 23, 2017 at 5:56 AM, Sokolov Yura
<funny(dot)falcon(at)postgrespro(dot)ru> wrote:
> Hello, Claudio.
>
> Thank you for review and confirm of improvement.
>
>
> On 2017-09-23 01:12, Claudio Freire wrote:
>>
>>
>> Patch 1 applies cleanly, builds, and make check runs fine.
>>
>> The code looks similar in style to surrounding code too, so I'm not
>> going to complain about the abundance of underscores in the macros :-p
>>
>> I can reproduce the results in the OP's benchmark, with slightly
>> different numbers, but an overall improvement of ~6%, which matches
>> the OP's relative improvement.
>>
>> Algorithmically, everything looks sound.
>>
>>
>> A few minor comments about patch 1:
>>
>> + if (max == 1)
>> + goto end;
>>
>> That goto is unnecessary, you could just as simply say
>>
>> if (max > 1)
>> {
>> ...
>> }
>
>
> Done.
> (I don't like indentation, though :-( )
>
>>
>>
>> +#define pg_shell_sort_pass(elem_t, cmp, off) \
>> + do { \
>> + int _i, _j; \
>> + elem_t _temp; \
>> + for (_i = off; _i < _n; _i += off) \
>> + { \
>>
>> _n right there isn't declared in the macro, and it isn't an argument
>> either. It should be an argument, having stuff inherited from the
>> enclosing context like that is confusing.
>>
>> Same with _arr, btw.
>
>
> pg_shell_sort_pass is not intended to be used outside pg_shell_sort
> and ph_insertion_sort, so I think, stealing from their context is ok.
> Nonetheless, done.

Looks good.

Marking this patch as ready for committer

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2017-09-25 14:55:58 Re: [BUGS] BUG #14825: enum type: unsafe use?
Previous Message Peter Eisentraut 2017-09-25 14:45:28 Re: bgw_type (was Re: Why does logical replication launcher set application_name?)