mirror of
https://github.com/postgres/postgres.git
synced 2025-12-07 12:02:30 +03:00
Use atomic access for SlruShared->latest_page_number
The new concurrency model proposed for slru.c to improve performance does not include any single lock that would coordinate processes doing concurrent reads/writes on SlruShared->latest_page_number. We can instead use atomic reads and writes for that variable. Author: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Andrey M. Borodin <x4mmm@yandex-team.ru> Discussion: https://postgr.es/m/CAFiTN-vzDvNz=ExGXz6gdyjtzGixKSqs0mKHMmaQ8sOSEFZ33A@mail.gmail.com
This commit is contained in:
@@ -49,6 +49,9 @@ typedef enum
|
||||
|
||||
/*
|
||||
* Shared-memory state
|
||||
*
|
||||
* ControlLock is used to protect access to the other fields, except
|
||||
* latest_page_number, which uses atomics; see comment in slru.c.
|
||||
*/
|
||||
typedef struct SlruSharedData
|
||||
{
|
||||
@@ -95,7 +98,7 @@ typedef struct SlruSharedData
|
||||
* this is not critical data, since we use it only to avoid swapping out
|
||||
* the latest page.
|
||||
*/
|
||||
int64 latest_page_number;
|
||||
pg_atomic_uint64 latest_page_number;
|
||||
|
||||
/* SLRU's index for statistics purposes (might not be unique) */
|
||||
int slru_stats_idx;
|
||||
|
||||
Reference in New Issue
Block a user