Re: [PATCH] Optimize json_lex_string by batching character copying - Mailing list pgsql-hackers

From John Naylor
Subject Re: [PATCH] Optimize json_lex_string by batching character copying
Date
Msg-id CAFBsxsGzaaGLF=Nuq61iRXTyspbO9rOjhSqFN=V6ozzmta5mXg@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Optimize json_lex_string by batching character copying  (Andres Freund <andres@anarazel.de>)
Responses Re: [PATCH] Optimize json_lex_string by batching character copying
List pgsql-hackers

On Mon, Jul 11, 2022 at 11:07 PM Andres Freund <andres@anarazel.de> wrote:

> I wonder if we can add a somewhat more general function for scanning until
> some characters are found using SIMD? There's plenty other places that could
> be useful.

In simple cases, we could possibly abstract the entire loop. With this particular case, I imagine the most approachable way to write the loop would be a bit more low-level:

while (p < end - VECTOR_WIDTH &&
       !vector_has_byte(p, '\\') &&
       !vector_has_byte(p, '"') &&
       vector_min_byte(p, 0x20))
    p += VECTOR_WIDTH

I wonder if we'd lose a bit of efficiency here by not accumulating set bits from the three conditions, but it's worth trying.
--
John Naylor
EDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: "Fujii.Yuki@df.MitsubishiElectric.co.jp"
Date:
Subject: RE: WIP: Aggregation push-down - take2
Next
From: Richard Guo
Date:
Subject: Re: Making Vars outer-join aware