| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | Junwang Zhao <zhjwpku(at)gmail(dot)com>, zengxx <xiangxin_zeng(at)qq(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] numeric: canonicalize wide digit accumulation |
| Date: | 2026-10-13 11:43:06 |
| Message-ID: | a89cf7cb-671c-499d-a8c5-2d3e90de4d22@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 13/10/2026 06:24, Junwang Zhao wrote:
> On Sun, Oct 11, 2026 at 12:16 AM zengxx <xiangxin_zeng(at)qq(dot)com> wrote:
>> While looking at wide numeric aggregates, I found that the digit
>> accumulation loop in accum_sum_add() did not auto-vectorize. It advances
>> two indexes together:
>>
>> for (val_i = 0; val_i < val_ndigits; val_i++)
>> {
>> accum_digits[i] += (int32) val_digits[val_i];
>> i++;
>> }
>>
>> The attached patch advances the destination pointer once before the loop:
>>
>> accum_digits += accum->weight - val->weight;
>> for (val_i = 0; val_i < val_ndigits; val_i++)
>> accum_digits[val_i] += (int32) val_digits[val_i];
>
> One small nit, could we use i instead of val_i and declare it directly in the
> for loop, which seems like a modern coding style accepted by postgres.
Committed with that little change, thanks.
- Heikki
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alena Rybakina | 2026-10-13 11:44:15 | Re: pull-up subquery if JOIN-ON contains refs to upper-query |
| Previous Message | shihao zhong | 2026-10-13 11:41:06 | Re: [PG19] psql backslash commands fail with translated messages and a non UTF-8 client encoding |