Re: make additional use of optimized linear search routines

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: make additional use of optimized linear search routines
Date: 2022-09-02 12:15:46
Message-ID: CAMbWs4-aZr_SiAbKsoOjAN2v5OQ4+eWb7LSXHpHksK_Yr+-t3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 2, 2022 at 2:52 AM Nathan Bossart <nathandbossart(at)gmail(dot)com>
wrote:

> I'm hoping to spend a bit more time looking for additional applications of
> the pg_lfind*() suite of functions (and anywhere else where SIMD might be
> useful, really). If you have any ideas in mind, I'm all ears.

+1 for the proposal. I did some simple grep work in the source codes but
not too much outputs besides the two places addressed in your patches.

Here are some places I noticed that might be optimized with pg_lfind*().
But 1) these places have issues that arguments differ in signedness, and
2) I'm not sure whether they are performance-sensitive or not.

In check_valid_internal_signature()

for (int i = 0; i < nargs; i++)
{
if (declared_arg_types[i] == ret_type)
return NULL; /* OK */
}

In validateFkOnDeleteSetColumns()

for (int j = 0; j < numfks; j++)
{
if (fkattnums[j] == setcol_attnum)
{
seen = true;
break;
}
}

In pg_isolation_test_session_is_blocked()

for (i = 0; i < num_blocking_pids; i++)
for (j = 0; j < num_interesting_pids; j++)
{
if (blocking_pids[i] == interesting_pids[j])
PG_RETURN_BOOL(true);
}

In dotrim()

for (i = 0; i < setlen; i++)
{
if (str_ch == set[i])
break;
}
if (i >= setlen)
break; /* no match here */

And the function has_lock_conflicts().

Thanks
Richard

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2022-09-02 12:26:50 Re: Missing CFI in iterate_word_similarity()
Previous Message Justin Pryzby 2022-09-02 12:01:30 Re: Fix possible bogus array out of bonds (src/backend/access/brin/brin_minmax_multi.c)