On Fri, Mar 13, 2026, at 10:05 AM, Nathan Bossart wrote:
> On Fri, Mar 13, 2026 at 04:34:49PM +0300, Nazir Bilal Yavuz wrote:
>> On Fri, 13 Mar 2026 at 14:57, Nazir Bilal Yavuz <byavuz81@gmail.com> wrote:
>>> Unfortunately, v15 causes a regression for a 'csv & wide & 1/3' case
>>> on my end. v14 was taking 8000ms but v15 took ~9100ms. If we add the
>>> tmp_hit_eof variable then the regression disappears. Also, if I use a
>>> struct like below, regression disappears again.
>>
>>> When I removed the tmp_hit_eof variable on v14, I didn't encounter any
>>> regression. I really don't understand why this is happening on my end.
>>> Manni didn't encounter any regression on the benchmark [1].
>>
>> Problem might be related to gcc. I am using Debian Trixie and my
>> current gcc version is 'gcc version 14.2.0 (Debian 14.2.0-19)'. If I
>> compile Postgres with 'Debian clang version 19.1.7 (3+b1)', then there
>> is no regression, which makes more sense IMO.
>
> Let's just re-add the temporary variable for hit_eof. The struct idea is
> clever, but it's just a little more complicated than I think is necessary
> here.
>
> I've also removed the goto in favor of just duplicating the "out" code,
> like you had before. I'd like to avoid sporadic #ifndef USE_NO_SIMD uses,
> and goto is out of fashion, anyway.
Hey Nathan, Nazir, et. al.,
I've always been a fan of these kinds of optimization so I couldn't resist reviewing, but I know you're ready to commit
soI'll just check on some systems I have. :)
At first glance the implementation seems conservative, but correct and safe. Local testing on on Linux/FreeBSD x86_64,
andWin11/aarch64/MSVC seem good. I also tried IllumOS/SPARCv9 and with some fixes (from another active thread) to the
buildsystem and it worked just fine too. I'm sure the 10 people care will be thrilled. ;-P
I ran into the "out:" label not defined because USE_NO_SIMD wasn't defined when I tested v15 on Linux/RISC-V, my
build-farmanimal "greenfly" which is an Orange Pi RV2 running Linux 24.04.4 LTS. Looks like changes this morning have
fixedthat.
I would have reported earlier this morning but I detoured into RISC-V specific fixes and optimizations. Interestingly,
simd.huses a fixed-width Vector8 type (16 bytes on SSE2/NEON) and relies on sizeof(Vector8) throughout, however RISC-V
Vectortypes like vuint8m1_t are "sizeless" meaning that you cannot use sizeof() on them. To model that properly would
requireoverhauling all of simd.h, which is way out of scope for this patch so I'll start a new thread for that (and
CRC,and popcnt). I also created a few tests (attached) to check boundary conditions, I might add some along with the
RISC-Vwork.
nice work, LGTM.
-greg
> --
> nathan
>
> Attachments:
> * v17-0001-Optimize-COPY-FROM-FORMAT-text-csv-using-SIMD.patch