Re: make additional use of optimized linear search routines - Mailing list pgsql-hackers

From Richard Guo
Subject Re: make additional use of optimized linear search routines
Date
Msg-id CAMbWs4-aZr_SiAbKsoOjAN2v5OQ4+eWb7LSXHpHksK_Yr+-t3A@mail.gmail.com
Whole thread Raw
In response to make additional use of optimized linear search routines  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: make additional use of optimized linear search routines
List pgsql-hackers

On Fri, Sep 2, 2022 at 2:52 AM Nathan Bossart <nathandbossart@gmail.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

pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: Fix possible bogus array out of bonds (src/backend/access/brin/brin_minmax_multi.c)
Next
From: Daniel Gustafsson
Date:
Subject: Re: Missing CFI in iterate_word_similarity()