| From: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
|---|---|
| To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Cc: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Haibo Yan <tristan(dot)yim(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Optimize UUID parse using SIMD |
| Date: | 2026-08-17 23:45:00 |
| Message-ID: | CALj2ACX_fW7+krZX1pLPt=mGMCg69DNtE=SGu3yhpuhBwDdtJA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Mon, Aug 17, 2026 at 3:21 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> > > > It doesn't have to be exactly 39; 1024 (long enough) would also work, or perhaps something based on UUID_LEN, such as UUID_LEN * 3. I think the main point is to avoid unbounded scanning on malformed input.
> > > >
> > > > The old code did not have this issue because it only examined as much input as needed based on UUID_LEN. The new fast path starts to use strlen(), so this would be a new risk introduced by the optimization.
> > >
> > > I don't think the scan can be really unbounded. string_to_uuid()
> > > receives a cstring, so by the time it is called the caller has already
> > > walked or copied the whole string to produce it. So unless the
> > > unbounded scan can be reached in some path I have overlooked, I'd
> > > prefer to keep strlen() here. Happy to change it if you still think it
> > > is worth it.
> >
> > After more thoughts, while I still don't think the scan can be
> > unbounded, using strlen() would add an extra scan just to determine we
> > use hex_decode_safe(). I'll change it to use strnlen() instead.
>
> I've updated the patch accordingly. Please review it.
I reviewed the diff and the v5 patch looks good. Bounding the strlen
to 64 bytes seems fine. pgindent, make check, and make check-world are
all clean.
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bharath Rupireddy | 2026-08-18 00:00:00 | Re: [Patch] Omit virtual generated columns from test_decoding output |
| Previous Message | Bharath Rupireddy | 2026-08-17 23:30:00 | Re: Use WALReadFromBuffers in more places |