Re: remove BufferBlockPointers for speed and space - Mailing list pgsql-patches

From Tom Lane
Subject Re: remove BufferBlockPointers for speed and space
Date
Msg-id 21559.1123767561@sss.pgh.pa.us
Whole thread Raw
In response to Re: remove BufferBlockPointers for speed and space  ("Qingqing Zhou" <zhouqq@cs.toronto.edu>)
List pgsql-patches
"Qingqing Zhou" <zhouqq@cs.toronto.edu> writes:
> The source code is attached.

>    gettimeofday(&start_t, NULL);
>    if (method == 0)
>    {
>     for (i = 0; i < NBuffers; i++)
>      k = array[i];
>    }
>    if (method == 1)
>    {
>     for (i = 0; i < NBuffers; i++)
>      k = start + i*BLCKSZ;
>    }
>    if (method == 2)
>    {
>     for (i = 0; i < NBuffers; i++)
>      k = start + (i<<13);
>    }
>    gettimeofday(&stop_t, NULL);

This is definitely going to tell us a lot more about the compiler's loop
strength reduction algorithms than it is going to tell about the time to
evaluate any one of these expressions in isolation.  What's worse, the
compiler would be quite within its rights to detect that k isn't used
anywhere, and optimize the loop away completely.

What I would suggest is first to fill another array with some large
number of buffer numbers (randomly chosen from 1..N) and then time loops
of the form

    for (i = 0; i < arraysize; i++)
    {
        bn = buffernumbers[i];
        bufferlocs[i] = BufferGetBlock(bn);
    }

for all three possible definitions of BufferGetBlock (where both arrays
are global variables, just to be sure the compiler doesn't think it can
discard the store).  This should give some numbers worth trusting.

            regards, tom lane

pgsql-patches by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: remove BufferBlockPointers for speed and space
Next
From: Matt Miller
Date:
Subject: Re: PL/pgSQL: #option select_into_1_row (was SELECT INTO