Re: ResourceOwner refactoring - Mailing list pgsql-hackers

From Andres Freund
Subject Re: ResourceOwner refactoring
Date
Msg-id 20230710194000.fh5scmicma5snbcc@awork3.anarazel.de
Whole thread Raw
In response to Re: ResourceOwner refactoring  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hi,

On 2023-07-10 12:14:46 -0700, Andres Freund wrote:
> >  /*
> > - * Initially allocated size of a ResourceArray.  Must be power of two since
> > - * we'll use (arraysize - 1) as mask for hashing.
> > + * Size of the fixed-size array to hold most-recently remembered resources.
> >   */
> > -#define RESARRAY_INIT_SIZE 16
> > +#define RESOWNER_ARRAY_SIZE 32
>
> That's 512 bytes, pretty large to be searched sequentially. It's somewhat sad
> that the array needs to include 8 byte of ResourceOwnerFuncs...

On that note:

It's perhaps worth noting that this change actually *increases* the size of
ResourceOwnerData. Previously:

        /* size: 576, cachelines: 9, members: 19 */
        /* sum members: 572, holes: 1, sum holes: 4 */

now:
        /* size: 696, cachelines: 11, members: 13 */
        /* sum members: 693, holes: 1, sum holes: 3 */

It won't make a difference memory-usage wise, given aset.c's rounding
behaviour. But it does mean that more memory needs to be zeroed, as
ResourceOwnerCreate() uses MemoryContextAllocZero.

As there's really no need to initialize the long ->arr, ->locks, it seems
worth to just initialize explicitly instead of using MemoryContextAllocZero().


With the new representation, is there any point in having ->locks? We still
need ->nlocks to be able to switch to the lossy behaviour, but there doesn't
seem to be much point in having the separate array.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: ResourceOwner refactoring
Next
From: Tomas Vondra
Date:
Subject: Re: PATCH: Using BRIN indexes for sorted output