Re: LogwrtResult contended spinlock

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: LogwrtResult contended spinlock
Дата
Msg-id 20210129154018.GA7723@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: LogwrtResult contended spinlock  (Andres Freund <andres@anarazel.de>)
Ответы Re: LogwrtResult contended spinlock  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Re: LogwrtResult contended spinlock  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On 2020-Aug-31, Andres Freund wrote:

> Wouldn't the better fix here be to allow reading of individual members without a lock? E.g. by wrapping each in a
64bitatomic.
 

So I've been playing with this and I'm annoyed about having two
datatypes to represent Write/Flush positions:

typedef struct XLogwrtRqst
{
    XLogRecPtr    Write;            /* last byte + 1 to write out */
    XLogRecPtr    Flush;            /* last byte + 1 to flush */
} XLogwrtRqst;

typedef struct XLogwrtResult
{
    XLogRecPtr    Write;            /* last byte + 1 written out */
    XLogRecPtr    Flush;            /* last byte + 1 flushed */
} XLogwrtResult;

Don't they look, um, quite similar?  I am strongly tempted to remove
that distinction, since it seems quite pointless, and introduce a
different one:

typedef struct XLogwrtAtomic
{
    pg_atomic_uint64    Write;        /* last byte + 1 of write position */
    pg_atomic_uint64    Flush;        /* last byte + 1 of flush position */
} XLogwrtAtomic;

this one, with atomics, would be used for the XLogCtl struct members
LogwrtRqst and LogwrtResult, and are always accessed using atomic ops.
On the other hand we would have

typedef struct XLogwrt
{
    XLogRecPtr    Write;        /* last byte + 1 of write position */
    XLogRecPtr    Flush;        /* last byte + 1 of flush position */
} XLogwrt;

to be used for the local-memory-only LogwrtResult, using normal
assignment.

Now, I do wonder if there's a point in keeping LogwrtResult as a local
variable at all; maybe since the ones in shared memory are going to use
unlocked access, we don't need it anymore?  I'd prefer to defer that
decision to after this patch is done, since ISTM that it'd merit more
careful benchmarking.

Thoughts?

-- 
Álvaro Herrera       Valdivia, Chile



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Allow matching whole DN from a client certificate
Следующее
От: Alexander Korotkov
Дата:
Сообщение: Re: [HACKERS] [PATCH] Generic type subscripting