MultiXact\SLRU buffers configuration

Started by Andrey M. Borodinover 5 years ago123 messages
#1Andrey M. Borodin
x4mmm@yandex-team.ru

Hi, hackers!

*** The problem ***
I'm investigating some cases of reduced database performance due to MultiXactOffsetLock contention (80% MultiXactOffsetLock, 20% IO DataFileRead).
The problem manifested itself during index repack and constraint validation. Both being effectively full table scans.
The database workload contains a lot of select for share\select for update queries. I've tried to construct synthetic world generator and could not achieve similar lock configuration: I see a lot of different locks in wait events, particularly a lot more MultiXactMemberLocks. But from my experiments with synthetic workload, contention of MultiXactOffsetLock can be reduced by increasing NUM_MXACTOFFSET_BUFFERS=8 to bigger numbers.

*** Question 1 ***
Is it safe to increase number of buffers of MultiXact\All SLRUs, recompile and run database as usual?
I cannot experiment much with production. But I'm mostly sure that bigger buffers will solve the problem.

*** Question 2 ***
Probably, we could do GUCs for SLRU sizes? Are there any reasons not to do them configurable? I think multis, clog, subtransactions and others will benefit from bigger buffer. But, probably, too much of knobs can be confusing.

*** Question 3 ***
MultiXact offset lock is always taken as exclusive lock. It turns MultiXact Offset subsystem to single threaded. If someone have good idea how to make it more concurrency-friendly, I'm willing to put some efforts into this.
Probably, I could just add LWlocks for each offset buffer page. Is it something worth doing? Or are there any hidden cavers and difficulties?

Thanks!

Best regards, Andrey Borodin.

#2Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Andrey M. Borodin (#1)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

8 мая 2020 г., в 21:36, Andrey M. Borodin <x4mmm@yandex-team.ru> написал(а):

*** The problem ***
I'm investigating some cases of reduced database performance due to MultiXactOffsetLock contention (80% MultiXactOffsetLock, 20% IO DataFileRead).
The problem manifested itself during index repack and constraint validation. Both being effectively full table scans.
The database workload contains a lot of select for share\select for update queries. I've tried to construct synthetic world generator and could not achieve similar lock configuration: I see a lot of different locks in wait events, particularly a lot more MultiXactMemberLocks. But from my experiments with synthetic workload, contention of MultiXactOffsetLock can be reduced by increasing NUM_MXACTOFFSET_BUFFERS=8 to bigger numbers.

*** Question 1 ***
Is it safe to increase number of buffers of MultiXact\All SLRUs, recompile and run database as usual?
I cannot experiment much with production. But I'm mostly sure that bigger buffers will solve the problem.

*** Question 2 ***
Probably, we could do GUCs for SLRU sizes? Are there any reasons not to do them configurable? I think multis, clog, subtransactions and others will benefit from bigger buffer. But, probably, too much of knobs can be confusing.

*** Question 3 ***
MultiXact offset lock is always taken as exclusive lock. It turns MultiXact Offset subsystem to single threaded. If someone have good idea how to make it more concurrency-friendly, I'm willing to put some efforts into this.
Probably, I could just add LWlocks for each offset buffer page. Is it something worth doing? Or are there any hidden cavers and difficulties?

I've created benchmark[0]https://github.com/x4m/multixact_stress imitating MultiXact pressure on my laptop: 7 clients are concurrently running select "select * from table where primary_key = ANY ($1) for share" where $1 is array of identifiers so that each tuple in a table is locked by different set of XIDs. During this benchmark I observe contention of MultiXactControlLock in pg_stat_activity

пятница, 8 мая 2020 г. 15:08:37 (every 1s)

pid | wait_event | wait_event_type | state | query
-------+----------------------------+-----------------+--------+----------------------------------------------------
41344 | ClientRead | Client | idle | insert into t1 select generate_series(1,1000000,1)
41375 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41377 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41378 | | | active | select * from t1 where i = ANY ($1) for share
41379 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41381 | | | active | select * from t1 where i = ANY ($1) for share
41383 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41385 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
(8 rows)

Finally, the benchmark is measuring time to execute select for update 42 times.

I've went ahead and created 3 patches:
1. Configurable SLRU buffer sizes for MultiXacOffsets and MultiXactMembers
2. Reduce locking level to shared on read of MultiXactId members
3. Configurable cache size

I've found out that:
1. When MultiXact working set does not fit into buffers - benchmark results grow very high. Yet, very big buffers slow down benchmark too. For this benchmark optimal SLRU size id 32 pages for offsets and 64 pages for members (defaults are 8 and 16 respectively).
2. Lock optimisation increases performance by 5% on default SLRU sizes. Actually, benchmark does not explicitly read MultiXactId members, but when it replaces one with another - it have to read previous set. I understand that we can construct benchmark to demonstrate dominance of any algorithm and 5% of synthetic workload is not a very big number. But it just make sense to try to take shared lock for reading.
3. Manipulations with cache size do not affect benchmark anyhow. It's somewhat expected: benchmark is designed to defeat cache, either way OffsetControlLock would not be stressed.

For our workload, I think we will just increase numbers of SLRU sizes. But patchset may be useful for tuning and as a performance optimisation of MultiXact.

Also MultiXacts seems to be not very good fit into SLRU design. I think it would be better to use B-tree as a container. Or at least make MultiXact members extendable in-place (reserve some size when multixact is created).
When we want to extend number of locks for a tuple currently we will:
1. Iterate through all SLRU buffers for offsets to read current offset (with exclusive lock for offsets)
2. Iterate through all buffers for members to find current members (with exclusive lock for members)
3. Create new members array with +1 xid
4. Iterate through all cache members to find out maybe there are any such cache item as what we are going to create
5. iterate over 1 again for write
6. Iterate over 2 again for write

Obviously this does not scale well - we cannot increase SLRU sizes for too long.

Thanks! I'd be happy to hear any feedback.

Best regards, Andrey Borodin.

[0]: https://github.com/x4m/multixact_stress

Attachments:

v1-0001-Add-GUCs-to-tune-MultiXact-SLRUs.patchapplication/octet-stream; name=v1-0001-Add-GUCs-to-tune-MultiXact-SLRUs.patch; x-unix-mode=0644Download
From 17ba50c29aafd2de81462e0aca70c8629076e52c Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sat, 9 May 2020 16:42:07 +0500
Subject: [PATCH v1 1/3] Add GUCs to tune MultiXact SLRUs

---
 doc/src/sgml/config.sgml               | 31 ++++++++++++++++++++++++++
 src/backend/access/transam/multixact.c |  8 +++----
 src/backend/utils/init/globals.c       |  3 +++
 src/backend/utils/misc/guc.c           | 22 ++++++++++++++++++
 src/include/access/multixact.h         |  4 ----
 src/include/miscadmin.h                |  2 ++
 6 files changed, 62 insertions(+), 8 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 3aea1763b4..71aa5c4900 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1746,6 +1746,37 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-multixact-offsets-slru-buffers" xreflabel="multixact_offsets_slru_buffers">
+      <term><varname>multixact_offsets_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact offsets. MultiXact offsets
+        are used to store informaion about offsets of multiple row lockers (caused by SELECT FOR UPDATE and others).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-slru-buffers" xreflabel="multixact_members_slru_buffers">
+      <term><varname>multixact_members_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact members. MultiXact members
+        are used to store informaion about XIDs of multiple row lockers. Tipically <varname>multixact_members_slru_buffers</varname>
+        is twice more than <varname>multixact_offsets_slru_buffers</varname>.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e2aa5c9ce4..d2ac029b98 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1812,8 +1812,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_slru_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_slru_buffers, 0));
 
 	return size;
 }
@@ -1829,11 +1829,11 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "multixact_offset", NUM_MXACTOFFSET_BUFFERS, 0,
+				  "multixact_offset", multixact_offsets_slru_buffers, 0,
 				  MultiXactOffsetControlLock, "pg_multixact/offsets",
 				  LWTRANCHE_MXACTOFFSET_BUFFERS);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "multixact_member", NUM_MXACTMEMBER_BUFFERS, 0,
+				  "multixact_member", multixact_members_slru_buffers, 0,
 				  MultiXactMemberControlLock, "pg_multixact/members",
 				  LWTRANCHE_MXACTMEMBER_BUFFERS);
 
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index eb19644419..aebfbdb67c 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -148,3 +148,6 @@ int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
 
 double		vacuum_cleanup_index_scale_factor;
+
+int			multixact_offsets_slru_buffers = 8;
+int			multixact_members_slru_buffers = 16;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 5bdc02fce2..b139e387f3 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2270,6 +2270,28 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index af4aac08bd..848398bf1e 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -28,10 +28,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MXACTOFFSET_BUFFERS		8
-#define NUM_MXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 14fa127ab1..95f4633a88 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -161,6 +161,8 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
-- 
2.24.2 (Apple Git-127)

v1-0002-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchapplication/octet-stream; name=v1-0002-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patch; x-unix-mode=0644Download
From 0a0ebc6391c33ca77260656d886224c71fb8ad96 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sat, 9 May 2020 21:19:18 +0500
Subject: [PATCH v1 2/3] Use shared lock in GetMultiXactIdMembers for offsets
 and members

Previously read of multixact required exclusive control locks in
offstes and members SLRUs. This could lead to contention.
In this commit we take advantge of SimpleLruReadPage_ReadOnly
similar to CLOG usage.
---
 src/backend/access/transam/clog.c      |  2 +-
 src/backend/access/transam/commit_ts.c |  2 +-
 src/backend/access/transam/multixact.c | 12 ++++++------
 src/backend/access/transam/slru.c      |  8 +++++---
 src/backend/access/transam/subtrans.c  |  2 +-
 src/backend/commands/async.c           |  2 +-
 src/backend/storage/lmgr/predicate.c   |  2 +-
 src/include/access/slru.h              |  2 +-
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index f8e7670f8d..2ae024608e 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -643,7 +643,7 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(ClogCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(ClogCtl, pageno, xid, false);
 	byteptr = ClogCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 630df672cc..1efa269339 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -342,7 +342,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, false);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index d2ac029b98..5387a3602d 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1321,12 +1321,12 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi, false);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1358,7 +1358,7 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, tmpMXact, true);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1382,7 +1382,7 @@ retry:
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
+	LWLockAcquire(MultiXactMemberControlLock, LW_SHARED);
 
 	truelength = 0;
 	prev_pageno = -1;
@@ -1399,7 +1399,7 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno, multi, true);
 			prev_pageno = pageno;
 		}
 
@@ -2745,7 +2745,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi, false);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b2316af779..ae63ad4e6c 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -470,17 +470,19 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
+ * Control lock will be held at exit. If lock_held is true at least
+ * shared control lock must be held.
  * It is unspecified whether the lock will be shared or exclusive.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid, bool lock_held)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (!lock_held)
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 25d7d739cf..98700f26a7 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -123,7 +123,7 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, false);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 0c9d20ebfc..a12447ecb5 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2005,7 +2005,7 @@ asyncQueueReadAllNotifications(void)
 			 * of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(AsyncCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, false);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 654584b77a..2969992a90 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -948,7 +948,7 @@ OldSerXidGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(OldSerXidSlruCtl,
-										OldSerXidPage(xid), xid);
+										OldSerXidPage(xid), xid, false);
 	val = OldSerXidValue(slotno, xid);
 	LWLockRelease(OldSerXidLock);
 	return val;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 00dbd803e1..916dd8203e 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -144,7 +144,7 @@ extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 							  TransactionId xid);
 extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-									   TransactionId xid);
+									   TransactionId xid, bool lock_held);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruFlush(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-- 
2.24.2 (Apple Git-127)

v1-0003-Make-MultiXact-local-cache-size-configurable.patchapplication/octet-stream; name=v1-0003-Make-MultiXact-local-cache-size-configurable.patch; x-unix-mode=0644Download
From 944551228e4c2b4ec015359821122d9676fcf7e0 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 11 May 2020 16:17:02 +0500
Subject: [PATCH v1 3/3] Make MultiXact local cache size configurable

---
 doc/src/sgml/config.sgml               | 16 ++++++++++++++++
 src/backend/access/transam/multixact.c |  2 +-
 src/backend/utils/init/globals.c       |  1 +
 src/backend/utils/misc/guc.c           | 10 ++++++++++
 src/include/miscadmin.h                |  1 +
 5 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 71aa5c4900..6dbc3ce5f1 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1777,6 +1777,22 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-multixact-local-cache-entries" xreflabel="multixact_local-cache-entries">
+      <term><varname>multixact_local_cache_entries</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_local_cache_entries</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded
+        by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while
+        lower values make cache lookup faster.
+        It defaults to 256.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 5387a3602d..62f9bf73eb 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1589,7 +1589,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
 	qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator);
 
 	dlist_push_head(&MXactCache, &entry->node);
-	if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
+	if (MXactCacheMembers++ >= multixact_local_cache_entries)
 	{
 		dlist_node *node;
 		mXactCacheEnt *entry;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index aebfbdb67c..b17382293c 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -151,3 +151,4 @@ double		vacuum_cleanup_index_scale_factor;
 
 int			multixact_offsets_slru_buffers = 8;
 int			multixact_members_slru_buffers = 16;
+int			multixact_local_cache_entries = 256;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index b139e387f3..a74f8a8f20 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2292,6 +2292,16 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM,
+			gettext_noop("Sets the number cached MultiXact by backend."),
+			NULL
+		},
+		&multixact_local_cache_entries,
+		256, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 95f4633a88..27d5170ff1 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -163,6 +163,7 @@ extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
 extern PGDLLIMPORT int multixact_offsets_slru_buffers;
 extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int multixact_local_cache_entries;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
-- 
2.24.2 (Apple Git-127)

#3Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Andrey M. Borodin (#2)
Re: MultiXact\SLRU buffers configuration

11 мая 2020 г., в 16:17, Andrey M. Borodin <x4mmm@yandex-team.ru> написал(а):

I've went ahead and created 3 patches:
1. Configurable SLRU buffer sizes for MultiXacOffsets and MultiXactMembers
2. Reduce locking level to shared on read of MultiXactId members
3. Configurable cache size

I'm looking more at MultiXact and it seems to me that we have a race condition there.

When we create a new MultiXact we do:
1. Generate new MultiXactId under MultiXactGenLock
2. Record new mxid with members and offset to WAL
3. Write offset to SLRU under MultiXactOffsetControlLock
4. Write members to SLRU under MultiXactMemberControlLock

When we read MultiXact we do:
1. Retrieve offset by mxid from SLRU under MultiXactOffsetControlLock
2. If offset is 0 - it's not filled in at step 4 of previous algorithm, we sleep and goto 1
3. Retrieve members from SLRU under MultiXactMemberControlLock
4. ..... what we do if there are just zeroes because step 4 is not executed yet? Nothing, return empty members list.

What am I missing?

Best regards, Andrey Borodin.

#4Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Andrey M. Borodin (#3)
Re: MultiXact\SLRU buffers configuration

At Wed, 13 May 2020 23:08:37 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

11 мая 2020 г., в 16:17, Andrey M. Borodin <x4mmm@yandex-team.ru> написал(а):

I've went ahead and created 3 patches:
1. Configurable SLRU buffer sizes for MultiXacOffsets and MultiXactMembers
2. Reduce locking level to shared on read of MultiXactId members
3. Configurable cache size

I'm looking more at MultiXact and it seems to me that we have a race condition there.

When we create a new MultiXact we do:
1. Generate new MultiXactId under MultiXactGenLock
2. Record new mxid with members and offset to WAL
3. Write offset to SLRU under MultiXactOffsetControlLock
4. Write members to SLRU under MultiXactMemberControlLock

But, don't we hold exclusive lock on the buffer through all the steps
above?

When we read MultiXact we do:
1. Retrieve offset by mxid from SLRU under MultiXactOffsetControlLock
2. If offset is 0 - it's not filled in at step 4 of previous algorithm, we sleep and goto 1
3. Retrieve members from SLRU under MultiXactMemberControlLock
4. ..... what we do if there are just zeroes because step 4 is not executed yet? Nothing, return empty members list.

So transactions never see such incomplete mxids, I believe.

What am I missing?

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#5Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Kyotaro Horiguchi (#4)
Re: MultiXact\SLRU buffers configuration

14 мая 2020 г., в 06:25, Kyotaro Horiguchi <horikyota.ntt@gmail.com> написал(а):

At Wed, 13 May 2020 23:08:37 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

11 мая 2020 г., в 16:17, Andrey M. Borodin <x4mmm@yandex-team.ru> написал(а):

I've went ahead and created 3 patches:
1. Configurable SLRU buffer sizes for MultiXacOffsets and MultiXactMembers
2. Reduce locking level to shared on read of MultiXactId members
3. Configurable cache size

I'm looking more at MultiXact and it seems to me that we have a race condition there.

When we create a new MultiXact we do:
1. Generate new MultiXactId under MultiXactGenLock
2. Record new mxid with members and offset to WAL
3. Write offset to SLRU under MultiXactOffsetControlLock
4. Write members to SLRU under MultiXactMemberControlLock

But, don't we hold exclusive lock on the buffer through all the steps
above?

Yes...Unless MultiXact is observed on StandBy. This could lead to observing inconsistent snapshot: one of lockers committed tuple delete, but standby sees it as alive.

When we read MultiXact we do:
1. Retrieve offset by mxid from SLRU under MultiXactOffsetControlLock
2. If offset is 0 - it's not filled in at step 4 of previous algorithm, we sleep and goto 1
3. Retrieve members from SLRU under MultiXactMemberControlLock
4. ..... what we do if there are just zeroes because step 4 is not executed yet? Nothing, return empty members list.

So transactions never see such incomplete mxids, I believe.

I've observed sleep in step 2. I believe it's possible to observe special effects of step 4 too.
Maybe we could add lock on standby to dismiss this 1000us wait? Sometimes it hits hard on Standbys: if someone is locking whole table on primary - all seq scans on standbys follow him with MultiXactOffsetControlLock contention.

It looks like this:
0x00007fcd56896ff7 in __GI___select (nfds=nfds@entry=0, readfds=readfds@entry=0x0, writefds=writefds@entry=0x0, exceptfds=exceptfds@entry=0x0, timeout=timeout@entry=0x7ffd83376fe0) at ../sysdeps/unix/sysv/linux/select.c:41
#0 0x00007fcd56896ff7 in __GI___select (nfds=nfds@entry=0, readfds=readfds@entry=0x0, writefds=writefds@entry=0x0, exceptfds=exceptfds@entry=0x0, timeout=timeout@entry=0x7ffd83376fe0) at ../sysdeps/unix/sysv/linux/select.c:41
#1 0x000056186e0d54bd in pg_usleep (microsec=microsec@entry=1000) at ./build/../src/port/pgsleep.c:56
#2 0x000056186dd5edf2 in GetMultiXactIdMembers (from_pgupgrade=0 '\000', onlyLock=<optimized out>, members=0x7ffd83377080, multi=3106214809) at ./build/../src/backend/access/transam/multixact.c:1370
#3 GetMultiXactIdMembers () at ./build/../src/backend/access/transam/multixact.c:1202
#4 0x000056186dd2d2d9 in MultiXactIdGetUpdateXid (xmax=<optimized out>, t_infomask=<optimized out>) at ./build/../src/backend/access/heap/heapam.c:7039
#5 0x000056186dd35098 in HeapTupleGetUpdateXid (tuple=tuple@entry=0x7fcba3b63d58) at ./build/../src/backend/access/heap/heapam.c:7080
#6 0x000056186e0cd0f8 in HeapTupleSatisfiesMVCC (htup=<optimized out>, snapshot=0x56186f44a058, buffer=230684) at ./build/../src/backend/utils/time/tqual.c:1091
#7 0x000056186dd2d922 in heapgetpage (scan=scan@entry=0x56186f4c8e78, page=page@entry=3620) at ./build/../src/backend/access/heap/heapam.c:439
#8 0x000056186dd2ea7c in heapgettup_pagemode (key=0x0, nkeys=0, dir=ForwardScanDirection, scan=0x56186f4c8e78) at ./build/../src/backend/access/heap/heapam.c:1034
#9 heap_getnext (scan=scan@entry=0x56186f4c8e78, direction=direction@entry=ForwardScanDirection) at ./build/../src/backend/access/heap/heapam.c:1801
#10 0x000056186de84f51 in SeqNext (node=node@entry=0x56186f4a4f78) at ./build/../src/backend/executor/nodeSeqscan.c:81
#11 0x000056186de6a3f1 in ExecScanFetch (recheckMtd=0x56186de84ef0 <SeqRecheck>, accessMtd=0x56186de84f20 <SeqNext>, node=0x56186f4a4f78) at ./build/../src/backend/executor/execScan.c:97
#12 ExecScan (node=0x56186f4a4f78, accessMtd=0x56186de84f20 <SeqNext>, recheckMtd=0x56186de84ef0 <SeqRecheck>) at ./build/../src/backend/executor/execScan.c:164

Best regards, Andrey Borodin.

#6Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Andrey M. Borodin (#5)
Re: MultiXact\SLRU buffers configuration

At Thu, 14 May 2020 10:19:42 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

I'm looking more at MultiXact and it seems to me that we have a race condition there.

When we create a new MultiXact we do:
1. Generate new MultiXactId under MultiXactGenLock
2. Record new mxid with members and offset to WAL
3. Write offset to SLRU under MultiXactOffsetControlLock
4. Write members to SLRU under MultiXactMemberControlLock

But, don't we hold exclusive lock on the buffer through all the steps
above?

Yes...Unless MultiXact is observed on StandBy. This could lead to observing inconsistent snapshot: one of lockers committed tuple delete, but standby sees it as alive.

Ah, right. I looked from GetNewMultiXactId. Actually
XLOG_MULTIXACT_CREATE_ID is not protected from concurrent reference to
the creating mxact id. And GetMultiXactIdMembers is considering that
case.

When we read MultiXact we do:
1. Retrieve offset by mxid from SLRU under MultiXactOffsetControlLock
2. If offset is 0 - it's not filled in at step 4 of previous algorithm, we sleep and goto 1
3. Retrieve members from SLRU under MultiXactMemberControlLock
4. ..... what we do if there are just zeroes because step 4 is not executed yet? Nothing, return empty members list.

So transactions never see such incomplete mxids, I believe.

I've observed sleep in step 2. I believe it's possible to observe special effects of step 4 too.
Maybe we could add lock on standby to dismiss this 1000us wait? Sometimes it hits hard on Standbys: if someone is locking whole table on primary - all seq scans on standbys follow him with MultiXactOffsetControlLock contention.

GetMultiXactIdMembers believes that 4 is successfully done if 2
returned valid offset, but actually that is not obvious.

If we add a single giant lock just to isolate ,say,
GetMultiXactIdMember and RecordNewMultiXact, it reduces concurrency
unnecessarily. Perhaps we need finer-grained locking-key for standby
that works similary to buffer lock on primary, that doesn't cause
confilicts between irrelevant mxids.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#7Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Kyotaro Horiguchi (#6)
Re: MultiXact\SLRU buffers configuration

14 мая 2020 г., в 11:16, Kyotaro Horiguchi <horikyota.ntt@gmail.com> написал(а):

At Thu, 14 May 2020 10:19:42 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

I'm looking more at MultiXact and it seems to me that we have a race condition there.

When we create a new MultiXact we do:
1. Generate new MultiXactId under MultiXactGenLock
2. Record new mxid with members and offset to WAL
3. Write offset to SLRU under MultiXactOffsetControlLock
4. Write members to SLRU under MultiXactMemberControlLock

But, don't we hold exclusive lock on the buffer through all the steps
above?

Yes...Unless MultiXact is observed on StandBy. This could lead to observing inconsistent snapshot: one of lockers committed tuple delete, but standby sees it as alive.

Ah, right. I looked from GetNewMultiXactId. Actually
XLOG_MULTIXACT_CREATE_ID is not protected from concurrent reference to
the creating mxact id. And GetMultiXactIdMembers is considering that
case.

When we read MultiXact we do:
1. Retrieve offset by mxid from SLRU under MultiXactOffsetControlLock
2. If offset is 0 - it's not filled in at step 4 of previous algorithm, we sleep and goto 1
3. Retrieve members from SLRU under MultiXactMemberControlLock
4. ..... what we do if there are just zeroes because step 4 is not executed yet? Nothing, return empty members list.

So transactions never see such incomplete mxids, I believe.

I've observed sleep in step 2. I believe it's possible to observe special effects of step 4 too.
Maybe we could add lock on standby to dismiss this 1000us wait? Sometimes it hits hard on Standbys: if someone is locking whole table on primary - all seq scans on standbys follow him with MultiXactOffsetControlLock contention.

GetMultiXactIdMembers believes that 4 is successfully done if 2
returned valid offset, but actually that is not obvious.

If we add a single giant lock just to isolate ,say,
GetMultiXactIdMember and RecordNewMultiXact, it reduces concurrency
unnecessarily. Perhaps we need finer-grained locking-key for standby
that works similary to buffer lock on primary, that doesn't cause
confilicts between irrelevant mxids.

We can just replay members before offsets. If offset is already there - members are there too.
But I'd be happy if we could mitigate those 1000us too - with a hint about last maixd state in a shared MX state, for example.

Actually, if we read empty mxid array instead of something that is replayed just yet - it's not a problem of inconsistency, because transaction in this mxid could not commit before we started. ISTM.
So instead of fix, we, probably, can just add a comment. If this reasoning is correct.

Best regards, Andrey Borodin.

#8Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Andrey M. Borodin (#7)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

At Thu, 14 May 2020 11:44:01 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

GetMultiXactIdMembers believes that 4 is successfully done if 2
returned valid offset, but actually that is not obvious.

If we add a single giant lock just to isolate ,say,
GetMultiXactIdMember and RecordNewMultiXact, it reduces concurrency
unnecessarily. Perhaps we need finer-grained locking-key for standby
that works similary to buffer lock on primary, that doesn't cause
confilicts between irrelevant mxids.

We can just replay members before offsets. If offset is already there - members are there too.
But I'd be happy if we could mitigate those 1000us too - with a hint about last maixd state in a shared MX state, for example.

Generally in such cases, condition variables would work. In the
attached PoC, the reader side gets no penalty in the "likely" code
path. The writer side always calls ConditionVariableBroadcast but the
waiter list is empty in almost all cases. But I couldn't cause the
situation where the sleep 1000u is reached.

Actually, if we read empty mxid array instead of something that is replayed just yet - it's not a problem of inconsistency, because transaction in this mxid could not commit before we started. ISTM.
So instead of fix, we, probably, can just add a comment. If this reasoning is correct.

The step 4 of the reader side reads the members of the target mxid. It
is already written if the offset of the *next* mxid is filled-in.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachments:

mxid_wait_instead_of_sleep.patchtext/x-patch; charset=us-asciiDownload
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e2aa5c9ce4..9db8f6cddd 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,7 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	ConditionVariable nextoff_cv;
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -873,6 +875,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetControlLock);
 
+	/*
+	 *  Let everybody know the offset of this mxid is recorded now. The waiters
+	 *  are waiting for the offset of the mxid next of the target to know the
+	 *  number of members of the target mxid, so we don't need to wait for
+	 *  members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoff_cv);
+
 	LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1367,9 +1377,19 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the offset.
+			 * Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoff_cv);
+
 			LWLockRelease(MultiXactOffsetControlLock);
 			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoff_cv,
+								   WAIT_EVENT_WAIT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1847,6 +1867,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoff_cv);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 0ecd29a1d9..1ac6b37188 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3879,6 +3879,9 @@ pgstat_get_wait_ipc(WaitEventIPC w)
 		case WAIT_EVENT_SYNC_REP:
 			event_name = "SyncRep";
 			break;
+		case WAIT_EVENT_WAIT_NEXT_MXMEMBERS:
+			event_name = "Mact/WaitNextXactMembers";
+			break;
 			/* no default case, so that compiler will warn */
 	}
 
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index ae9a39573c..e79bba0bef 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -886,7 +886,8 @@ typedef enum
 	WAIT_EVENT_REPLICATION_ORIGIN_DROP,
 	WAIT_EVENT_REPLICATION_SLOT_DROP,
 	WAIT_EVENT_SAFE_SNAPSHOT,
-	WAIT_EVENT_SYNC_REP
+	WAIT_EVENT_SYNC_REP,
+	WAIT_EVENT_WAIT_NEXT_MXMEMBERS
 } WaitEventIPC;
 
 /* ----------
#9Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Kyotaro Horiguchi (#8)
Re: MultiXact\SLRU buffers configuration

15 мая 2020 г., в 05:03, Kyotaro Horiguchi <horikyota.ntt@gmail.com> написал(а):

At Thu, 14 May 2020 11:44:01 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

GetMultiXactIdMembers believes that 4 is successfully done if 2
returned valid offset, but actually that is not obvious.

If we add a single giant lock just to isolate ,say,
GetMultiXactIdMember and RecordNewMultiXact, it reduces concurrency
unnecessarily. Perhaps we need finer-grained locking-key for standby
that works similary to buffer lock on primary, that doesn't cause
confilicts between irrelevant mxids.

We can just replay members before offsets. If offset is already there - members are there too.
But I'd be happy if we could mitigate those 1000us too - with a hint about last maixd state in a shared MX state, for example.

Generally in such cases, condition variables would work. In the
attached PoC, the reader side gets no penalty in the "likely" code
path. The writer side always calls ConditionVariableBroadcast but the
waiter list is empty in almost all cases. But I couldn't cause the
situation where the sleep 1000u is reached.

Thanks! That really looks like a good solution without magic timeouts. Beautiful!
I think I can create temporary extension which calls MultiXact API and tests edge-cases like this 1000us wait.
This extension will also be also useful for me to assess impact of bigger buffers, reduced read locking (as in my 2nd patch) and other tweaks.

Actually, if we read empty mxid array instead of something that is replayed just yet - it's not a problem of inconsistency, because transaction in this mxid could not commit before we started. ISTM.
So instead of fix, we, probably, can just add a comment. If this reasoning is correct.

The step 4 of the reader side reads the members of the target mxid. It
is already written if the offset of the *next* mxid is filled-in.

Most often - yes, but members are not guaranteed to be filled in order. Those who win MXMemberControlLock will write first.
But nobody can read members of MXID before it is returned. And its members will be written before returning MXID.

Best regards, Andrey Borodin.

#10Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Andrey M. Borodin (#9)
Re: MultiXact\SLRU buffers configuration

At Fri, 15 May 2020 14:01:46 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

15 мая 2020 г., в 05:03, Kyotaro Horiguchi <horikyota.ntt@gmail.com> написал(а):

At Thu, 14 May 2020 11:44:01 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

GetMultiXactIdMembers believes that 4 is successfully done if 2
returned valid offset, but actually that is not obvious.

If we add a single giant lock just to isolate ,say,
GetMultiXactIdMember and RecordNewMultiXact, it reduces concurrency
unnecessarily. Perhaps we need finer-grained locking-key for standby
that works similary to buffer lock on primary, that doesn't cause
confilicts between irrelevant mxids.

We can just replay members before offsets. If offset is already there - members are there too.
But I'd be happy if we could mitigate those 1000us too - with a hint about last maixd state in a shared MX state, for example.

Generally in such cases, condition variables would work. In the
attached PoC, the reader side gets no penalty in the "likely" code
path. The writer side always calls ConditionVariableBroadcast but the
waiter list is empty in almost all cases. But I couldn't cause the
situation where the sleep 1000u is reached.

Thanks! That really looks like a good solution without magic timeouts. Beautiful!
I think I can create temporary extension which calls MultiXact API and tests edge-cases like this 1000us wait.
This extension will also be also useful for me to assess impact of bigger buffers, reduced read locking (as in my 2nd patch) and other tweaks.

Happy to hear that, It would need to use timeout just in case, though.

Actually, if we read empty mxid array instead of something that is replayed just yet - it's not a problem of inconsistency, because transaction in this mxid could not commit before we started. ISTM.
So instead of fix, we, probably, can just add a comment. If this reasoning is correct.

The step 4 of the reader side reads the members of the target mxid. It
is already written if the offset of the *next* mxid is filled-in.

Most often - yes, but members are not guaranteed to be filled in order. Those who win MXMemberControlLock will write first.
But nobody can read members of MXID before it is returned. And its members will be written before returning MXID.

Yeah, right. Otherwise assertion failure happens.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#11Daniel Gustafsson
daniel@yesql.se
In reply to: Kyotaro Horiguchi (#8)
Re: MultiXact\SLRU buffers configuration

On 15 May 2020, at 02:03, Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:

Generally in such cases, condition variables would work. In the
attached PoC, the reader side gets no penalty in the "likely" code
path. The writer side always calls ConditionVariableBroadcast but the
waiter list is empty in almost all cases. But I couldn't cause the
situation where the sleep 1000u is reached.

The submitted patch no longer applies, can you please submit an updated
version? I'm marking the patch Waiting on Author in the meantime.

cheers ./daniel

#12Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Daniel Gustafsson (#11)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

2 июля 2020 г., в 17:02, Daniel Gustafsson <daniel@yesql.se> написал(а):

On 15 May 2020, at 02:03, Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:

Generally in such cases, condition variables would work. In the
attached PoC, the reader side gets no penalty in the "likely" code
path. The writer side always calls ConditionVariableBroadcast but the
waiter list is empty in almost all cases. But I couldn't cause the
situation where the sleep 1000u is reached.

The submitted patch no longer applies, can you please submit an updated
version? I'm marking the patch Waiting on Author in the meantime.

Thanks, Daniel! PFA V2

Best regards, Andrey Borodin.

Attachments:

v2-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchapplication/octet-stream; name=v2-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patch; x-unix-mode=0644Download
From 264b475fbf6ee519dc3b4eb2cca25145d2aaa569 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sat, 9 May 2020 21:19:18 +0500
Subject: [PATCH v2 1/4] Use shared lock in GetMultiXactIdMembers for offsets
 and members

Previously read of multixact required exclusive control locks in
offstes and members SLRUs. This could lead to contention.
In this commit we take advantge of SimpleLruReadPage_ReadOnly
similar to CLOG usage.
---
 src/backend/access/transam/clog.c      |  2 +-
 src/backend/access/transam/commit_ts.c |  2 +-
 src/backend/access/transam/multixact.c | 12 ++++++------
 src/backend/access/transam/slru.c      |  8 +++++---
 src/backend/access/transam/subtrans.c  |  2 +-
 src/backend/commands/async.c           |  2 +-
 src/backend/storage/lmgr/predicate.c   |  2 +-
 src/include/access/slru.h              |  2 +-
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index f3da40ae01..3614d0c774 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -643,7 +643,7 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid, false);
 	byteptr = XactCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9cdb136435..5fbbf446e3 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -342,7 +342,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, false);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 79ec21c75a..241d9dd78d 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1321,12 +1321,12 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi, false);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1358,7 +1358,7 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, tmpMXact, true);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1382,7 +1382,7 @@ retry:
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
+	LWLockAcquire(MultiXactMemberSLRULock, LW_SHARED);
 
 	truelength = 0;
 	prev_pageno = -1;
@@ -1399,7 +1399,7 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno, multi, true);
 			prev_pageno = pageno;
 		}
 
@@ -2745,7 +2745,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi, false);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 61249f4a12..96d0def5c2 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -475,17 +475,19 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
+ * Control lock will be held at exit. If lock_held is true at least
+ * shared control lock must be held.
  * It is unspecified whether the lock will be shared or exclusive.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid, bool lock_held)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (!lock_held)
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index f33ae407a6..8d8e0d9ec7 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -123,7 +123,7 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, false);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 71b7577afc..70085fc037 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2012,7 +2012,7 @@ asyncQueueReadAllNotifications(void)
 			 * part of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(NotifyCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, false);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d24919f76b..e2a7d00d37 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -948,7 +948,7 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(SerialSlruCtl,
-										SerialPage(xid), xid);
+										SerialPage(xid), xid, false);
 	val = SerialValue(slotno, xid);
 	LWLockRelease(SerialSLRULock);
 	return val;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 61fbc80ef0..471c692021 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -140,7 +140,7 @@ extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 							  TransactionId xid);
 extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-									   TransactionId xid);
+									   TransactionId xid, bool lock_held);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruFlush(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-- 
2.24.2 (Apple Git-127)

v2-0002-Make-MultiXact-local-cache-size-configurable.patchapplication/octet-stream; name=v2-0002-Make-MultiXact-local-cache-size-configurable.patch; x-unix-mode=0644Download
From 520686d6cc22a599bc06b91391171ca218c3db75 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 11 May 2020 16:17:02 +0500
Subject: [PATCH v2 2/4] Make MultiXact local cache size configurable

---
 doc/src/sgml/config.sgml               | 16 ++++++++++++++++
 src/backend/access/transam/multixact.c |  2 +-
 src/backend/utils/init/globals.c       |  1 +
 src/backend/utils/misc/guc.c           | 10 ++++++++++
 src/include/miscadmin.h                |  1 +
 5 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 94d99373a7..31d7c1f4b3 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1777,6 +1777,22 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-multixact-local-cache-entries" xreflabel="multixact_local-cache-entries">
+      <term><varname>multixact_local_cache_entries</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_local_cache_entries</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded
+        by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while
+        lower values make cache lookup faster.
+        It defaults to 256.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 241d9dd78d..445b6258a4 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1589,7 +1589,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
 	qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator);
 
 	dlist_push_head(&MXactCache, &entry->node);
-	if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
+	if (MXactCacheMembers++ >= multixact_local_cache_entries)
 	{
 		dlist_node *node;
 		mXactCacheEnt *entry;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 01e739da40..f404167ad0 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -151,3 +151,4 @@ double		vacuum_cleanup_index_scale_factor;
 
 int			multixact_offsets_slru_buffers = 8;
 int			multixact_members_slru_buffers = 16;
+int			multixact_local_cache_entries = 256;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index d1fbb75cd5..6443f595cc 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2273,6 +2273,16 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM,
+			gettext_noop("Sets the number cached MultiXact by backend."),
+			NULL
+		},
+		&multixact_local_cache_entries,
+		256, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index bb1475ad2b..9ce2adea63 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -163,6 +163,7 @@ extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
 extern PGDLLIMPORT int multixact_offsets_slru_buffers;
 extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int multixact_local_cache_entries;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
-- 
2.24.2 (Apple Git-127)

v2-0003-Add-conditional-variable-to-wait-for-next-MultXac.patchapplication/octet-stream; name=v2-0003-Add-conditional-variable-to-wait-for-next-MultXac.patch; x-unix-mode=0644Download
From ddde253b10b87d060d34f8d7250be27a27c18c0a Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Fri, 22 May 2020 14:13:33 +0500
Subject: [PATCH v2 3/4] Add conditional variable to wait for next MultXact
 offset in edge case

---
 src/backend/access/transam/multixact.c | 23 ++++++++++++++++++++++-
 src/backend/postmaster/pgstat.c        |  2 ++
 src/include/pgstat.h                   |  1 +
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 445b6258a4..02de9a7c13 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,7 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	ConditionVariable nextoff_cv;
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -873,6 +875,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
 
+	/*
+	 *  Let everybody know the offset of this mxid is recorded now. The waiters
+	 *  are waiting for the offset of the mxid next of the target to know the
+	 *  number of members of the target mxid, so we don't need to wait for
+	 *  members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoff_cv);
+
 	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1367,9 +1377,19 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the offset.
+			 * Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoff_cv);
+
 			LWLockRelease(MultiXactOffsetSLRULock);
 			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoff_cv,
+								   WAIT_EVENT_WAIT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1847,6 +1867,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoff_cv);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index edfa774ee4..4bce534c7a 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3877,6 +3877,8 @@ pgstat_get_wait_ipc(WaitEventIPC w)
 			break;
 		case WAIT_EVENT_XACT_GROUP_UPDATE:
 			event_name = "XactGroupUpdate";
+		case WAIT_EVENT_WAIT_NEXT_MXMEMBERS:
+			event_name = "MultiXact/WaitNextXactMembers";
 			break;
 			/* no default case, so that compiler will warn */
 	}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 1387201382..26f828597b 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -887,6 +887,7 @@ typedef enum
 	WAIT_EVENT_REPLICATION_SLOT_DROP,
 	WAIT_EVENT_SAFE_SNAPSHOT,
 	WAIT_EVENT_SYNC_REP,
+	WAIT_EVENT_WAIT_NEXT_MXMEMBERS,
 	WAIT_EVENT_XACT_GROUP_UPDATE
 } WaitEventIPC;
 
-- 
2.24.2 (Apple Git-127)

#13Daniel Gustafsson
daniel@yesql.se
In reply to: Andrey M. Borodin (#12)
Re: MultiXact\SLRU buffers configuration

On 8 Jul 2020, at 09:03, Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:

2 июля 2020 г., в 17:02, Daniel Gustafsson <daniel@yesql.se> написал(а):

On 15 May 2020, at 02:03, Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:

Generally in such cases, condition variables would work. In the
attached PoC, the reader side gets no penalty in the "likely" code
path. The writer side always calls ConditionVariableBroadcast but the
waiter list is empty in almost all cases. But I couldn't cause the
situation where the sleep 1000u is reached.

The submitted patch no longer applies, can you please submit an updated
version? I'm marking the patch Waiting on Author in the meantime.

Thanks, Daniel! PFA V2

This version too has stopped applying according to the CFbot. I've moved it to
the next commitfest as we're out of time in this one and it was only pointed
out now, but kept it Waiting on Author.

cheers ./daniel

#14Anastasia Lubennikova
a.lubennikova@postgrespro.ru
In reply to: Andrey M. Borodin (#12)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

On 08.07.2020 10:03, Andrey M. Borodin wrote:

2 июля 2020 г., в 17:02, Daniel Gustafsson <daniel@yesql.se> написал(а):

On 15 May 2020, at 02:03, Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:
Generally in such cases, condition variables would work. In the
attached PoC, the reader side gets no penalty in the "likely" code
path. The writer side always calls ConditionVariableBroadcast but the
waiter list is empty in almost all cases. But I couldn't cause the
situation where the sleep 1000u is reached.

The submitted patch no longer applies, can you please submit an updated
version? I'm marking the patch Waiting on Author in the meantime.

Thanks, Daniel! PFA V2

Best regards, Andrey Borodin.

1) The first patch is sensible and harmless, so I think it is ready for
committer. I haven't tested the performance impact, though.

2) I like the initial proposal to make various SLRU buffers
configurable, however, I doubt if it really solves the problem, or just
moves it to another place?

The previous patch you sent was based on some version that contained
changes for other slru buffers numbers: 'multixact_offsets_slru_buffers'
and 'multixact_members_slru_buffers'. Have you just forgot to attach
them? The patch message "[PATCH v2 2/4]" hints that you had 4 patches)
Meanwhile, I attach the rebased patch to calm down the CFbot. The
changes are trivial.

2.1) I think that both min and max values for this parameter are too
extreme. Have you tested them?

+               &multixact_local_cache_entries,
+               256, 2, INT_MAX / 2,

2.2) MAX_CACHE_ENTRIES is not used anymore, so it can be deleted.

3) No changes for third patch. I just renamed it for consistency.

--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachments:

v3-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchtext/x-patch; charset=UTF-8; name=v3-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchDownload
From 264b475fbf6ee519dc3b4eb2cca25145d2aaa569 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sat, 9 May 2020 21:19:18 +0500
Subject: [PATCH v2 1/4] Use shared lock in GetMultiXactIdMembers for offsets
 and members

Previously read of multixact required exclusive control locks in
offstes and members SLRUs. This could lead to contention.
In this commit we take advantge of SimpleLruReadPage_ReadOnly
similar to CLOG usage.
---
 src/backend/access/transam/clog.c      |  2 +-
 src/backend/access/transam/commit_ts.c |  2 +-
 src/backend/access/transam/multixact.c | 12 ++++++------
 src/backend/access/transam/slru.c      |  8 +++++---
 src/backend/access/transam/subtrans.c  |  2 +-
 src/backend/commands/async.c           |  2 +-
 src/backend/storage/lmgr/predicate.c   |  2 +-
 src/include/access/slru.h              |  2 +-
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index f3da40ae01..3614d0c774 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -643,7 +643,7 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid, false);
 	byteptr = XactCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9cdb136435..5fbbf446e3 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -342,7 +342,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, false);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 79ec21c75a..241d9dd78d 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1321,12 +1321,12 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi, false);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1358,7 +1358,7 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, tmpMXact, true);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1382,7 +1382,7 @@ retry:
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
+	LWLockAcquire(MultiXactMemberSLRULock, LW_SHARED);
 
 	truelength = 0;
 	prev_pageno = -1;
@@ -1399,7 +1399,7 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno, multi, true);
 			prev_pageno = pageno;
 		}
 
@@ -2745,7 +2745,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi, false);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 61249f4a12..96d0def5c2 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -475,17 +475,19 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
+ * Control lock will be held at exit. If lock_held is true at least
+ * shared control lock must be held.
  * It is unspecified whether the lock will be shared or exclusive.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid, bool lock_held)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (!lock_held)
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index f33ae407a6..8d8e0d9ec7 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -123,7 +123,7 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, false);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 71b7577afc..70085fc037 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2012,7 +2012,7 @@ asyncQueueReadAllNotifications(void)
 			 * part of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(NotifyCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, false);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d24919f76b..e2a7d00d37 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -948,7 +948,7 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(SerialSlruCtl,
-										SerialPage(xid), xid);
+										SerialPage(xid), xid, false);
 	val = SerialValue(slotno, xid);
 	LWLockRelease(SerialSLRULock);
 	return val;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 61fbc80ef0..471c692021 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -140,7 +140,7 @@ extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 							  TransactionId xid);
 extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-									   TransactionId xid);
+									   TransactionId xid, bool lock_held);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruFlush(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-- 
2.24.2 (Apple Git-127)

v3-0002-Make-MultiXact-local-cache-size-configurable.patchtext/x-patch; charset=UTF-8; name=v3-0002-Make-MultiXact-local-cache-size-configurable.patchDownload
commit 67053e7204b5044a7147d878eec4c66217495298
Author: anastasia <a.lubennikova@postgrespro.ru>
Date:   Fri Aug 28 19:15:41 2020 +0300

    Make MultiXact local cache size configurable

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 7a7177c550..14eea77f2b 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1821,6 +1821,22 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-multixact-local-cache-entries" xreflabel="multixact_local-cache-entries">
+      <term><varname>multixact_local_cache_entries</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_local_cache_entries</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded
+        by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while
+        lower values make cache lookup faster.
+        It defaults to 256.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index b8bedca04a..99a2bc7c80 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1589,7 +1589,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
 	qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator);
 
 	dlist_push_head(&MXactCache, &entry->node);
-	if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
+	if (MXactCacheMembers++ >= multixact_local_cache_entries)
 	{
 		dlist_node *node;
 		mXactCacheEnt *entry;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 6ab8216839..9ca71933dc 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -149,3 +149,5 @@ int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
 
 double		vacuum_cleanup_index_scale_factor;
+
+int         multixact_local_cache_entries = 256;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index de87ad6ef7..6f3027fd66 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2257,6 +2257,16 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM,
+			gettext_noop("Sets the number of cached MultiXact by backend."),
+			NULL
+		},
+		&multixact_local_cache_entries,
+		256, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 72e3352398..01af61c963 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,8 @@ extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
 
+extern PGDLLIMPORT int multixact_local_cache_entries;
+
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
 extern PGDLLIMPORT TimestampTz MyStartTimestamp;
v3-0003-Add-conditional-variable-to-wait-for-next-MultXac.patchtext/x-patch; charset=UTF-8; name=v3-0003-Add-conditional-variable-to-wait-for-next-MultXac.patchDownload
From ddde253b10b87d060d34f8d7250be27a27c18c0a Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Fri, 22 May 2020 14:13:33 +0500
Subject: [PATCH v2 3/4] Add conditional variable to wait for next MultXact
 offset in edge case

---
 src/backend/access/transam/multixact.c | 23 ++++++++++++++++++++++-
 src/backend/postmaster/pgstat.c        |  2 ++
 src/include/pgstat.h                   |  1 +
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 445b6258a4..02de9a7c13 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,7 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	ConditionVariable nextoff_cv;
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -873,6 +875,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
 
+	/*
+	 *  Let everybody know the offset of this mxid is recorded now. The waiters
+	 *  are waiting for the offset of the mxid next of the target to know the
+	 *  number of members of the target mxid, so we don't need to wait for
+	 *  members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoff_cv);
+
 	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1367,9 +1377,19 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the offset.
+			 * Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoff_cv);
+
 			LWLockRelease(MultiXactOffsetSLRULock);
 			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoff_cv,
+								   WAIT_EVENT_WAIT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1847,6 +1867,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoff_cv);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index edfa774ee4..4bce534c7a 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3877,6 +3877,8 @@ pgstat_get_wait_ipc(WaitEventIPC w)
 			break;
 		case WAIT_EVENT_XACT_GROUP_UPDATE:
 			event_name = "XactGroupUpdate";
+		case WAIT_EVENT_WAIT_NEXT_MXMEMBERS:
+			event_name = "MultiXact/WaitNextXactMembers";
 			break;
 			/* no default case, so that compiler will warn */
 	}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 1387201382..26f828597b 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -887,6 +887,7 @@ typedef enum
 	WAIT_EVENT_REPLICATION_SLOT_DROP,
 	WAIT_EVENT_SAFE_SNAPSHOT,
 	WAIT_EVENT_SYNC_REP,
+	WAIT_EVENT_WAIT_NEXT_MXMEMBERS,
 	WAIT_EVENT_XACT_GROUP_UPDATE
 } WaitEventIPC;
 
-- 
2.24.2 (Apple Git-127)

#15Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Anastasia Lubennikova (#14)
Re: MultiXact\SLRU buffers configuration

Hi, Anastasia!

28 авг. 2020 г., в 23:08, Anastasia Lubennikova <a.lubennikova@postgrespro.ru> написал(а):

1) The first patch is sensible and harmless, so I think it is ready for committer. I haven't tested the performance impact, though.

2) I like the initial proposal to make various SLRU buffers configurable, however, I doubt if it really solves the problem, or just moves it to another place?

The previous patch you sent was based on some version that contained changes for other slru buffers numbers: 'multixact_offsets_slru_buffers' and 'multixact_members_slru_buffers'. Have you just forgot to attach them? The patch message "[PATCH v2 2/4]" hints that you had 4 patches)
Meanwhile, I attach the rebased patch to calm down the CFbot. The changes are trivial.

2.1) I think that both min and max values for this parameter are too extreme. Have you tested them?

+               &multixact_local_cache_entries,
+               256, 2, INT_MAX / 2,

2.2) MAX_CACHE_ENTRIES is not used anymore, so it can be deleted.

3) No changes for third patch. I just renamed it for consistency.

Thank you for your review.

Indeed, I had 4th patch with tests, but these tests didn't work well: I still did not manage to stress SLRUs to reproduce problem from production...

You are absolutely correct in point 2: I did only tests with sane values. And observed extreme performance degradation with values ~ 64 megabytes. I do not know which highest values should we pick? 1Gb? Or highest possible functioning value?

I greatly appreciate your review, sorry for so long delay. Thanks!

Best regards, Andrey Borodin.

#16Anastasia Lubennikova
a.lubennikova@postgrespro.ru
In reply to: Andrey M. Borodin (#15)
Re: MultiXact\SLRU buffers configuration

On 28.09.2020 17:41, Andrey M. Borodin wrote:

Hi, Anastasia!

28 авг. 2020 г., в 23:08, Anastasia Lubennikova <a.lubennikova@postgrespro.ru> написал(а):

1) The first patch is sensible and harmless, so I think it is ready for committer. I haven't tested the performance impact, though.

2) I like the initial proposal to make various SLRU buffers configurable, however, I doubt if it really solves the problem, or just moves it to another place?

The previous patch you sent was based on some version that contained changes for other slru buffers numbers: 'multixact_offsets_slru_buffers' and 'multixact_members_slru_buffers'. Have you just forgot to attach them? The patch message "[PATCH v2 2/4]" hints that you had 4 patches)
Meanwhile, I attach the rebased patch to calm down the CFbot. The changes are trivial.

2.1) I think that both min and max values for this parameter are too extreme. Have you tested them?

+               &multixact_local_cache_entries,
+               256, 2, INT_MAX / 2,

2.2) MAX_CACHE_ENTRIES is not used anymore, so it can be deleted.

3) No changes for third patch. I just renamed it for consistency.

Thank you for your review.

Indeed, I had 4th patch with tests, but these tests didn't work well: I still did not manage to stress SLRUs to reproduce problem from production...

You are absolutely correct in point 2: I did only tests with sane values. And observed extreme performance degradation with values ~ 64 megabytes. I do not know which highest values should we pick? 1Gb? Or highest possible functioning value?

I would go with the values that we consider adequate for this setting.
As I see, there is no strict rule about it in guc.c and many variables
have large border values. Anyway, we need to explain it at least in the
documentation and code comments.

It seems that the default was conservative enough, so it can be also a
minimal value too. As for maximum, can you provide any benchmark
results? If we have a peak and a noticeable performance degradation
after that, we can use it to calculate the preferable maxvalue.

--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

#17Alexander Korotkov
aekorotkov@gmail.com
In reply to: Andrey M. Borodin (#15)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

Hi!

On Mon, Sep 28, 2020 at 5:41 PM Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:

28 авг. 2020 г., в 23:08, Anastasia Lubennikova <a.lubennikova@postgrespro.ru> написал(а):

1) The first patch is sensible and harmless, so I think it is ready for committer. I haven't tested the performance impact, though.

2) I like the initial proposal to make various SLRU buffers configurable, however, I doubt if it really solves the problem, or just moves it to another place?

The previous patch you sent was based on some version that contained changes for other slru buffers numbers: 'multixact_offsets_slru_buffers' and 'multixact_members_slru_buffers'. Have you just forgot to attach them? The patch message "[PATCH v2 2/4]" hints that you had 4 patches)
Meanwhile, I attach the rebased patch to calm down the CFbot. The changes are trivial.

2.1) I think that both min and max values for this parameter are too extreme. Have you tested them?

+               &multixact_local_cache_entries,
+               256, 2, INT_MAX / 2,

2.2) MAX_CACHE_ENTRIES is not used anymore, so it can be deleted.

3) No changes for third patch. I just renamed it for consistency.

Thank you for your review.

Indeed, I had 4th patch with tests, but these tests didn't work well: I still did not manage to stress SLRUs to reproduce problem from production...

You are absolutely correct in point 2: I did only tests with sane values. And observed extreme performance degradation with values ~ 64 megabytes. I do not know which highest values should we pick? 1Gb? Or highest possible functioning value?

I greatly appreciate your review, sorry for so long delay. Thanks!

I took a look at this patchset.

The 1st and 3rd patches look good to me. I made just minor improvements.
1) There is still a case when SimpleLruReadPage_ReadOnly() relocks the
SLRU lock, which is already taken in exclusive mode. I've evaded this
by passing the lock mode as a parameter to
SimpleLruReadPage_ReadOnly().
3) CHECK_FOR_INTERRUPTS() is not needed anymore, because it's called
inside ConditionVariableSleep() if needed. Also, no current wait
events use slashes, and I don't think we should introduce slashes
here. Even if we should, then we should also rename existing wait
events to be consistent with a new one. So, I've renamed the new wait
event to remove the slash.

Regarding the patch 2. I see the current documentation in the patch
doesn't explain to the user how to set the new parameter. I think we
should give users an idea what workloads need high values of
multixact_local_cache_entries parameter and what doesn't. Also, we
should explain the negative aspects of high values
multixact_local_cache_entries. Ideally, we should get the advantage
without overloading users with new nontrivial parameters, but I don't
have a particular idea here.

I'd like to propose committing 1 and 3, but leave 2 for further review.

------
Regards,
Alexander Korotkov

Attachments:

v4-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offsets.patchapplication/octet-stream; name=v4-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offsets.patchDownload
From 12bbf5dbd372a431d106e7e8c3ed50ffa5707a19 Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 01:50:08 +0300
Subject: [PATCH 1/3] Use shared lock in GetMultiXactIdMembers for offsets and
 members

Previously the read of multixact required exclusive control locks for both
offsets and members SLRUs.  This could lead to the excessive lock contention.
This commit we makes multixacts SLRU take advantage of SimpleLruReadPage_ReadOnly
similar to clog, commit_ts and subtrans.

In order to evade extra reacquiring of CLRU lock, we teach
SimpleLruReadPage_ReadOnly() to take into account the current lock mode and
report resulting lock mode back.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/clog.c      |  4 +++-
 src/backend/access/transam/commit_ts.c |  4 +++-
 src/backend/access/transam/multixact.c | 22 +++++++++++++++-------
 src/backend/access/transam/slru.c      | 23 +++++++++++++++++------
 src/backend/access/transam/subtrans.c  |  4 +++-
 src/backend/commands/async.c           |  4 +++-
 src/backend/storage/lmgr/predicate.c   |  4 +++-
 src/include/access/slru.h              |  2 +-
 src/include/storage/lwlock.h           |  2 ++
 9 files changed, 50 insertions(+), 19 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 034349aa7b9..4c372065dee 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -640,10 +640,11 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	int			lsnindex;
 	char	   *byteptr;
 	XidStatus	status;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid, &lockmode);
 	byteptr = XactCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
@@ -651,6 +652,7 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	lsnindex = GetLSNIndex(slotno, xid);
 	*lsn = XactCtl->shared->group_lsn[lsnindex];
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(XactSLRULock);
 
 	return status;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index cb8a9688018..c19b0b5399e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -288,6 +288,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	CommitTimestampEntry entry;
 	TransactionId oldestCommitTsXid;
 	TransactionId newestCommitTsXid;
+	LWLockMode	lockmode = LW_NONE;
 
 	if (!TransactionIdIsValid(xid))
 		ereport(ERROR,
@@ -342,7 +343,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, &lockmode);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
@@ -352,6 +353,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	if (nodeid)
 		*nodeid = entry.nodeid;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(CommitTsSLRULock);
 	return *ts != 0;
 }
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 43653fe5721..ccbce90f0ea 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1237,6 +1237,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	MultiXactId tmpMXact;
 	MultiXactOffset nextOffset;
 	MultiXactMember *ptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
 
@@ -1340,12 +1341,13 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1377,7 +1379,8 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+												tmpMXact, &lockmode);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1395,14 +1398,14 @@ retry:
 		length = nextMXOffset - offset;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember));
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
-
+	lockmode = LW_NONE;
 	truelength = 0;
 	prev_pageno = -1;
 	for (i = 0; i < length; i++, offset++)
@@ -1418,7 +1421,8 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno,
+												multi, &lockmode);
 			prev_pageno = pageno;
 		}
 
@@ -1441,6 +1445,7 @@ retry:
 		truelength++;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactMemberSLRULock);
 
 	/*
@@ -2733,6 +2738,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 	int			entryno;
 	int			slotno;
 	MultiXactOffset *offptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(MultiXactState->finishedStartup);
 
@@ -2749,10 +2755,12 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	*result = offset;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 16a78986971..ca0a23ab875 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -487,17 +487,23 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
- * It is unspecified whether the lock will be shared or exclusive.
+ * Control lock must be held in *lock_mode mode, which may be LW_NONE.  Control
+ * lock will be held at exit in at least shared mode.  Resulting control lock
+ * mode is set to *lock_mode.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid,
+						   LWLockMode *lock_mode)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (*lock_mode == LW_NONE)
+	{
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
+		*lock_mode = LW_SHARED;
+	}
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -517,8 +523,13 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
-	LWLockRelease(shared->ControlLock);
-	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+	if (*lock_mode != LW_EXCLUSIVE)
+	{
+		Assert(*lock_mode == LW_NONE);
+		LWLockRelease(shared->ControlLock);
+		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+		*lock_mode = LW_EXCLUSIVE;
+	}
 
 	return SimpleLruReadPage(ctl, pageno, true, xid);
 }
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 0111e867c79..7bb15431893 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -113,6 +113,7 @@ SubTransGetParent(TransactionId xid)
 	int			slotno;
 	TransactionId *ptr;
 	TransactionId parent;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* Can't ask about stuff that might not be around anymore */
 	Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
@@ -123,12 +124,13 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, &lockmode);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
 	parent = *ptr;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SubtransSLRULock);
 
 	return parent;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 8dbcace3f93..8b419575590 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2002,6 +2002,7 @@ asyncQueueReadAllNotifications(void)
 			int			curoffset = QUEUE_POS_OFFSET(pos);
 			int			slotno;
 			int			copysize;
+			LWLockMode	lockmode = LW_NONE;
 
 			/*
 			 * We copy the data from SLRU into a local buffer, so as to avoid
@@ -2010,7 +2011,7 @@ asyncQueueReadAllNotifications(void)
 			 * part of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(NotifyCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, &lockmode);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
@@ -2027,6 +2028,7 @@ asyncQueueReadAllNotifications(void)
 				   NotifyCtl->shared->page_buffer[slotno] + curoffset,
 				   copysize);
 			/* Release lock that we got from SimpleLruReadPage_ReadOnly() */
+			Assert(lockmode != LW_NONE);
 			LWLockRelease(NotifySLRULock);
 
 			/*
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8a365b400c6..a4df90a8aeb 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -924,6 +924,7 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	TransactionId tailXid;
 	SerCommitSeqNo val;
 	int			slotno;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(TransactionIdIsValid(xid));
 
@@ -946,8 +947,9 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(SerialSlruCtl,
-										SerialPage(xid), xid);
+										SerialPage(xid), xid, &lockmode);
 	val = SerialValue(slotno, xid);
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SerialSLRULock);
 	return val;
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index b39b43504d8..4b66d3b592b 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -142,7 +142,7 @@ extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 							  TransactionId xid);
 extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-									   TransactionId xid);
+									   TransactionId xid, LWLockMode *lock_mode);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index af9b41795d2..2684c8e51c9 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -129,6 +129,8 @@ extern PGDLLIMPORT int NamedLWLockTrancheRequests;
 
 typedef enum LWLockMode
 {
+	LW_NONE,					/* Not a lock mode. Indicates that there is
+								 * no lock. */
 	LW_EXCLUSIVE,
 	LW_SHARED,
 	LW_WAIT_UNTIL_FREE			/* A special mode used in PGPROC->lwWaitMode,
-- 
2.14.3

v4-0002-Make-MultiXact-local-cache-size-configurable.patchapplication/octet-stream; name=v4-0002-Make-MultiXact-local-cache-size-configurable.patchDownload
From b1af887f4c4e5402dce1b6ea226ac8b81b92443f Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 03:44:50 +0300
Subject: [PATCH 2/3] Make MultiXact local cache size configurable

---
 doc/src/sgml/config.sgml               | 16 ++++++++++++++++
 src/backend/access/transam/multixact.c |  2 +-
 src/backend/utils/init/globals.c       |  2 ++
 src/backend/utils/misc/guc.c           | 10 ++++++++++
 src/include/miscadmin.h                |  2 ++
 5 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index f043433e318..fd4ca293476 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1823,6 +1823,22 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-multixact-local-cache-entries" xreflabel="multixact_local-cache-entries">
+      <term><varname>multixact_local_cache_entries</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_local_cache_entries</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded
+        by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while
+        lower values make cache lookup faster.
+        It defaults to 256.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index ccbce90f0ea..57be24c0cc1 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1613,7 +1613,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
 	qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator);
 
 	dlist_push_head(&MXactCache, &entry->node);
-	if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
+	if (MXactCacheMembers++ >= multixact_local_cache_entries)
 	{
 		dlist_node *node;
 		mXactCacheEnt *entry;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 6ab82168398..9ca71933dcc 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -149,3 +149,5 @@ int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
 
 double		vacuum_cleanup_index_scale_factor;
+
+int         multixact_local_cache_entries = 256;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index a62d64eaa47..d667578cc33 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2257,6 +2257,16 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM,
+			gettext_noop("Sets the number of cached MultiXact by backend."),
+			NULL
+		},
+		&multixact_local_cache_entries,
+		256, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 72e33523984..01af61c963a 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,8 @@ extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
 
+extern PGDLLIMPORT int multixact_local_cache_entries;
+
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
 extern PGDLLIMPORT TimestampTz MyStartTimestamp;
-- 
2.14.3

v4-0003-Add-conditional-variable-to-wait-for-next-MultXact-o.patchapplication/octet-stream; name=v4-0003-Add-conditional-variable-to-wait-for-next-MultXact-o.patchDownload
From b878ffe74a10d34d312a7be66df7a53b423aaaec Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 01:55:31 +0300
Subject: [PATCH 3/3] Add conditional variable to wait for next MultXact offset
 in corner case

GetMultiXactIdMembers() has a corner case, when the next multixact offset is
not yet set.  In this case GetMultiXactIdMembers() has to sleep till this offset
is set.  Currently the sleeping is implemented in naive way using pg_sleep()
and retry.  This commit implements sleeping with conditional variable, which
provides more efficient way for waiting till the event.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/multixact.c | 29 +++++++++++++++++++++++++++--
 src/backend/postmaster/pgstat.c        |  2 ++
 src/include/pgstat.h                   |  1 +
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 57be24c0cc1..09df91899ec 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,7 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	ConditionVariable nextoff_cv;
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -892,6 +894,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
 
+	/*
+	 *  Let everybody know the offset of this mxid is recorded now. The waiters
+	 *  are waiting for the offset of the mxid next of the target to know the
+	 *  number of members of the target mxid, so we don't need to wait for
+	 *  members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoff_cv);
+
 	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1389,9 +1399,23 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the offset.
+			 * Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoff_cv);
+
+			/*
+			 * We don't have to recheck if multixact was filled in during
+			 * ConditionVariablePrepareToSleep(), because we were holding
+			 * MultiXactOffsetSLRULock.
+			 */
 			LWLockRelease(MultiXactOffsetSLRULock);
-			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoff_cv,
+								   WAIT_EVENT_WAIT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1873,6 +1897,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoff_cv);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 822f0ebc628..b99398a97e9 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -4020,6 +4020,8 @@ pgstat_get_wait_ipc(WaitEventIPC w)
 			break;
 		case WAIT_EVENT_XACT_GROUP_UPDATE:
 			event_name = "XactGroupUpdate";
+		case WAIT_EVENT_WAIT_NEXT_MXMEMBERS:
+			event_name = "MultiXactWaitNextMembers";
 			break;
 			/* no default case, so that compiler will warn */
 	}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index a821ff4f158..75ede141ab7 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -952,6 +952,7 @@ typedef enum
 	WAIT_EVENT_REPLICATION_SLOT_DROP,
 	WAIT_EVENT_SAFE_SNAPSHOT,
 	WAIT_EVENT_SYNC_REP,
+	WAIT_EVENT_WAIT_NEXT_MXMEMBERS,
 	WAIT_EVENT_XACT_GROUP_UPDATE
 } WaitEventIPC;
 
-- 
2.14.3

#18Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Alexander Korotkov (#17)
Re: MultiXact\SLRU buffers configuration

26 окт. 2020 г., в 06:05, Alexander Korotkov <aekorotkov@gmail.com> написал(а):

Hi!

On Mon, Sep 28, 2020 at 5:41 PM Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:

28 авг. 2020 г., в 23:08, Anastasia Lubennikova <a.lubennikova@postgrespro.ru> написал(а):

1) The first patch is sensible and harmless, so I think it is ready for committer. I haven't tested the performance impact, though.

2) I like the initial proposal to make various SLRU buffers configurable, however, I doubt if it really solves the problem, or just moves it to another place?

The previous patch you sent was based on some version that contained changes for other slru buffers numbers: 'multixact_offsets_slru_buffers' and 'multixact_members_slru_buffers'. Have you just forgot to attach them? The patch message "[PATCH v2 2/4]" hints that you had 4 patches)
Meanwhile, I attach the rebased patch to calm down the CFbot. The changes are trivial.

2.1) I think that both min and max values for this parameter are too extreme. Have you tested them?

+               &multixact_local_cache_entries,
+               256, 2, INT_MAX / 2,

2.2) MAX_CACHE_ENTRIES is not used anymore, so it can be deleted.

3) No changes for third patch. I just renamed it for consistency.

Thank you for your review.

Indeed, I had 4th patch with tests, but these tests didn't work well: I still did not manage to stress SLRUs to reproduce problem from production...

You are absolutely correct in point 2: I did only tests with sane values. And observed extreme performance degradation with values ~ 64 megabytes. I do not know which highest values should we pick? 1Gb? Or highest possible functioning value?

I greatly appreciate your review, sorry for so long delay. Thanks!

I took a look at this patchset.

The 1st and 3rd patches look good to me. I made just minor improvements.
1) There is still a case when SimpleLruReadPage_ReadOnly() relocks the
SLRU lock, which is already taken in exclusive mode. I've evaded this
by passing the lock mode as a parameter to
SimpleLruReadPage_ReadOnly().
3) CHECK_FOR_INTERRUPTS() is not needed anymore, because it's called
inside ConditionVariableSleep() if needed. Also, no current wait
events use slashes, and I don't think we should introduce slashes
here. Even if we should, then we should also rename existing wait
events to be consistent with a new one. So, I've renamed the new wait
event to remove the slash.

Regarding the patch 2. I see the current documentation in the patch
doesn't explain to the user how to set the new parameter. I think we
should give users an idea what workloads need high values of
multixact_local_cache_entries parameter and what doesn't. Also, we
should explain the negative aspects of high values
multixact_local_cache_entries. Ideally, we should get the advantage
without overloading users with new nontrivial parameters, but I don't
have a particular idea here.

I'd like to propose committing 1 and 3, but leave 2 for further review.

Thanks for your review, Alexander!
+1 for avoiding double locking in SimpleLruReadPage_ReadOnly().
Other changes seem correct to me too.

I've tried to find optimal value for cache size and it seems to me that it affects multixact scalability much less than sizes of offsets\members buffers. I concur that patch 2 of the patchset does not seem documented enough.

Best regards, Andrey Borodin.

#19Alexander Korotkov
aekorotkov@gmail.com
In reply to: Andrey Borodin (#18)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Mon, Oct 26, 2020 at 6:45 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

Thanks for your review, Alexander!
+1 for avoiding double locking in SimpleLruReadPage_ReadOnly().
Other changes seem correct to me too.

I've tried to find optimal value for cache size and it seems to me that it affects multixact scalability much less than sizes of offsets\members buffers. I concur that patch 2 of the patchset does not seem documented enough.

Thank you. I've made a few more minor adjustments to the patchset.
I'm going to push 0001 and 0003 if there are no objections.

------
Regards,
Alexander Korotkov

Attachments:

v5-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchapplication/octet-stream; name=v5-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchDownload
From e81bccfe1dbf0403163b8e1e836211e0dab1d7a4 Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Tue, 27 Oct 2020 19:29:56 +0300
Subject: [PATCH 1/3] Use shared lock in GetMultiXactIdMembers for offsets and
 members

Previously the read of multixact required exclusive control locks for both
offsets and members SLRUs.  This could lead to the excessive lock contention.
This commit we makes multixacts SLRU take advantage of SimpleLruReadPage_ReadOnly
similar to clog, commit_ts and subtrans.

In order to evade extra reacquiring of CLRU lock, we teach
SimpleLruReadPage_ReadOnly() to take into account the current lock mode and
report resulting lock mode back.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/clog.c      |  4 +++-
 src/backend/access/transam/commit_ts.c |  4 +++-
 src/backend/access/transam/multixact.c | 22 +++++++++++++++-------
 src/backend/access/transam/slru.c      | 23 +++++++++++++++++------
 src/backend/access/transam/subtrans.c  |  4 +++-
 src/backend/commands/async.c           |  4 +++-
 src/backend/storage/lmgr/lwlock.c      |  3 +++
 src/backend/storage/lmgr/predicate.c   |  4 +++-
 src/include/access/slru.h              |  2 +-
 src/include/storage/lwlock.h           |  2 ++
 10 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 034349aa7b9..4c372065dee 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -640,10 +640,11 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	int			lsnindex;
 	char	   *byteptr;
 	XidStatus	status;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid, &lockmode);
 	byteptr = XactCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
@@ -651,6 +652,7 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	lsnindex = GetLSNIndex(slotno, xid);
 	*lsn = XactCtl->shared->group_lsn[lsnindex];
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(XactSLRULock);
 
 	return status;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index cb8a9688018..c19b0b5399e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -288,6 +288,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	CommitTimestampEntry entry;
 	TransactionId oldestCommitTsXid;
 	TransactionId newestCommitTsXid;
+	LWLockMode	lockmode = LW_NONE;
 
 	if (!TransactionIdIsValid(xid))
 		ereport(ERROR,
@@ -342,7 +343,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, &lockmode);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
@@ -352,6 +353,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	if (nodeid)
 		*nodeid = entry.nodeid;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(CommitTsSLRULock);
 	return *ts != 0;
 }
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 43653fe5721..ccbce90f0ea 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1237,6 +1237,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	MultiXactId tmpMXact;
 	MultiXactOffset nextOffset;
 	MultiXactMember *ptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
 
@@ -1340,12 +1341,13 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1377,7 +1379,8 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+												tmpMXact, &lockmode);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1395,14 +1398,14 @@ retry:
 		length = nextMXOffset - offset;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember));
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
-
+	lockmode = LW_NONE;
 	truelength = 0;
 	prev_pageno = -1;
 	for (i = 0; i < length; i++, offset++)
@@ -1418,7 +1421,8 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno,
+												multi, &lockmode);
 			prev_pageno = pageno;
 		}
 
@@ -1441,6 +1445,7 @@ retry:
 		truelength++;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactMemberSLRULock);
 
 	/*
@@ -2733,6 +2738,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 	int			entryno;
 	int			slotno;
 	MultiXactOffset *offptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(MultiXactState->finishedStartup);
 
@@ -2749,10 +2755,12 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	*result = offset;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 16a78986971..ca0a23ab875 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -487,17 +487,23 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
- * It is unspecified whether the lock will be shared or exclusive.
+ * Control lock must be held in *lock_mode mode, which may be LW_NONE.  Control
+ * lock will be held at exit in at least shared mode.  Resulting control lock
+ * mode is set to *lock_mode.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid,
+						   LWLockMode *lock_mode)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (*lock_mode == LW_NONE)
+	{
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
+		*lock_mode = LW_SHARED;
+	}
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -517,8 +523,13 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
-	LWLockRelease(shared->ControlLock);
-	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+	if (*lock_mode != LW_EXCLUSIVE)
+	{
+		Assert(*lock_mode == LW_NONE);
+		LWLockRelease(shared->ControlLock);
+		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+		*lock_mode = LW_EXCLUSIVE;
+	}
 
 	return SimpleLruReadPage(ctl, pageno, true, xid);
 }
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 0111e867c79..7bb15431893 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -113,6 +113,7 @@ SubTransGetParent(TransactionId xid)
 	int			slotno;
 	TransactionId *ptr;
 	TransactionId parent;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* Can't ask about stuff that might not be around anymore */
 	Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
@@ -123,12 +124,13 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, &lockmode);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
 	parent = *ptr;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SubtransSLRULock);
 
 	return parent;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 8dbcace3f93..8b419575590 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2002,6 +2002,7 @@ asyncQueueReadAllNotifications(void)
 			int			curoffset = QUEUE_POS_OFFSET(pos);
 			int			slotno;
 			int			copysize;
+			LWLockMode	lockmode = LW_NONE;
 
 			/*
 			 * We copy the data from SLRU into a local buffer, so as to avoid
@@ -2010,7 +2011,7 @@ asyncQueueReadAllNotifications(void)
 			 * part of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(NotifyCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, &lockmode);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
@@ -2027,6 +2028,7 @@ asyncQueueReadAllNotifications(void)
 				   NotifyCtl->shared->page_buffer[slotno] + curoffset,
 				   copysize);
 			/* Release lock that we got from SimpleLruReadPage_ReadOnly() */
+			Assert(lockmode != LW_NONE);
 			LWLockRelease(NotifySLRULock);
 
 			/*
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 2fa90cc0954..8a7726f11c0 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -1068,6 +1068,8 @@ LWLockWakeup(LWLock *lock)
 static void
 LWLockQueueSelf(LWLock *lock, LWLockMode mode)
 {
+	Assert(mode != LW_NONE);
+
 	/*
 	 * If we don't have a PGPROC structure, there's no way to wait. This
 	 * should never occur, since MyProc should only be null during shared
@@ -1828,6 +1830,7 @@ LWLockRelease(LWLock *lock)
 		elog(ERROR, "lock %s is not held", T_NAME(lock));
 
 	mode = held_lwlocks[i].mode;
+	Assert(mode == LW_EXCLUSIVE || mode == LW_SHARED);
 
 	num_held_lwlocks--;
 	for (; i < num_held_lwlocks; i++)
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8a365b400c6..a4df90a8aeb 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -924,6 +924,7 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	TransactionId tailXid;
 	SerCommitSeqNo val;
 	int			slotno;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(TransactionIdIsValid(xid));
 
@@ -946,8 +947,9 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(SerialSlruCtl,
-										SerialPage(xid), xid);
+										SerialPage(xid), xid, &lockmode);
 	val = SerialValue(slotno, xid);
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SerialSLRULock);
 	return val;
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index b39b43504d8..4b66d3b592b 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -142,7 +142,7 @@ extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 							  TransactionId xid);
 extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-									   TransactionId xid);
+									   TransactionId xid, LWLockMode *lock_mode);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index af9b41795d2..e680c6397aa 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -129,6 +129,8 @@ extern PGDLLIMPORT int NamedLWLockTrancheRequests;
 
 typedef enum LWLockMode
 {
+	LW_NONE,					/* Not a lock mode. Indicates that there is no
+								 * lock. */
 	LW_EXCLUSIVE,
 	LW_SHARED,
 	LW_WAIT_UNTIL_FREE			/* A special mode used in PGPROC->lwWaitMode,
-- 
2.14.3

v5-0002-Make-MultiXact-local-cache-size-configurable.patchapplication/octet-stream; name=v5-0002-Make-MultiXact-local-cache-size-configurable.patchDownload
From 53ef71094688048002ffd1a62dbbb1a4a90d4691 Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 03:44:50 +0300
Subject: [PATCH 2/3] Make MultiXact local cache size configurable

---
 doc/src/sgml/config.sgml               | 16 ++++++++++++++++
 src/backend/access/transam/multixact.c |  2 +-
 src/backend/utils/init/globals.c       |  2 ++
 src/backend/utils/misc/guc.c           | 10 ++++++++++
 src/include/miscadmin.h                |  2 ++
 5 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index f043433e318..fd4ca293476 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1823,6 +1823,22 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-multixact-local-cache-entries" xreflabel="multixact_local-cache-entries">
+      <term><varname>multixact_local_cache_entries</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_local_cache_entries</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded
+        by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while
+        lower values make cache lookup faster.
+        It defaults to 256.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index ccbce90f0ea..57be24c0cc1 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1613,7 +1613,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
 	qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator);
 
 	dlist_push_head(&MXactCache, &entry->node);
-	if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
+	if (MXactCacheMembers++ >= multixact_local_cache_entries)
 	{
 		dlist_node *node;
 		mXactCacheEnt *entry;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 6ab82168398..9ca71933dcc 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -149,3 +149,5 @@ int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
 
 double		vacuum_cleanup_index_scale_factor;
+
+int         multixact_local_cache_entries = 256;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index a62d64eaa47..d667578cc33 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2257,6 +2257,16 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM,
+			gettext_noop("Sets the number of cached MultiXact by backend."),
+			NULL
+		},
+		&multixact_local_cache_entries,
+		256, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 72e33523984..01af61c963a 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,8 @@ extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
 
+extern PGDLLIMPORT int multixact_local_cache_entries;
+
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
 extern PGDLLIMPORT TimestampTz MyStartTimestamp;
-- 
2.14.3

v5-0003-Add-conditional-variable-to-wait-for-next-MultXact.patchapplication/octet-stream; name=v5-0003-Add-conditional-variable-to-wait-for-next-MultXact.patchDownload
From 8876966a703f35abf98b575978c9d38ff4297473 Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 01:55:31 +0300
Subject: [PATCH 3/3] Add conditional variable to wait for next MultXact offset
 in corner case

GetMultiXactIdMembers() has a corner case, when the next multixact offset is
not yet set.  In this case GetMultiXactIdMembers() has to sleep till this offset
is set.  Currently the sleeping is implemented in naive way using pg_sleep()
and retry.  This commit implements sleeping with conditional variable, which
provides more efficient way for waiting till the event.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/multixact.c | 35 ++++++++++++++++++++++++++++++++--
 src/backend/postmaster/pgstat.c        |  2 ++
 src/include/pgstat.h                   |  1 +
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 57be24c0cc1..70d977cba33 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,13 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	/*
+	 * Conditional variable for waiting till the filling of the next multixact
+	 * will be finished.  See GetMultiXactIdMembers() and RecordNewMultiXact()
+	 * for details.
+	 */
+	ConditionVariable nextoffCV;
+
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -892,6 +900,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
 
+	/*
+	 * Let everybody know the offset of this mxid is recorded now.  The
+	 * waiters are waiting for the offset of the mxid next of the target to
+	 * know the number of members of the target mxid, so we don't need to wait
+	 * for members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoffCV);
+
 	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1389,9 +1405,23 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the
+			 * offset. Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoffCV);
+
+			/*
+			 * We don't have to recheck if multixact was filled in during
+			 * ConditionVariablePrepareToSleep(), because we were holding
+			 * MultiXactOffsetSLRULock.
+			 */
 			LWLockRelease(MultiXactOffsetSLRULock);
-			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoffCV,
+								   WAIT_EVENT_WAIT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1873,6 +1903,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoffCV);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 822f0ebc628..b99398a97e9 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -4020,6 +4020,8 @@ pgstat_get_wait_ipc(WaitEventIPC w)
 			break;
 		case WAIT_EVENT_XACT_GROUP_UPDATE:
 			event_name = "XactGroupUpdate";
+		case WAIT_EVENT_WAIT_NEXT_MXMEMBERS:
+			event_name = "MultiXactWaitNextMembers";
 			break;
 			/* no default case, so that compiler will warn */
 	}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index a821ff4f158..75ede141ab7 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -952,6 +952,7 @@ typedef enum
 	WAIT_EVENT_REPLICATION_SLOT_DROP,
 	WAIT_EVENT_SAFE_SNAPSHOT,
 	WAIT_EVENT_SYNC_REP,
+	WAIT_EVENT_WAIT_NEXT_MXMEMBERS,
 	WAIT_EVENT_XACT_GROUP_UPDATE
 } WaitEventIPC;
 
-- 
2.14.3

#20Alexander Korotkov
aekorotkov@gmail.com
In reply to: Alexander Korotkov (#19)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Tue, Oct 27, 2020 at 8:02 PM Alexander Korotkov <aekorotkov@gmail.com> wrote:

On Mon, Oct 26, 2020 at 6:45 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

Thanks for your review, Alexander!
+1 for avoiding double locking in SimpleLruReadPage_ReadOnly().
Other changes seem correct to me too.

I've tried to find optimal value for cache size and it seems to me that it affects multixact scalability much less than sizes of offsets\members buffers. I concur that patch 2 of the patchset does not seem documented enough.

Thank you. I've made a few more minor adjustments to the patchset.
I'm going to push 0001 and 0003 if there are no objections.

I get that patchset v5 doesn't pass the tests due to typo in assert.
The fixes version is attached.

------
Regards,
Alexander Korotkov

Attachments:

v6-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchapplication/octet-stream; name=v6-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchDownload
From 9307192bbb9d1ee48aba5c335ae54cff7b34ffb7 Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Tue, 27 Oct 2020 19:29:56 +0300
Subject: [PATCH 1/3] Use shared lock in GetMultiXactIdMembers for offsets and
 members

Previously the read of multixact required exclusive control locks for both
offsets and members SLRUs.  This could lead to the excessive lock contention.
This commit we makes multixacts SLRU take advantage of SimpleLruReadPage_ReadOnly
similar to clog, commit_ts and subtrans.

In order to evade extra reacquiring of CLRU lock, we teach
SimpleLruReadPage_ReadOnly() to take into account the current lock mode and
report resulting lock mode back.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/clog.c      |  4 +++-
 src/backend/access/transam/commit_ts.c |  4 +++-
 src/backend/access/transam/multixact.c | 22 +++++++++++++++-------
 src/backend/access/transam/slru.c      | 23 +++++++++++++++++------
 src/backend/access/transam/subtrans.c  |  4 +++-
 src/backend/commands/async.c           |  4 +++-
 src/backend/storage/lmgr/lwlock.c      |  3 +++
 src/backend/storage/lmgr/predicate.c   |  4 +++-
 src/include/access/slru.h              |  2 +-
 src/include/storage/lwlock.h           |  2 ++
 10 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 034349aa7b9..4c372065dee 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -640,10 +640,11 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	int			lsnindex;
 	char	   *byteptr;
 	XidStatus	status;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid, &lockmode);
 	byteptr = XactCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
@@ -651,6 +652,7 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	lsnindex = GetLSNIndex(slotno, xid);
 	*lsn = XactCtl->shared->group_lsn[lsnindex];
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(XactSLRULock);
 
 	return status;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index cb8a9688018..c19b0b5399e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -288,6 +288,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	CommitTimestampEntry entry;
 	TransactionId oldestCommitTsXid;
 	TransactionId newestCommitTsXid;
+	LWLockMode	lockmode = LW_NONE;
 
 	if (!TransactionIdIsValid(xid))
 		ereport(ERROR,
@@ -342,7 +343,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, &lockmode);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
@@ -352,6 +353,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	if (nodeid)
 		*nodeid = entry.nodeid;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(CommitTsSLRULock);
 	return *ts != 0;
 }
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 43653fe5721..ccbce90f0ea 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1237,6 +1237,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	MultiXactId tmpMXact;
 	MultiXactOffset nextOffset;
 	MultiXactMember *ptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
 
@@ -1340,12 +1341,13 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1377,7 +1379,8 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+												tmpMXact, &lockmode);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1395,14 +1398,14 @@ retry:
 		length = nextMXOffset - offset;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember));
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
-
+	lockmode = LW_NONE;
 	truelength = 0;
 	prev_pageno = -1;
 	for (i = 0; i < length; i++, offset++)
@@ -1418,7 +1421,8 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno,
+												multi, &lockmode);
 			prev_pageno = pageno;
 		}
 
@@ -1441,6 +1445,7 @@ retry:
 		truelength++;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactMemberSLRULock);
 
 	/*
@@ -2733,6 +2738,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 	int			entryno;
 	int			slotno;
 	MultiXactOffset *offptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(MultiXactState->finishedStartup);
 
@@ -2749,10 +2755,12 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	*result = offset;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 16a78986971..cf89006e131 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -487,17 +487,23 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
- * It is unspecified whether the lock will be shared or exclusive.
+ * Control lock must be held in *lock_mode mode, which may be LW_NONE.  Control
+ * lock will be held at exit in at least shared mode.  Resulting control lock
+ * mode is set to *lock_mode.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid,
+						   LWLockMode *lock_mode)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (*lock_mode == LW_NONE)
+	{
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
+		*lock_mode = LW_SHARED;
+	}
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -517,8 +523,13 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
-	LWLockRelease(shared->ControlLock);
-	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+	if (*lock_mode != LW_EXCLUSIVE)
+	{
+		Assert(*lock_mode != LW_NONE);
+		LWLockRelease(shared->ControlLock);
+		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+		*lock_mode = LW_EXCLUSIVE;
+	}
 
 	return SimpleLruReadPage(ctl, pageno, true, xid);
 }
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 0111e867c79..7bb15431893 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -113,6 +113,7 @@ SubTransGetParent(TransactionId xid)
 	int			slotno;
 	TransactionId *ptr;
 	TransactionId parent;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* Can't ask about stuff that might not be around anymore */
 	Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
@@ -123,12 +124,13 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, &lockmode);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
 	parent = *ptr;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SubtransSLRULock);
 
 	return parent;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 8dbcace3f93..8b419575590 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2002,6 +2002,7 @@ asyncQueueReadAllNotifications(void)
 			int			curoffset = QUEUE_POS_OFFSET(pos);
 			int			slotno;
 			int			copysize;
+			LWLockMode	lockmode = LW_NONE;
 
 			/*
 			 * We copy the data from SLRU into a local buffer, so as to avoid
@@ -2010,7 +2011,7 @@ asyncQueueReadAllNotifications(void)
 			 * part of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(NotifyCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, &lockmode);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
@@ -2027,6 +2028,7 @@ asyncQueueReadAllNotifications(void)
 				   NotifyCtl->shared->page_buffer[slotno] + curoffset,
 				   copysize);
 			/* Release lock that we got from SimpleLruReadPage_ReadOnly() */
+			Assert(lockmode != LW_NONE);
 			LWLockRelease(NotifySLRULock);
 
 			/*
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 2fa90cc0954..8a7726f11c0 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -1068,6 +1068,8 @@ LWLockWakeup(LWLock *lock)
 static void
 LWLockQueueSelf(LWLock *lock, LWLockMode mode)
 {
+	Assert(mode != LW_NONE);
+
 	/*
 	 * If we don't have a PGPROC structure, there's no way to wait. This
 	 * should never occur, since MyProc should only be null during shared
@@ -1828,6 +1830,7 @@ LWLockRelease(LWLock *lock)
 		elog(ERROR, "lock %s is not held", T_NAME(lock));
 
 	mode = held_lwlocks[i].mode;
+	Assert(mode == LW_EXCLUSIVE || mode == LW_SHARED);
 
 	num_held_lwlocks--;
 	for (; i < num_held_lwlocks; i++)
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8a365b400c6..a4df90a8aeb 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -924,6 +924,7 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	TransactionId tailXid;
 	SerCommitSeqNo val;
 	int			slotno;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(TransactionIdIsValid(xid));
 
@@ -946,8 +947,9 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(SerialSlruCtl,
-										SerialPage(xid), xid);
+										SerialPage(xid), xid, &lockmode);
 	val = SerialValue(slotno, xid);
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SerialSLRULock);
 	return val;
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index b39b43504d8..4b66d3b592b 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -142,7 +142,7 @@ extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 							  TransactionId xid);
 extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-									   TransactionId xid);
+									   TransactionId xid, LWLockMode *lock_mode);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index af9b41795d2..e680c6397aa 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -129,6 +129,8 @@ extern PGDLLIMPORT int NamedLWLockTrancheRequests;
 
 typedef enum LWLockMode
 {
+	LW_NONE,					/* Not a lock mode. Indicates that there is no
+								 * lock. */
 	LW_EXCLUSIVE,
 	LW_SHARED,
 	LW_WAIT_UNTIL_FREE			/* A special mode used in PGPROC->lwWaitMode,
-- 
2.14.3

v6-0002-Make-MultiXact-local-cache-size-configurable.patchapplication/octet-stream; name=v6-0002-Make-MultiXact-local-cache-size-configurable.patchDownload
From 2c40a5878da97b18e7e64a775f5caa0641e2f39c Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 03:44:50 +0300
Subject: [PATCH 2/3] Make MultiXact local cache size configurable

---
 doc/src/sgml/config.sgml               | 16 ++++++++++++++++
 src/backend/access/transam/multixact.c |  2 +-
 src/backend/utils/init/globals.c       |  2 ++
 src/backend/utils/misc/guc.c           | 10 ++++++++++
 src/include/miscadmin.h                |  2 ++
 5 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index f043433e318..fd4ca293476 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1823,6 +1823,22 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-multixact-local-cache-entries" xreflabel="multixact_local-cache-entries">
+      <term><varname>multixact_local_cache_entries</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_local_cache_entries</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded
+        by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while
+        lower values make cache lookup faster.
+        It defaults to 256.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index ccbce90f0ea..57be24c0cc1 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1613,7 +1613,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
 	qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator);
 
 	dlist_push_head(&MXactCache, &entry->node);
-	if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
+	if (MXactCacheMembers++ >= multixact_local_cache_entries)
 	{
 		dlist_node *node;
 		mXactCacheEnt *entry;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 6ab82168398..9ca71933dcc 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -149,3 +149,5 @@ int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
 
 double		vacuum_cleanup_index_scale_factor;
+
+int         multixact_local_cache_entries = 256;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index a62d64eaa47..d667578cc33 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2257,6 +2257,16 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM,
+			gettext_noop("Sets the number of cached MultiXact by backend."),
+			NULL
+		},
+		&multixact_local_cache_entries,
+		256, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 72e33523984..01af61c963a 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,8 @@ extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
 
+extern PGDLLIMPORT int multixact_local_cache_entries;
+
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
 extern PGDLLIMPORT TimestampTz MyStartTimestamp;
-- 
2.14.3

v6-0003-Add-conditional-variable-to-wait-for-next-MultXact.patchapplication/octet-stream; name=v6-0003-Add-conditional-variable-to-wait-for-next-MultXact.patchDownload
From da9cc973a4e7d568466b1c4de15479f707ad04f6 Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 01:55:31 +0300
Subject: [PATCH 3/3] Add conditional variable to wait for next MultXact offset
 in corner case

GetMultiXactIdMembers() has a corner case, when the next multixact offset is
not yet set.  In this case GetMultiXactIdMembers() has to sleep till this offset
is set.  Currently the sleeping is implemented in naive way using pg_sleep()
and retry.  This commit implements sleeping with conditional variable, which
provides more efficient way for waiting till the event.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/multixact.c | 35 ++++++++++++++++++++++++++++++++--
 src/backend/postmaster/pgstat.c        |  2 ++
 src/include/pgstat.h                   |  1 +
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 57be24c0cc1..70d977cba33 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,13 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	/*
+	 * Conditional variable for waiting till the filling of the next multixact
+	 * will be finished.  See GetMultiXactIdMembers() and RecordNewMultiXact()
+	 * for details.
+	 */
+	ConditionVariable nextoffCV;
+
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -892,6 +900,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
 
+	/*
+	 * Let everybody know the offset of this mxid is recorded now.  The
+	 * waiters are waiting for the offset of the mxid next of the target to
+	 * know the number of members of the target mxid, so we don't need to wait
+	 * for members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoffCV);
+
 	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1389,9 +1405,23 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the
+			 * offset. Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoffCV);
+
+			/*
+			 * We don't have to recheck if multixact was filled in during
+			 * ConditionVariablePrepareToSleep(), because we were holding
+			 * MultiXactOffsetSLRULock.
+			 */
 			LWLockRelease(MultiXactOffsetSLRULock);
-			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoffCV,
+								   WAIT_EVENT_WAIT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1873,6 +1903,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoffCV);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 822f0ebc628..b99398a97e9 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -4020,6 +4020,8 @@ pgstat_get_wait_ipc(WaitEventIPC w)
 			break;
 		case WAIT_EVENT_XACT_GROUP_UPDATE:
 			event_name = "XactGroupUpdate";
+		case WAIT_EVENT_WAIT_NEXT_MXMEMBERS:
+			event_name = "MultiXactWaitNextMembers";
 			break;
 			/* no default case, so that compiler will warn */
 	}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index a821ff4f158..75ede141ab7 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -952,6 +952,7 @@ typedef enum
 	WAIT_EVENT_REPLICATION_SLOT_DROP,
 	WAIT_EVENT_SAFE_SNAPSHOT,
 	WAIT_EVENT_SYNC_REP,
+	WAIT_EVENT_WAIT_NEXT_MXMEMBERS,
 	WAIT_EVENT_XACT_GROUP_UPDATE
 } WaitEventIPC;
 
-- 
2.14.3

#21Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Alexander Korotkov (#20)
Re: MultiXact\SLRU buffers configuration

On Tue, Oct 27, 2020 at 08:23:26PM +0300, Alexander Korotkov wrote:

On Tue, Oct 27, 2020 at 8:02 PM Alexander Korotkov <aekorotkov@gmail.com> wrote:

On Mon, Oct 26, 2020 at 6:45 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

Thanks for your review, Alexander!
+1 for avoiding double locking in SimpleLruReadPage_ReadOnly().
Other changes seem correct to me too.

I've tried to find optimal value for cache size and it seems to me that it affects multixact scalability much less than sizes of offsets\members buffers. I concur that patch 2 of the patchset does not seem documented enough.

Thank you. I've made a few more minor adjustments to the patchset.
I'm going to push 0001 and 0003 if there are no objections.

I get that patchset v5 doesn't pass the tests due to typo in assert.
The fixes version is attached.

I did a quick review on this patch series. A couple comments:

0001
----

This looks quite suspicious to me - SimpleLruReadPage_ReadOnly is
changed to return information about what lock was used, merely to allow
the callers to do an Assert() that the value is not LW_NONE.

IMO we could achieve exactly the same thing by passing a simple flag
that would say 'make sure we got a lock' or something like that. In
fact, aren't all callers doing the assert? That'd mean we can just do
the check always, without the flag. (I see GetMultiXactIdMembers does
two calls and only checks the second result, but I wonder if that's
intended or omission.)

In any case, it'd make the lwlock.c changes unnecessary, I think.

0002
----

Specifies the number cached MultiXact by backend. Any SLRU lookup ...

should be 'number of cached ...'

0003
----

* Conditional variable for waiting till the filling of the next multixact
* will be finished. See GetMultiXactIdMembers() and RecordNewMultiXact()
* for details.

Perhaps 'till the next multixact is filled' or 'gets full' would be
better. Not sure.

This thread started with a discussion about making the SLRU sizes
configurable, but this patch version only adds a local cache. Does this
achieve the same goal, or would we still gain something by having GUCs
for the SLRUs?

If we're claiming this improves performance, it'd be good to have some
workload demonstrating that and measurements. I don't see anything like
that in this thread, so it's a bit hand-wavy. Can someone share details
of such workload (even synthetic one) and some basic measurements?

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#22Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Tomas Vondra (#21)
4 attachment(s)
Re: MultiXact\SLRU buffers configuration

Tomas, thanks for looking into this!

28 окт. 2020 г., в 06:36, Tomas Vondra <tomas.vondra@2ndquadrant.com> написал(а):

This thread started with a discussion about making the SLRU sizes
configurable, but this patch version only adds a local cache. Does this
achieve the same goal, or would we still gain something by having GUCs
for the SLRUs?

If we're claiming this improves performance, it'd be good to have some
workload demonstrating that and measurements. I don't see anything like
that in this thread, so it's a bit hand-wavy. Can someone share details
of such workload (even synthetic one) and some basic measurements?

All patches in this thread aim at the same goal: improve performance in presence of MultiXact locks contention.
I could not build synthetical reproduction of the problem, however I did some MultiXact stressing here [0]https://github.com/x4m/multixact_stress. It's a clumsy test program, because it still is not clear to me which parameters of workload trigger MultiXact locks contention. In generic case I was encountering other locks like *GenLock: XidGenLock, MultixactGenLock etc. Yet our production system encounters this problem approximately once in a month through this year.

Test program locks for share different set of tuples in presence of concurrent full scans.
To produce a set of locks we choose one of 14 bits. If a row number has this bit set to 0 we add lock it.
I've been measuring time to lock all rows 3 time for each of 14 bits, observing total time to set all locks.
During the test I was observing locks in pg_stat_activity, if they did not contain enough MultiXact locks I was tuning parameters further (number of concurrent clients, number of bits, select queries etc).

Why is it so complicated? It seems that other reproductions of a problem were encountering other locks.

Lets describe patches in this thread from the POV of these test.

*** Configurable SLRU buffers for MultiXact members and offsets.
From tests it is clear that high and low values for these buffers affect the test time. Here are time for a one test run with different offsets and members sizes [1]https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L22-L39
Our production currently runs with (numbers are pages of buffers)
+#define NUM_MXACTOFFSET_BUFFERS 32
+#define NUM_MXACTMEMBER_BUFFERS 64
And, looking back to incidents in summer and fall 2020, seems like it helped mostly.

But it's hard to give some tuning advises based on test results. Values (32,64) produce 10% better result than current hardcoded values (8,16). In generic case this is not what someone should tune first.

*** Configurable caches of MultiXacts.
Tests were specifically designed to beat caches. So, according to test the bigger cache is - the more time it takes to accomplish the test [2]https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L83-L99.
Anyway cache is local for backend and it's purpose is deduplication of written MultiXacts, not enhancing reads.

*** Using advantage of SimpleLruReadPage_ReadOnly() in MultiXacts.
This simply aligns MultiXact with Subtransactions and CLOG. Other SLRUs already take advantage of reading SLRU with shared lock.
On synthetical tests without background selects this patch adds another ~4.7% of performance [3]https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L9 against [4]https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L29. This improvement seems consistent between different parameter values, yet within measurements deviation (see difference between warmup run [5]https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L3 and closing run [6]https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L19).
All in all, these attempts to measure impact are hand-wavy too. But it makes sense to use consistent approach among similar subsystems (MultiXacts, Subtrans, CLOG etc).

*** Reduce sleep in GetMultiXactIdMembers() on standby.
The problem with pg_usleep(1000L) within GetMultiXactIdMembers() manifests on standbys during contention of MultiXactOffsetControlLock. It's even harder to reproduce.
Yet it seems obvious that reducing sleep to shorter time frame will make count of sleeping backend smaller.

For consistency I've returned patch with SLRU buffer configs to patchset (other patches are intact). But I'm mostly concerned about patches 1 and 3.

Thanks!

Best regards, Andrey Borodin.

[0]: https://github.com/x4m/multixact_stress
[1]: https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L22-L39
[2]: https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L83-L99
[3]: https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L9
[4]: https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L29
[5]: https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L3
[6]: https://github.com/x4m/multixact_stress/blob/master/testresults.txt#L19

Attachments:

v6-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchapplication/octet-stream; name=v6-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patch; x-unix-mode=0644Download
From bcbd4f6d88d7b6dd9cf779b62e0e0261edadc71b Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Tue, 27 Oct 2020 19:29:56 +0300
Subject: [PATCH v6 1/4] Use shared lock in GetMultiXactIdMembers for offsets
 and members

Previously the read of multixact required exclusive control locks for both
offsets and members SLRUs.  This could lead to the excessive lock contention.
This commit we makes multixacts SLRU take advantage of SimpleLruReadPage_ReadOnly
similar to clog, commit_ts and subtrans.

In order to evade extra reacquiring of CLRU lock, we teach
SimpleLruReadPage_ReadOnly() to take into account the current lock mode and
report resulting lock mode back.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/clog.c      |  4 +++-
 src/backend/access/transam/commit_ts.c |  4 +++-
 src/backend/access/transam/multixact.c | 22 +++++++++++++++-------
 src/backend/access/transam/slru.c      | 23 +++++++++++++++++------
 src/backend/access/transam/subtrans.c  |  4 +++-
 src/backend/commands/async.c           |  4 +++-
 src/backend/storage/lmgr/lwlock.c      |  3 +++
 src/backend/storage/lmgr/predicate.c   |  4 +++-
 src/include/access/slru.h              |  2 +-
 src/include/storage/lwlock.h           |  2 ++
 10 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 034349aa7b..4c372065de 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -640,10 +640,11 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	int			lsnindex;
 	char	   *byteptr;
 	XidStatus	status;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid, &lockmode);
 	byteptr = XactCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
@@ -651,6 +652,7 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	lsnindex = GetLSNIndex(slotno, xid);
 	*lsn = XactCtl->shared->group_lsn[lsnindex];
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(XactSLRULock);
 
 	return status;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index cb8a968801..c19b0b5399 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -288,6 +288,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	CommitTimestampEntry entry;
 	TransactionId oldestCommitTsXid;
 	TransactionId newestCommitTsXid;
+	LWLockMode	lockmode = LW_NONE;
 
 	if (!TransactionIdIsValid(xid))
 		ereport(ERROR,
@@ -342,7 +343,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, &lockmode);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
@@ -352,6 +353,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	if (nodeid)
 		*nodeid = entry.nodeid;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(CommitTsSLRULock);
 	return *ts != 0;
 }
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 43653fe572..ccbce90f0e 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1237,6 +1237,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	MultiXactId tmpMXact;
 	MultiXactOffset nextOffset;
 	MultiXactMember *ptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
 
@@ -1340,12 +1341,13 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1377,7 +1379,8 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+												tmpMXact, &lockmode);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1395,14 +1398,14 @@ retry:
 		length = nextMXOffset - offset;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember));
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
-
+	lockmode = LW_NONE;
 	truelength = 0;
 	prev_pageno = -1;
 	for (i = 0; i < length; i++, offset++)
@@ -1418,7 +1421,8 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno,
+												multi, &lockmode);
 			prev_pageno = pageno;
 		}
 
@@ -1441,6 +1445,7 @@ retry:
 		truelength++;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactMemberSLRULock);
 
 	/*
@@ -2733,6 +2738,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 	int			entryno;
 	int			slotno;
 	MultiXactOffset *offptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(MultiXactState->finishedStartup);
 
@@ -2749,10 +2755,12 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	*result = offset;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 16a7898697..ca0a23ab87 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -487,17 +487,23 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
- * It is unspecified whether the lock will be shared or exclusive.
+ * Control lock must be held in *lock_mode mode, which may be LW_NONE.  Control
+ * lock will be held at exit in at least shared mode.  Resulting control lock
+ * mode is set to *lock_mode.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid,
+						   LWLockMode *lock_mode)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (*lock_mode == LW_NONE)
+	{
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
+		*lock_mode = LW_SHARED;
+	}
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -517,8 +523,13 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
-	LWLockRelease(shared->ControlLock);
-	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+	if (*lock_mode != LW_EXCLUSIVE)
+	{
+		Assert(*lock_mode == LW_NONE);
+		LWLockRelease(shared->ControlLock);
+		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+		*lock_mode = LW_EXCLUSIVE;
+	}
 
 	return SimpleLruReadPage(ctl, pageno, true, xid);
 }
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 0111e867c7..7bb1543189 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -113,6 +113,7 @@ SubTransGetParent(TransactionId xid)
 	int			slotno;
 	TransactionId *ptr;
 	TransactionId parent;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* Can't ask about stuff that might not be around anymore */
 	Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
@@ -123,12 +124,13 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, &lockmode);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
 	parent = *ptr;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SubtransSLRULock);
 
 	return parent;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 8dbcace3f9..8b41957559 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2002,6 +2002,7 @@ asyncQueueReadAllNotifications(void)
 			int			curoffset = QUEUE_POS_OFFSET(pos);
 			int			slotno;
 			int			copysize;
+			LWLockMode	lockmode = LW_NONE;
 
 			/*
 			 * We copy the data from SLRU into a local buffer, so as to avoid
@@ -2010,7 +2011,7 @@ asyncQueueReadAllNotifications(void)
 			 * part of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(NotifyCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, &lockmode);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
@@ -2027,6 +2028,7 @@ asyncQueueReadAllNotifications(void)
 				   NotifyCtl->shared->page_buffer[slotno] + curoffset,
 				   copysize);
 			/* Release lock that we got from SimpleLruReadPage_ReadOnly() */
+			Assert(lockmode != LW_NONE);
 			LWLockRelease(NotifySLRULock);
 
 			/*
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 2fa90cc095..8a7726f11c 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -1068,6 +1068,8 @@ LWLockWakeup(LWLock *lock)
 static void
 LWLockQueueSelf(LWLock *lock, LWLockMode mode)
 {
+	Assert(mode != LW_NONE);
+
 	/*
 	 * If we don't have a PGPROC structure, there's no way to wait. This
 	 * should never occur, since MyProc should only be null during shared
@@ -1828,6 +1830,7 @@ LWLockRelease(LWLock *lock)
 		elog(ERROR, "lock %s is not held", T_NAME(lock));
 
 	mode = held_lwlocks[i].mode;
+	Assert(mode == LW_EXCLUSIVE || mode == LW_SHARED);
 
 	num_held_lwlocks--;
 	for (; i < num_held_lwlocks; i++)
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8a365b400c..a4df90a8ae 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -924,6 +924,7 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	TransactionId tailXid;
 	SerCommitSeqNo val;
 	int			slotno;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(TransactionIdIsValid(xid));
 
@@ -946,8 +947,9 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(SerialSlruCtl,
-										SerialPage(xid), xid);
+										SerialPage(xid), xid, &lockmode);
 	val = SerialValue(slotno, xid);
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SerialSLRULock);
 	return val;
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index b39b43504d..4b66d3b592 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -142,7 +142,7 @@ extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 							  TransactionId xid);
 extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-									   TransactionId xid);
+									   TransactionId xid, LWLockMode *lock_mode);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index af9b41795d..e680c6397a 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -129,6 +129,8 @@ extern PGDLLIMPORT int NamedLWLockTrancheRequests;
 
 typedef enum LWLockMode
 {
+	LW_NONE,					/* Not a lock mode. Indicates that there is no
+								 * lock. */
 	LW_EXCLUSIVE,
 	LW_SHARED,
 	LW_WAIT_UNTIL_FREE			/* A special mode used in PGPROC->lwWaitMode,
-- 
2.24.3 (Apple Git-128)

v6-0004-Add-GUCs-to-tune-MultiXact-SLRUs.patchapplication/octet-stream; name=v6-0004-Add-GUCs-to-tune-MultiXact-SLRUs.patch; x-unix-mode=0644Download
From a5e15ae42bd6c99d39bac7a9988f586c48ceba13 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sat, 9 May 2020 16:42:07 +0500
Subject: [PATCH v6 4/4] Add GUCs to tune MultiXact SLRUs

---
 doc/src/sgml/config.sgml               | 31 ++++++++++++++++++++++++++
 src/backend/access/transam/multixact.c |  8 +++----
 src/backend/utils/init/globals.c       |  2 ++
 src/backend/utils/misc/guc.c           | 22 ++++++++++++++++++
 src/include/access/multixact.h         |  4 ----
 src/include/miscadmin.h                |  2 ++
 6 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index fd4ca29347..d2ca4934de 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1838,6 +1838,37 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-slru-buffers" xreflabel="multixact_offsets_slru_buffers">
+      <term><varname>multixact_offsets_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact offsets. MultiXact offsets
+        are used to store informaion about offsets of multiple row lockers (caused by SELECT FOR UPDATE and others).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-slru-buffers" xreflabel="multixact_members_slru_buffers">
+      <term><varname>multixact_members_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact members. MultiXact members
+        are used to store informaion about XIDs of multiple row lockers. Tipically <varname>multixact_members_slru_buffers</varname>
+        is twice more than <varname>multixact_offsets_slru_buffers</varname>.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 70d977cba3..1c177242c5 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1866,8 +1866,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_slru_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_slru_buffers, 0));
 
 	return size;
 }
@@ -1883,12 +1883,12 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_slru_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_members_slru_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 9ca71933dc..a5ec7bfe88 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -151,3 +151,5 @@ bool		VacuumCostActive = false;
 double		vacuum_cleanup_index_scale_factor;
 
 int         multixact_local_cache_entries = 256;
+int			multixact_offsets_slru_buffers = 8;
+int			multixact_members_slru_buffers = 16;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index d667578cc3..7682c8be1e 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2267,6 +2267,28 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 9a30380901..630ceaea4d 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 01af61c963..ef8abea84d 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -161,6 +161,8 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
 
 extern PGDLLIMPORT int multixact_local_cache_entries;
 
-- 
2.24.3 (Apple Git-128)

v6-0003-Add-conditional-variable-to-wait-for-next-MultXac.patchapplication/octet-stream; name=v6-0003-Add-conditional-variable-to-wait-for-next-MultXac.patch; x-unix-mode=0644Download
From d25e7d68a7979fc391c5d988b256a49cdd916bfb Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 01:55:31 +0300
Subject: [PATCH v6 3/4] Add conditional variable to wait for next MultXact
 offset in corner case

GetMultiXactIdMembers() has a corner case, when the next multixact offset is
not yet set.  In this case GetMultiXactIdMembers() has to sleep till this offset
is set.  Currently the sleeping is implemented in naive way using pg_sleep()
and retry.  This commit implements sleeping with conditional variable, which
provides more efficient way for waiting till the event.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/multixact.c | 35 ++++++++++++++++++++++++--
 src/backend/postmaster/pgstat.c        |  2 ++
 src/include/pgstat.h                   |  1 +
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 57be24c0cc..70d977cba3 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,13 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	/*
+	 * Conditional variable for waiting till the filling of the next multixact
+	 * will be finished.  See GetMultiXactIdMembers() and RecordNewMultiXact()
+	 * for details.
+	 */
+	ConditionVariable nextoffCV;
+
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -892,6 +900,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
 
+	/*
+	 * Let everybody know the offset of this mxid is recorded now.  The
+	 * waiters are waiting for the offset of the mxid next of the target to
+	 * know the number of members of the target mxid, so we don't need to wait
+	 * for members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoffCV);
+
 	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1389,9 +1405,23 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the
+			 * offset. Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoffCV);
+
+			/*
+			 * We don't have to recheck if multixact was filled in during
+			 * ConditionVariablePrepareToSleep(), because we were holding
+			 * MultiXactOffsetSLRULock.
+			 */
 			LWLockRelease(MultiXactOffsetSLRULock);
-			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoffCV,
+								   WAIT_EVENT_WAIT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1873,6 +1903,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoffCV);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 822f0ebc62..b99398a97e 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -4020,6 +4020,8 @@ pgstat_get_wait_ipc(WaitEventIPC w)
 			break;
 		case WAIT_EVENT_XACT_GROUP_UPDATE:
 			event_name = "XactGroupUpdate";
+		case WAIT_EVENT_WAIT_NEXT_MXMEMBERS:
+			event_name = "MultiXactWaitNextMembers";
 			break;
 			/* no default case, so that compiler will warn */
 	}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index a821ff4f15..75ede141ab 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -952,6 +952,7 @@ typedef enum
 	WAIT_EVENT_REPLICATION_SLOT_DROP,
 	WAIT_EVENT_SAFE_SNAPSHOT,
 	WAIT_EVENT_SYNC_REP,
+	WAIT_EVENT_WAIT_NEXT_MXMEMBERS,
 	WAIT_EVENT_XACT_GROUP_UPDATE
 } WaitEventIPC;
 
-- 
2.24.3 (Apple Git-128)

v6-0002-Make-MultiXact-local-cache-size-configurable.patchapplication/octet-stream; name=v6-0002-Make-MultiXact-local-cache-size-configurable.patch; x-unix-mode=0644Download
From d0cd1ce556ad3f4e7bbebf0468dc6e00765d79ae Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 03:44:50 +0300
Subject: [PATCH v6 2/4] Make MultiXact local cache size configurable

---
 doc/src/sgml/config.sgml               | 16 ++++++++++++++++
 src/backend/access/transam/multixact.c |  2 +-
 src/backend/utils/init/globals.c       |  2 ++
 src/backend/utils/misc/guc.c           | 10 ++++++++++
 src/include/miscadmin.h                |  2 ++
 5 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index f043433e31..fd4ca29347 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1823,6 +1823,22 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-multixact-local-cache-entries" xreflabel="multixact_local-cache-entries">
+      <term><varname>multixact_local_cache_entries</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_local_cache_entries</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded
+        by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while
+        lower values make cache lookup faster.
+        It defaults to 256.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index ccbce90f0e..57be24c0cc 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1613,7 +1613,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
 	qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator);
 
 	dlist_push_head(&MXactCache, &entry->node);
-	if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
+	if (MXactCacheMembers++ >= multixact_local_cache_entries)
 	{
 		dlist_node *node;
 		mXactCacheEnt *entry;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 6ab8216839..9ca71933dc 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -149,3 +149,5 @@ int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
 
 double		vacuum_cleanup_index_scale_factor;
+
+int         multixact_local_cache_entries = 256;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index a62d64eaa4..d667578cc3 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2257,6 +2257,16 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM,
+			gettext_noop("Sets the number of cached MultiXact by backend."),
+			NULL
+		},
+		&multixact_local_cache_entries,
+		256, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 72e3352398..01af61c963 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,8 @@ extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
 
+extern PGDLLIMPORT int multixact_local_cache_entries;
+
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
 extern PGDLLIMPORT TimestampTz MyStartTimestamp;
-- 
2.24.3 (Apple Git-128)

#23Alexander Korotkov
aekorotkov@gmail.com
In reply to: Tomas Vondra (#21)
Re: MultiXact\SLRU buffers configuration

Hi, Tomas!

Thank you for your review.

On Wed, Oct 28, 2020 at 4:36 AM Tomas Vondra
<tomas.vondra@2ndquadrant.com> wrote:

I did a quick review on this patch series. A couple comments:

0001
----

This looks quite suspicious to me - SimpleLruReadPage_ReadOnly is
changed to return information about what lock was used, merely to allow
the callers to do an Assert() that the value is not LW_NONE.

Yes, but this is not merely to allow callers to do an Assert().
Sometimes in multixacts it could save us some relocks. So, we can
skip relocking lock to exclusive mode if it's in exclusive already.
Adding Assert() to every caller is probably overkill.

IMO we could achieve exactly the same thing by passing a simple flag
that would say 'make sure we got a lock' or something like that. In
fact, aren't all callers doing the assert? That'd mean we can just do
the check always, without the flag. (I see GetMultiXactIdMembers does
two calls and only checks the second result, but I wonder if that's
intended or omission.)

Having just the flag is exactly what the original version by Andrey
did. But if we have to read two multixact offsets pages or multiple
members page in one GetMultiXactIdMembers()), then it does relocks
from exclusive mode to exclusive mode. I decide that once we decide
to optimize this locks, this situation is nice to evade.

In any case, it'd make the lwlock.c changes unnecessary, I think.

I agree that it would be better to not touch lwlock.c. But I didn't
find a way to evade relocking exclusive mode to exclusive mode without
touching lwlock.c or making code cumbersome in other places.

0002
----

Specifies the number cached MultiXact by backend. Any SLRU lookup ...

should be 'number of cached ...'

Sounds reasonable.

0003
----

* Conditional variable for waiting till the filling of the next multixact
* will be finished. See GetMultiXactIdMembers() and RecordNewMultiXact()
* for details.

Perhaps 'till the next multixact is filled' or 'gets full' would be
better. Not sure.

Sounds reasonable as well.

------
Regards,
Alexander Korotkov

#24Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Alexander Korotkov (#23)
Re: MultiXact\SLRU buffers configuration

On Wed, Oct 28, 2020 at 10:36:39PM +0300, Alexander Korotkov wrote:

Hi, Tomas!

Thank you for your review.

On Wed, Oct 28, 2020 at 4:36 AM Tomas Vondra
<tomas.vondra@2ndquadrant.com> wrote:

I did a quick review on this patch series. A couple comments:

0001
----

This looks quite suspicious to me - SimpleLruReadPage_ReadOnly is
changed to return information about what lock was used, merely to allow
the callers to do an Assert() that the value is not LW_NONE.

Yes, but this is not merely to allow callers to do an Assert().
Sometimes in multixacts it could save us some relocks. So, we can
skip relocking lock to exclusive mode if it's in exclusive already.
Adding Assert() to every caller is probably overkill.

Hmm, OK. That can only happen in GetMultiXactIdMembers, which is the
only place where we do retry, right? Do we actually know this makes any
measurable difference? It seems we're mostly imagining that it might
help, but we don't have any actual proof of that (e.g. a workload which
we might benchmark). Or am I missing something?

For me, the extra conditions make it way harder to reason about the
behavior of the code, and I can't convince myself it's worth it.

IMO we could achieve exactly the same thing by passing a simple flag
that would say 'make sure we got a lock' or something like that. In
fact, aren't all callers doing the assert? That'd mean we can just do
the check always, without the flag. (I see GetMultiXactIdMembers does
two calls and only checks the second result, but I wonder if that's
intended or omission.)

Having just the flag is exactly what the original version by Andrey
did. But if we have to read two multixact offsets pages or multiple
members page in one GetMultiXactIdMembers()), then it does relocks
from exclusive mode to exclusive mode. I decide that once we decide
to optimize this locks, this situation is nice to evade.

In any case, it'd make the lwlock.c changes unnecessary, I think.

I agree that it would be better to not touch lwlock.c. But I didn't
find a way to evade relocking exclusive mode to exclusive mode without
touching lwlock.c or making code cumbersome in other places.

Hmm. OK.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#25Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Andrey Borodin (#22)
Re: MultiXact\SLRU buffers configuration

Hi,

On Wed, Oct 28, 2020 at 12:34:58PM +0500, Andrey Borodin wrote:

Tomas, thanks for looking into this!

28 окт. 2020 г., в 06:36, Tomas Vondra <tomas.vondra@2ndquadrant.com> написал(а):

This thread started with a discussion about making the SLRU sizes
configurable, but this patch version only adds a local cache. Does this
achieve the same goal, or would we still gain something by having GUCs
for the SLRUs?

If we're claiming this improves performance, it'd be good to have some
workload demonstrating that and measurements. I don't see anything like
that in this thread, so it's a bit hand-wavy. Can someone share details
of such workload (even synthetic one) and some basic measurements?

All patches in this thread aim at the same goal: improve performance in presence of MultiXact locks contention.
I could not build synthetical reproduction of the problem, however I did some MultiXact stressing here [0]. It's a clumsy test program, because it still is not clear to me which parameters of workload trigger MultiXact locks contention. In generic case I was encountering other locks like *GenLock: XidGenLock, MultixactGenLock etc. Yet our production system encounters this problem approximately once in a month through this year.

Test program locks for share different set of tuples in presence of concurrent full scans.
To produce a set of locks we choose one of 14 bits. If a row number has this bit set to 0 we add lock it.
I've been measuring time to lock all rows 3 time for each of 14 bits, observing total time to set all locks.
During the test I was observing locks in pg_stat_activity, if they did not contain enough MultiXact locks I was tuning parameters further (number of concurrent clients, number of bits, select queries etc).

Why is it so complicated? It seems that other reproductions of a problem were encountering other locks.

It's not my intention to be mean or anything like that, but to me this
means we don't really understand the problem we're trying to solve. Had
we understood it, we should be able to construct a workload reproducing
the issue ...

I understand what the individual patches are doing, and maybe those
changes are desirable in general. But without any benchmarks from a
plausible workload I find it hard to convince myself that:

(a) it actually will help with the issue you're observing on production

and

(b) it's actually worth the extra complexity (e.g. the lwlock changes)

I'm willing to invest some of my time into reviewing/testing this, but I
think we badly need better insight into the issue, so that we can build
a workload reproducing it. Perhaps collecting some perf profiles and a
sample of the queries might help, but I assume you already tried that.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#26Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Tomas Vondra (#25)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

29 окт. 2020 г., в 04:32, Tomas Vondra <tomas.vondra@2ndquadrant.com> написал(а):

It's not my intention to be mean or anything like that, but to me this
means we don't really understand the problem we're trying to solve. Had
we understood it, we should be able to construct a workload reproducing
the issue ...

I understand what the individual patches are doing, and maybe those
changes are desirable in general. But without any benchmarks from a
plausible workload I find it hard to convince myself that:

(a) it actually will help with the issue you're observing on production

and
(b) it's actually worth the extra complexity (e.g. the lwlock changes)

I'm willing to invest some of my time into reviewing/testing this, but I
think we badly need better insight into the issue, so that we can build
a workload reproducing it. Perhaps collecting some perf profiles and a
sample of the queries might help, but I assume you already tried that.

Thanks, Tomas! This totally makes sense.

Indeed, collecting queries did not help yet. We have loadtest environment equivalent to production (but with 10x less shards), copy of production workload queries. But the problem does not manifest there.
Why do I think the problem is in MultiXacts?
Here is a chart with number of wait events on each host

During the problem MultiXactOffsetControlLock and SLRURead dominate all other lock types. After primary switchover to another node SLRURead continued for a bit there, then disappeared.
Backtraces on standbys during the problem show that most of backends are sleeping in pg_sleep(1000L) and are not included into wait stats on these charts.

Currently I'm considering writing test that directly calls MultiXactIdExpand(), MultiXactIdCreate(), and GetMultiXactIdMembers() from an extension. How do you think, would benchmarks in such tests be meaningful?

Thanks!

Best regards, Andrey Borodin.

Attachments:

Графика-1.pngimage/png; name="=?utf-8?B?0JPRgNCw0YTQuNC60LAtMS5wbmc=?="Download
�PNG


IHDR��Qm��sRGB���DeXIfMM*�i�����L�c��iTXtXML:com.adobe.xmp<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.4.0">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:exif="http://ns.adobe.com/exif/1.0/">
         <exif:ColorSpace>1</exif:ColorSpace>
         <exif:PixelXDimension>1440</exif:PixelXDimension>
         <exif:PixelYDimension>1477</exif:PixelYDimension>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>
�:�z@IDATx���e�U'�:��$��4��d����e����`09-,L�����Nk�x�&.6&�d��-K��if49vN�����^�y�R���4�����n��sN�_�:U7������\��j������j������j�����T*3�S�=����p���7]
t5��@W]
t5��@W]
t5�+��s�3`tOW]
t5���r
LO�GGKss�|��&��+�U*��J50P��m�8�����*9��#���������-�h�Y7������j`m4��k��.����z4P*U&'K��%P�)��������P�

U
M�
��eQ.�z�+����-�b*����
~o�^���^���!o����BXSM@�CC���U`c!������j���@@_���e����V]�6�
"7�)vJ�>���#����:�o���C�.]��������V9�����l�)��j���-��.��R��������D 2���j
�������t���j���-����~��bl�t���+����'fx������~X	=wn�r��I�\��m��[�<�%we���+g��^sM��`���Z������</<\�8����7�T������]=���Fh�8WT2�;�$�Z}�������w��pC��p5_����?vl�����y��W��>>>�Ry����`�)��K%����k�wj�|����==�`�E�b�c�:�a��&'����������gO���D!�Z�z�����m��!�C���X���r���=��Z�n����h��r���U��v����Xy������	�+�3g��
G�_�{��@W]
\�(��e/���k/��������_��{��l���������=��#m�]�����^������������R0x|��c������U�\�K���$����/�����m���pFF�d��q��������������#{�;���_�3r[�M4Ky��������,��H��?����>v�P���?���W���������w�/������w�5C�!�x��_��#�������������C�!��~�g�B�������O���_����Q�Di�?�c�W~��m�
���x��n�a�ND[�8Z�=�L���'�!?�������O�v��dA�G�y�;���P�
(,������k�B�����m����x����}ue�d�6��K��B����%�����f�A�m��5��������������?���}�}���Y�a����Q�u��'�����OL���c83`������_��G��OO�c�����x�N���'���z�}������~�������h���������D[u��t�������T��^�F�3���b�y~zXx��k_w]����?���\��Y�!�'�:�������Gu�������	D�������]�� �7k�G��Q� ��W��
C�������P��N�NyvD��=�+Lv����Ln������F�
��>:c\���9}�
����:sf~�����V�"K"�k��I��'���r;wQ���o0���/��&r0�1��o������|�2���"��o�J�=�,�"�������B���Ik��0�p���
�b�[n��8p�u����_������m��W�2��IZ��7$���T�&��/C�pc!�����D��A�������?�c}��G�\�y)n��o���������NL������v<F��~x��l���}�e�n��{����:}:xj��
������l����;p~�<;q�x��"���L@B���OL���3�x�������'�������'_�������O�������
��w~���x���k�f�2}��w��=qN�xKg5�D��W�����
������?��EI��\	.�*��|�"������K�#	�����������r��#�ed���L!*w=��S3[R�������K�V�w�B����P�YmY�{�e����������>���c3:��/������q��j������aeD(�$������������������9��Hd	Uo��v�%>��]|*}�������]�{����C�&&"z`t��\#�R�J
�K�U���[d43#�P��B�J�c_$R�z��T�@������"�*�������:jH^jI}/�i ��&����KE]�>rd�����{�s���x���5��~V+���?<�h~��nU���O�(�o���2��tN�]
t5�u5`�����
i�;$��ow���mY����s�=����n�������,����k��@o�~�9�*>���������_.�����{��k^s����4^~������?
�y�W��o��m��b���t�F���n�--��O����_9��������������y��$�1�@x����j�r�7���y�.Y���~����W?��7��_��?���!����<����2����2j>�9;~��nL��������x�k��
�
�����~��_c���_?�/�r�|�����������Q>�������zh������������}���������4���/y��o~���>rd�E/��%_��u�;z�}����~��������u�hR6������\bd��#S������iO�`�_�����~>�3`}�k�A$&'�x�����fX�_��!Z���o>����+����)"4�=���/y�~c�k_{��/?x���&3?�s�����rK����'&@����]�����G������x�������������~���eL}����I����-{����w~���d1��Ko|�I�C�7}�u_��{������+����k�;�s?�
��m�T!f]��n@�D��?>s�]����G9fj��/����>��w_L��&����j��>5I{���o�1X7�~`�d�������������0������3*����}������(c�/���L�����p,����>o'����������9���������7�q�9���B����\�����}_���9~X4`!��)<�	C���m=���'���Hk�
�i�}�M&$��g���Z���;��Z����7�����3Nr���?�7�� ��}����d���,��EIw~�w\+�����0AR{_���_�e��s��o�������_����������:��ON���N���W����=����B�����q����������*�7s��o=���k��'?9������#S����_�����C
LVX�����9;R��SL���|p
��E[���bR��w}��~�������*G0�����������?�������Z�2�0����F3j���*P���H�:e��~��Z"s�m��Y���TP��"��a�p%����?O4�'=iX|��4	�Q���wk��
dD��@�R�:�O58th�����G���>���ah�d47�Z�JUz9v�t5����������?~dd$�Sd�t���Ww����{�N}����<4`�J@�F�	Ox���*;w������}�`t�������,`��)�}��m"������E8��������d�Y�����7��������������26��1;q���0~�W��p�����A��+^�0�O2:�s�pF;C�����3����<�i����!W�-��_����>�{��x��M�tm6za�
 [���N��������_�u���+&���~]����B���l��L�k�|�m�O���U���y�YB�+�5���{�3�	�������^u��2������y�[�u����<5�BuD7�����������	�!r�3Z@��)E��u�y�k9���������r��'�^���
*P����7.r�18��(J�q�~��/q����&���~�w�#�8���?���;��p!`2�T��{�g?;_V��K
�����/���v�������M'^�����,��
����T
o{��)n&�S����p��7�����2g���&{�K�K��d��_8HF�0Ux���a�Bj����xc��������]�:oq�����3�|��J�I����V�|�v���d�x�V���3�_?��W���S`x�T��d�H9����h��)w9'�;���2�2�~{oB�����i��M���+�r��>��E{��R���go��j@�xWS;�����;�����|��{�{I=W�fk����^(���~x�}��Dd��?������'��������:I���|�����t|��n�M���.=�1C��%�����FZ�5>�,�(��-�;7��3?s���7�����_�����p�L-##�o}�A�^�-��p��3:6c���������77���7|��Jn��~��o�\�u��������kR�����/�ej���r���J?��7�mk#�1(-]&]����e3��rV3���m���z�E~�g����@����?=u����O[Mz���z��Z��W����"U�����S����8���r��y�[����A��X��M����"V�����<*��~kh����C�z�U����6����o.�6z�����f�.�Tm.�]��q�cA��	�:�On�m�����)=�7j��V����"��D/��7�P����m�K#�^]
t5��@��z����!�k��,~�aP����A[p6�����O�8�w�����y��n`h����?.�@�W�.�Y��'Y?�A�����+����^�^A�Zm��'=	P~����qy� ��c�������8��i�us�0��Nf�0���:nc0�h4}�wG�b/s�~\���h�4l����d����>�$���r����0�����o|�c8�:���)_�����=�y�0�)}f��`���a�P
�AZ,.V{��`,@���>�%���-t�d�B���-��~�� 5 �0�u_����b�e��h�F��x�~344u�s��9����[�=�Lb������x����
�L� ���_��F����8p!�[���������>����n��`!f�S`/�0�%������+;WU���h�
��PF����^��a�6�Zueg�DM<�!
�&������@��~��M�R(J�?��f��F�p���v��<�)C�1x����=m��
,��/����b�<Ka��vFM����5����f	30sbQE����W������\/�.���6��{$5����!U�w���3�T�km�D���
y�9���\{��G�5~����rC�&��*_5J���A�� �����M�X���z�v>�ru[�9th"����Gg1S1����U�S�D{��v>�)�#:f�$B���z�^.�T]MkM\U	���K_zfL,	�����_��{�swq%�(8'�}�m�R��e]��C���?��y|hY����,�&{����?>�k���^=��;�G7��=��;�]3��L�����O|b�_�Q��RG2%�D�^Q>�[��o/X���q���p�S�'uJ�W�r��$�YT%j���{LZ��jjk����|�gn����4b���(�'<a��>k�~C�Q
$�Z��w��~R��F��
GK�6��m&�&�::�2f����{�m\�,��HjW�:�������������h���n��F!�>�h������6�p��k!`��O}�S�|A�3g�@��}�c���ae!���2
"��"�������h�Z�H��Dd������,�	�6��t�o�Y0������h�3ZH�m�O����3Y���.>oh�_����H}TR��/k��G���8�����~������,��`h��������P��a���������+x�e/�	���+��6v~��\\����]9'�Bp���E�2��LN����.�����Q�'�f`�";�Fq�E�W��N�dL\I����i<��2`�d����=�������}�uf�D�e�aI���;�t����@�K�0%3�;B���$�te7�!V�U�0������X�7
}Y�A7N�B0(2U�YJ�](�@�rb<V����4�����`^�"N�ht�O���`���%��~�����Y���������-w&m��lU$���M����x����f��g���So����
��!������3�Y�0��x"\��A����8��b�����?YC�vn)A�(�Tf�+!���jS��������`B�d�'.�@=�3��� ����@��0��?^2������/%�ccR�����Y8"���E�%
��/�#W4�����//�5sc�'25U#�plhS���&Y���@lv�{� �����iu���-��J�����X�{D�S?�17���� ��U~;�����@�P&�S�f}x3��}NLp�t���o����U�Eo<jL�	[�@�Hj�"r��X"M_���oS��7$h��M��JPs����`(�2I�M�@3+)�4��hJ�_q����!#�����cE*�fg�Qa���c�5j�V����G�E����d:���������`@�������E'
����||�c���f�
��� ����b`�hv����l�a_p�hP��800 S�Aj�����_����^%�<��hfdEh��h]�1�V�����Le/{�!�I�B������:���s�-�l����h�����_��Gz(� Fd@������_1�����`:���:h��L�E��uI����I�H�^���e�f��D?}����je�zqB��'����k�vc��Ye�vD
<e�b�FJ`��/
���!������B�+�%��F)&F�`#P�d>�uYtb���b7�i���d|�������/��Ax�[�gi�N�j��i�-�~��������n2���@y�p�e���x0�X�;���k��4���O�������N��zw���b�-WT�h#�����M	�(�*�����$�����-�Yaw4'ak���/����K~���P���Q�����d�O�"3�����K4�l7�������gg���P�/���b26�5��������
K9�����_yMY�|��l�mF�[�0���<%(#����oF����|�6�;�5��j��ddwWE����b��es��7�>�&*�k_{�qb#-	k�U�q�������X����^mwC�������Z��p��$���(�H�7� <����2"��:~��o43��,&���o�S���~��6}�p�|-B�KvA��*������ca$:��::U�"CCAaJ���!�����Q=�f��:�j��OP��59�|��g
<�9���t%,���4�s�C�T��i����V���T�b���+�����E��eP���`��_�&��>�ch�V[OT6������(���I���:Rvq�u!�{�mb�E��N^aj�m3��	��m�oz�I����G^���e�����@W[X������9r����l�`1��}���S7�|3t�044��Bdn�) f6�e�q�{\r����k%��G?�`r�e�Y7+;���4���,�F8�4�!G���
Ox]F)���h��`�{�+�~����e��t��p*����?7�E��p������m]d����}������r �eq�n2Q������� �~�S)�#�r1xd
��_
;��o�5�Hms�����9���W��J�������[t
6F�����>��@��4/g*,@�y��Jr����<�*����A���������gP��7��3,�����^��#/y��
���+��y�1�L����3ct���O�w�0
k��N�V;�I����\o���.G�����x���G>r	���h &�c��7�K-S,����������C?���s,f�gz��
C�}������_��6�������D��W�(\�
Zy9�����vp"�8o�k�D�����k����������(�WhK<;Y�����������*��<��Wu�P���P�����:6����{�������D��<�2��W���{h��6�����H<8IJ?t�����7~��RXa����/������kf��7<j�j*�J���.UUR�������\3�.���>�X.&C�����arr���?YP~R��#������Bi���*����8���i�+�
��|���`va����~�SF�~���<�i�� �@�������C�=r�b����>l�"xQ]���	�q�x�k�@��7����Yr�e
�Z��~:Q��g������S�:��v�N���m�0��?��qG��mB�o�u�C}�;����:��B��7��y�����d��H������7k��Ej�����Bu�R�*���{�nz�"4$�P�>ZUil�)��V�D�\O�����,	Z���&,#��A��\���v�z\���^7�T���#\�[b�����,�Y�b�4_��0E���-o�M�,�$�X�,��=�����6��Z���]
t5��V�Oy�S����/P�+p��L���[n��2X�B�pgakDk!Y�$O{��2'�������P��?����g��'wjt<��7<-��l��$&�~��m�g�bM9s&�W�[��G���d�k�K�3w�@�X_eF�+��@~F0������3���y�y�G�G3�����w�X��:��$���D���m��90��f��={��l���r���q[j��J*r����3L�2������QA��Lf�R�G����}�\�"(��}��^8)�Jm����H3��C�yL���^��S������m����a�q�����N��p�!�0WW`�OwC��f:��e�K�d�u[P�< ��,~,�'����a��G����
{?{��
��h��L��Lf<��x��l���D�+��q"/;����*<���FA��fP����8�&�c��V�� !����zA+����X��-��� -��cf>/z�5�\c�B��T�� $���r�K�=
�'���!�Hd0=��|p�$��f��Uu��q���G�Q����O4����bF����j)*�������f�
�N>�Y�D��������*�8����`kT�,����5�C,#|��3=N�Qs�&��j�������+�F���>v��\��p�z���UU?6�*q:WU�z�����>�c&����@1#_������B��r�|����J��I��x6e8���#��&Y�U�$
����$�DB��d��mJ���di�n�:��T�naU���U!���n���y\��8�v���im.|���u	���Vo��,�B���Rkzy�������)�����G���S1��&�	`���J%����F����Q�<������?�59��A���K��Z�������ff��B�8���=�+GNV���)� �	�Q�K�������j�
�w�b!�V�
`Km�N��Wt~��K�R�END�9����b�e��Y�9rd��h��'�4>�P[H@:��x�Y����!��~�A��z�s6�$����V�V�/�����O���F�Ph�e6-f�����@�V���[}v����kf��k��a5���@x��0�(�$7>���Y��n`��T�&p��]��+��$/�8hBQRTxq���^�8x��	�4�W������`����XEy���9z�-�i�5
���t<K�����,��jX����eK
�?�s�j+#(�����#t<���C�>ac���`I�����F�����l����d3���z��&S�64���w--�jr��7%e���ib���mzm?����4s$x4M'D0Q�����"�����.���`�r�;2��-��+F�S�Q��1�0���4vhf���K����]
t5�������c
l����`}�B��O,+1��S?
��z���{^��%=8��VZg\��#�
ef9��0����8������jl�p.�^����$YB8�^����
��Whr�u� L_Ks���K_�!���E#��!�����Wa\����������5n�L"�����t�l^���I��	h,I*��7;h{���[��'���b���������c����=�W������
����RwH����i6B8D/�|G���6�[�"g��t�v(*[����r������u�<R5�.�om4�����o)�l�6r��������4���2�\+iK�S<\l�~��z�������/\�	�A���V|��`T���ZcUd����_�=�)���|E�������jG��t������Z��x�b����sB,t�PXn\�}��"�ZU��}�w����n^p�w^.��e\k�P��K�����/�h�*�����`S�8�����I��m�W�,��+��vX[/[��H���S���2�,�����6�Z��Qp�2�H�(w�`:f������,��<��N��<��&����$�6&Z�%���d��i�n���� �9��N�N�i��
\k�W�������g�k=�]��4�M�l
qh����Y�M/����:-�7���H+{���������7���U)�8��A��u�K��V|i�
e��Si�Vi�K"l��d�#���U�I�B��6�U�k�� �^���Mm�
��&���En^�SA-�6�j�������.�!��+t�mh�4�;5U�7�;��Z#W�;T�%�f|�WG�V�3l��m�
oEj���Y��9�����x-�S_-�-�U6F"��M�i��Mn��U��jr�,����fk�Y�=������9#�
;��[@I���u�
obH0$;��^(H��U�j������Q������yN�b��y��z{��G�u����am��+�h�t����z��s���M�)���B�T����z��M_�i �D�z}@p�KK-�3+}�0���3�4��r0���,�pc/�6��U�]�<xp	n8��T:��7pm�VW��<��O^-jNG���o��XE,,�ZmU�y"�v�����`hWZIq#�U�s �"���h*�a`��0����E��������X����V1���S3M	�pV1�zR�\����9m�Q�2�:C��D����=�����F|N�XK�{�t�K���U�M��T������c�i�g��k����K����M}����T%�m�dk5�Po��n�����
�9r��[nY��z-%�|`E�gk�CU�r�i�
]<74E��E
��`$�5y�g�Lv�U)
>A�U���D��(�nm8'�����������2�`���_"����u���\��(�BXmG��!K��z|��|��nI�����/I�#l����t*�*�ez�4�nqR��k���-
p���e�sU3#��G��@�&�F`e���/�6H~��a���F3NC�>���5mC��U������\����+�]�R�r�;�J�M/����'p9W��h�bW�^?��)��v+"�_:�8Y�p�l���8�h	Z
_!�u�
���%��
\KF�Z"h;[��A��8��w��
�i�0�*�/"���,��"D��������a+�wX�w��p�|5��^������i��WN
���F�������,:V!�?U�����]��6�[�>}�t��4~Vp��/���|�=|��6<�?�n��o��N�3��w��W�g9~���w�������!��he��oW�����C@q�u7I��%\��
�1�9�I�M�O���O�d��������1�2:�6��Vtj�o�-R���p	}I�����g�th')���s�t.��8���T��\���,<cX�,�5p���F:M����I���~����$�dz^?i���iJ��.�� x�5�:�U�����i$��h�4�l<��+\
��u�)����)<����,��Y��%)~:���De�n�����w��S�~m�.�Z~��wN����p7�/S��o^G�M��8O��B���Dve�Z���H�6\vPr���%�u����P��D�c�p5� u��S�������bb$n.���pfZ�PJ�M�K�H�f����Sg*&8���������8�,��~�Y������3u��������7�N�R�)~��������:=~���w~:�������>7ql[������y�z��W�����P��:DS
\J�#	�Q�p7������4��9��r���'w��p!����%����(2zH��<<�k���OMj_��7��W�������t����,�p���@���O����k��;y�HJ���T�V.wF"�����p��QH��8��"�e���!!�$~"�pR-��Cu����U��E��[�.���UH��K�������'�KLP��W�K�����=v�f�i)��a8~0 ������h��~m�$�e|v�I�����J��s8V1�����#<����p�����/�(\A`�r�S�Z�,���I�����l"4�������;���w����Z ae���D�$���+SJi�kU�	]�"kD��V����^g���������u�Si�+�?Y����S@i��
�V.���^*��VN��=t0�Y�B�tv�����i8n�������sg��=|K�3�0����G�?r��	;r�m���w�r�����-��7Gmx��+�W��o��MEY{����p�+<+�$H���Z�6��*<�E����<�:�*��D�<��w�C������"����rYq�utj���a��v��J��75RLv8���*�N�/��:�'����,=��rQF�zN��ao�rL����S�*�&7���3��Fy79�Y�$>��D��r�7+Ge�������lk>��E�?����%��R����
F���_����>q�ekx�G��������9�{��}i��t4��1a�K�GO��L��9��}��z�Kh-?�P�T9~�t����%l��������\x��������3���/�������r���8q�V��W���Q:�0�������N�7��Y,����?:[������\8���7H��BA
�����<��M�iK�W���j|*���`�=�z�0��C�x��B_�^���V�a�5����fg���c.�v�d�@o<,0e�b�����R[��Q��U}��������ss���Vd�����v.7=_���_����������g������wW�����s����V���z��7S?^�g�r�@���[q�I8�\���;��2:��h��z��	�W���}%
\��z�Z��n���=z�����Vp���S�U��lo�$�asb�����%C�k+�b��V<� �h���?U�_�x������i2q0_���r�;�J�J._����#�>��\��9N.V�],�����7�M]���4B]�Ln�\��X�t]�&yT:z6B�?T��c�����
sT�}��B�8[	;F��s#��m!������0.��{��HH���2�h8:7��**�6�����tm_�&������e������>��T��kL'�,[F�$������8�N�hSn_������A-Uf���D��W�aP�[�-�g�}��)����#�n����K����������V��5����+���OU��7��R.$Z�hE������W��X���/"���j��wM���
5�����k������s[O}�n^���9������,�������ru��F��z�][f}@�'����a>+��kkn�o����`i��a�	b"���mWmg ��������>���<R�F���S�r��\����Y]����*����o��K$n��s����spU=���X^���]��7�k��k���!��N��u�!�:�~�cl�-��n[U���*}7-@;��*��)�F���Wc�u4���_�>�*��\�(����#�t��@D��n
��G�����_*Sq��i�Y��_v2C�WM����v�k
���$jB�Y��-��g�e��0�cYpbr��+��Hu��r�*�X�������$�j�i�F/����'�rW���N��.�V���ks�7�I�wn�������[�t��8����H�5�j��d��7+����y���O�x4��
|�����Jkn�}6�qm%h��%'���������`�
N�����U���u�;��X�Lv�|���S�h���8Z�������5^�s���|���.��-"��!X����}�p}��&`����7m)�������5mw������
���f:_B�#�5�5��l6^x���a�@���'i��+��}d���1z�NZ:��u��;��<����5�����7pe�W���D���g\�Rd�k>{�����
��J��i�t��$f+���1o�i����&�e�4��x(��E ��-UG�������F�	��tbs��<^9w��pW
���;Co���M"7	j �8��I&�1.c����:�3�v�|��p���t��p���������%l����3��:��t�xc�!��P��UJ��$V�m"L{I�kD���}='5��4W�3%���O���L&[,��D�����O�8������,�WwDhsDR4?��O��5}�����@��������!ss��%� Y��2
q\[�Z/fep�f��
���\1����,@�\2.Q��zm�Q:u��
>_���x!�[���s	.�TX����N 9V��R~�?7�Y,0�V����[���i<���)099h;�;�o��>_zx>7���M�w8U�p�|�v���a�����)���T�e�����������qRRzX����C�#�]"�,/
��:i&�2���'B�.�xU>�7*���������T9��Hl����Z���c0m���:�U��7 N]��z.�F�������u�qM3R���)te�Y�%w�]8�����-rg+�:�R!�)�\���N6��/�8Py����!�@-�������#�����e�K09	��
@�)�a��{��Fd`E�����7��;�o�|�D��;
����XC�zl�y6��|��	���G�L��S���U5g�N�����R���D�J
�m�L��=�[�;������������g�2�O������H{���z{K�%�`jZ��_Y;�bs��uA��kA��T
�W�����0�,'����m�J�3�����qX����������b��$�����I�ho������h[�{�j���:�����=z3��
|�7��<���fV}��i�I3grU�2][�cX�hE���e��i���e�3�n�|TmS��,�����}�Z����+�g���`kF�'6jL��q�����-z/������fsSN �S���B@yQ����$�p����[���R�j�eB��h�(��{��$���@�=�
��g�8����K�C��r���Y�/M\�[��ReFM�@3F�}9�;<#hK���Q�����m�U�`s����
�����6���k���m���"�D6L9�#��1��
����8�s��4�
�=z���z������zl�5A*av������z���2��v�����Le�x���v��b����������h�I'��T>�����8Q��)�k�Kd��v��`��������
��(��&P��"\����m^�/>�b���9���E�r6?�����[+Kv���T�,B�a����F���}�4)"�&ZJ��L�=e��qY�7�W��;�j��<�Dt���
�m�����V�����k�?�;�L7�BK��|�uM�����k4�3���m��c�\m:��W�8R���sk��yg�]���\\��r�M�8��%����:��z�Q\[f}@I%�YWd���y����r�<W�e\l[�����>�c���K���Ya&�m�N=�f�Kc�7�6��yp��)�����C��F�D�����X8~$�s$�g�0�pM\/�6���[3���
���h��ur4r����Mq�|n�B�U�,�n`j!@���%%�!�2��N�U-�Ln�P�;�$��tzz�=e������J5+���C�/t��%�7�w������[PL6S��R�=�=�Ra+x@��-�����Y���.}jG���\��'t,���.2U��M�
V��f �7pmNV���{��hr��,y<Wc�����kb��{�Z(vin��XGk�Q�\�����E�$~ �>]@IDATNu�NC/��x:D�$���V��sg���x�\�pqjf|:?:�����%�%����J���@�#G
�^�s�|Q�m�ko,>��0����m�?��t�/�Y�oJ�D���t'�@s��U
���
@7���R��������v���)#�t3�;�f)ps���"��C�U=��-}�L�P�����{��)�3s�ng�ND(�-�����@��v`��NkR����P��b�r��[]1k�j���:}����^rjz�
..WoM�x�����T.Z����2Y�Ts����9���{��qG������.��9����>���[i'q\[��,s��&�����Cv�hm����1�����������R���@��_�j����!t���l4����<7���I�����\V�3C�a.����R@=6���=���"��zJ/��V=�%Iv����X��l���h &�Vv��d+3j�!r�������g
�6Rn�w�q��?�=����O���HC���Hf{
#;���CV���6���������.�8���	�Q�vq��[12�
�F�o/mg��5+���T�mB(������o6��f�s�y��MM��+g�+{kE��K���~u-eCD���!j�0��9�*j��u���(�/��Qp����&��rY�P:m%
7Z��0no���1��>">��)�.���ROe`�r	����u�:|$����\i���J�$���D*"�h�ni��L�(!K�	 b0�����13��g5Z*��%��2+7�`�s���a#�u�S��9k���������_�^�{��Vg�K�c:���Qmd���pCZ4Y3�g����\��I#Y!�D��^��2��[O����5�U��U��,�����G����1�&	�v��KjQ)x����z$ #O�ZYD+TB9�����1�������+�Ko�T_}�Y�gzE�=z=����N/w���ph��s��[��_�����^��s���� ��bs��>��:U�����)��
�s����`���gs,y�.&^�O�5�L+���yg��;���V�M��W����������!�*��"�����Q>|_��b�oy�\��hb��*���a�lu4�|��	'F��AF��m�`�.�_�#��j#o�oT���
��QMN�(sopN�/��(��'��w-2�d�c��a�Pq����q6b�b�lZ_��js��>c�M|l��A^�|�����9�������TK'ZA�5������5~�7=:���|���V�Go�jy�Q���aZ�t��^�Z�r��7�s�W���Oi UF���J��,+���-v�m�i�MH��9���\2��1��2:��`��������V��(�}��h��K������/X��r���K#�}s���j�=p�r��e��ie���1�}d�25>�����'���H����W�D0A�7�N"���P������kXF�PO�Jg����_g��+��y��H<���9�L���<UX���m0������1�/��"��}��fd����m��(S4b[$����������g<S�$e�+T.h9FD�Y����������!�T�>:������i���#7-	�t�t���:M�<�A��P�*J��%L�#�����i;�;'����������K��4��'�q��3��s���w������~������!�x�,��� �-T���&E!D�4�+T�r����H���V��-��[�{�,�s����<�U;�*��<G�a�����C=���.\`:t��G3����8���,����8�s����zb������������ #,
_-�X:z���:�+�&Nt�H��Yn�o�}��#=�`��6)�|m�zL^�I���.���Q���k$���C�e�a�6b�Bf�F�K���G"h�J��0�7��kQ����6�p�!��6��eTwB�H��'��G4$��:�V�@�e���1�C,U�;��}eW�54��a_R4W1�h�W�C���>� ���046&�+�-��8���b�)HJ�
��C�i�����U���''����!&�<]�����|�aE�\v��@�\��i�b��D;N������d�������
����v����IKK�\�v���L�	htk<Z���*l�&�h.���l��&���3abe�I�n��s��M�+�H��=zz[�$�stZh`F����9s��i;M�e;v�[�����WK*�
��l����C�-#N*����*�����da����x�	��������)���q��gX��=�-�
i��L!Z�9d"=U���r�d1��l�>i�$�Z/����GO�?�b:;#��x�?7B(>��u�s�Ct|D\��u��"^(	y������B��wD�U�
�����)�o�P/@�H�I|�������N���j��k<��>F��$��^�����F
Gi�����4��"��d�d���������I�`S�3��G������dQ�,�>���){l��gl=���,�Ht"w^���$t��e��
kz���������.����m�a��!|��b�X�y�
��w��D��U��qCg�C�qU�C��-�y	�4�x�F�B4xY:��"%U�U|����(n���K��v���.r�]�IYe#N����y�y�fF��t��
�Y��'����&����l�����H���������t��%c/e�d��%Bc���$���n\[f}���9��1��eVLFJ�Z��� 
T��������d���m=�PO����o�\��3���zs�AD�L����,>A�z{XB������<��F��s���N��'�4�*��a�M:#��0�hU���4��i;��7���4�6b@���	N�;��w�($�bX����9t56)����I��j����C���S�����
7x�;���y�	3xh��Db;�JeDq�q:�{_�����J�|�8eM@|�2�	�l���������8��O���Z�I�X��9��B�VT�����:?�vy�s�������)I�?�����h��Eo����U�Z��YH�h�l�0s�hx0�Y�����L��*��ma��70%��L-�V���+ym` �2.�w�rjq�����[����V���i]��
t[FE��-3P.��G�^�8u�Q�Y$�gq�$�|�]w��>PY�V���gw��^E}�)��d7��u���@�r��T�+�}	9:`��I��<#���K��]��\?���t������\�c������G�Y+��%5�g�������Fgg���(4W�*`�*��!�l��-�{4,�a���s^
�	�(��(�<�n����������)} ���n��tR�eA��H����<o�a`N�V�@'p��/�r�cK���kS�D0N�T��}�9n��r�&r�p���s�t����:p<\��s���S���R���sE����y��C��/L�B~K]�Q������AC&]�����|\qT],%���*�7�e<k�\�em�!���HYv*�F��r�^�<�K�G����:s�r_6�l�Zj���*���w�t�iB����iA���H���k�����a�h!��T���u�=z�4�t��@��VW�������^����;�&e3�&�<����iMD+��n�8��NH9[i'q\[i'��������#�����d�\_A#hOu\��F�h�xQd����`;w���C����,EcZ�._*�����3`������S��k�L�#�x&��p����j�T����#0�e����%��a_�)JB��������]e5�2��&)!%h�
�����n��S��[����o6�lu�/��C����H�!���'��Q��t<��A�D#P�&�"��S�*�
}0��C9�Z�������qf�����SEOn�~\�����EG��8W~��S�-	�K���@X�#Q�0��$�Q6MN��7}��l�6W_�|�Vp�R�IE1��M���M�!�����w��i��\&�p|����.b�:Y����S�����M5=ZQ.�B�>�
����n�@����-tH	K1�����@���� ��9�W���H�:�@3?[	���{N�:eG<�|���������yB�|���(����CV1�U'e��V��4Bo`������^"�3�c������F�����
$
v_�5;��b������y���?;�M��~e�r�x���!�k��s�o|��/F��B����cK}0�����~D��k>_a��u�h Bu�IBF�4z�M�AR��t/����+��pkY3&jn�0��$|�<��/xh2��c�c�,��K�FI�]0
~���*�
[��J-=f�B@�}�;�|�P~O�B�u6�Z��Q���LY��>����X:.��fX�.4���8����be���F���tn\N�������EY�-���l��E���F���dB8h�"�i@5J�]I�x�(�SG�$D�����������U��y�D��5�l������{g�U��B�*g���V3��n��1��Zw1?x�_�E�|���G����Zjb������� �7����{�Ziv5��f�s���AlS�X�8��I&��n���odo�K��s&��w������b�l��5����i��h�_=��q\[���O@�V��tb��e
��a �q��>��b������^(=��p�X�-��lA�b(
o����/d��m��
���X����``�LA�����N��w$18�|@1@a<wz!��aC[���4�[���c� �H��x���n��Y[dK����^E^��z��,Y��h��/�9qCr���3g����9�=w�������F��ogW0�c3�2
���!v_~�!�qM?�l�D�i@�Q��p)�R���y�>�|������Ed���rizf�h�����6	�cp���m;
fr��4l���c^�>�M��������}�05�D
�29X�]��6�P�tT]5\^�md�3��tn�/7�
�����:��UE�XK2�r��,{�&L�����=��n��uq����PS�����zs�Y��NY0�Wg�A��D�����h�D~n[<J�r�=�pp
%���ca&o3CS}^N�vw
q�8i�^��������@�d��>��Q.daL�m��XO���#��q�N8��������L���qZ ��^8�*�)�M
����d�kn�������'X�^���Q���om�
	OS��-?Y8qR8q�v>��,<�[?������!u�1�~�p��i��p��	��|&�)�����1�6Z���J�QDK�K���i�6�������r����;}r���3''&�P�+�=�2�'&��|rd����g{K����/�|��Q��}pvz~v&�Q3>�a���`t����LU.�����>3=��Wv���	/��A�������
�:1�+���o��,��'�G���z��;�����G��=��7�v���2E����������n�iw�sb��S�g�+��<_�������_���������:33��}|�&�c�L@I��������
��(_������gf�����������O��.��Ao��j����T*��O�M])2����������y�k>|�lN����L�bB6���G'&'�G������%�jD'���.����>35�?1=69�������U��M
@S)~�_�wunz*�1��au����Y|M;��n�ef*(gp A������L?n������OH��g��T���
ulnv~j*h/�7�/o�$��� S}���0�G6dQ"��\DJ�b�����0}J��jVi���gfu��L�\��+�D?���i��O��4��j�����{�9������&>1K[�3�U�&'C�k��`(�O��O��		�������������z������������~�$�_���:����gz�G��z)<ES�R�IC�u�
Y�J��y�U����33��o9h��
�T�yh�,*�����s�4K���j��P~vP}@oP���/�Nmf�]��������XoU�����D��r����t���;Z�hu�A�1�No��.<K�������j��	O����b��G������!�p�4��F�4����~k��!�K����|�QG���h��'����
��F��o���p�R�,<��,\���KH�?�m�'��t:��)���-��bR]c�8Y����������W-R��5{�nR�����}�c�26�{�Z�2��7%�����)�������k�i<��n�o���1���U�<������_�<�����c�Pvu�[��h1��|k�G���
w_�0{UwS����*����D���)�Ac�i�P����!�"�5������z�lJ�
#������dm���{�����r�\�$�A�ev������m/��W���Q0��
)�)����'sl�g���'S����R���K��jn�
2��!�H6�vA�d����]��#[a�����FN�9�Z����M�H��q�Z���D�e���Gy�,d[�f�	I�B�L����.���^�Kp��T�%�����y��BS��G����||6g�.����������[������mj��-���x1�������?�_��V�e�?
=f�1��"��5������+f�O�J�$�����E����������Vd`��C���Q��3�]���\���Z��� hc�O��8
!���C�3^A���(��09��Ew9���1q`#F��,R�!�M�H����r��|$}�0[(�DS�a���L�����^�+Q* �C��x[�f"g��P�\j�C�!u^�9�:�J�����-�)9���F�X�]8|u2�)F�������&��P�aGi������p!,�]��D����#3�Y.Y�B�}vS�����u7u�)����MS�)�i�������,f�,�o�QF3��*<#�E���M�E�nR|�������k���YV��Y���|��f���3`�*<%�~��`�ZqR`F!{�n�J�~�����$�������Ux-?���[��b��4q��J��)�/���\y8k?:��.7���={�(?���S�,�,��;�/���N]8Se���p���C��b:���1~b`��uz��!N]8C{��a8�7��T�2>��D^�p5�^��_��������>G��]7�+��v��3�CM4^�f{+}��s���f7���+�����ra����%���Pq�d)O��g+�����!�x���;���6�0f���T������M[�1yXW�������3�4$�r2te�gtG��3��m�g~�P�
]��z;8<���#\Kd�!c�o#�r��_n�P.��z��
��fAI���`q`���~�"�e�X1���g�pnL����\������Pp�X�S��Q)L�s����^.C����b��C�4������Ox�w��5�o� �������\�|&��������},��4dz��S�Y,jv9��������9:9_g�������\����cx�d�OzO�/����=e{%���>�Wv2X:7�w��[���`~�����?S�/���;S��-���}�E�:���?����C}���Dar*\_��#
�7!�\n�r�0�[�n�o}�7���:��bV�����2�����r����T����gr�?���D$��<�s}�������&h�^�b�8[��0�8��.�����d~�.�Tz�8��#���4�#en�wg_n0�����m�B�808�W��P,��Z�W?�x����-�!����h����v|G�g4����������Q-�Z=L�qj������Z���f�����+CS\��{��U��	�Q��������m��}���q��~`N��Br�h��������B�������;840[)M�]��?��5���Jqxx$����+��n����V1�u� F9�g��[��.��PK�O�N�M�L6O�r!���*#���u�w������v�pk��I��[�I?������r���m��ge�*~�n�O(�
�0�d�pNV�M}��n�X5VE3����8��-�ar�_20�S)B�����ULa�ob��df��>�_����abR]�}��}�a���xyi�O{�4O�S�����9f���*+����6�� ��>��j��b�������U����;	g/I��)Z]��`�w�_0�V���{Z��"R���?���O�~�LH�8	����#}`j�8~������
|��)<����a�����A���Q(��+�Y�M��H�.�	��
@$����L	���%���J�x��C(z	��1���V��9����q����u0K�>���&���}�|�l��LWo�������s��\b��3��e*��`^�T�W�?D��0�
�sJu8�����!�@����Lq���Z
�����Z����\��*p����h��;0]�2�����5��_����	���qFu,J�NI�==	�U���"2���H�\������:�AW,�*p� V3[�A��z5�ZZ��J�@������:ho�P��+N�=�2�6�=z
������6��Is�h[�M	�VY}��_�
U��������=�������1z����	@0w���#�;2�x�,%��l��T��#����qD
�������p�G-8t���XA���hP��7��5&O��S8�7���"
���}����F\C�;��iC�������>3��a<��������x�B��GLsi�$
���#��8�����OX�,�� �Z:����U�$��7��NXSv!0������{fr�n:�������x���\�n��$�f_����D{��\�
�;���@-K��r����{q"�������Wu���D��.q��{��J?�+�&��K��O��`��A*��P���s��V����������e�����h�_H�%��{!��o�|zA3����I7���e|�'�V\D�<���~��d�hbJeH���pN9��>u�������'�w�w`>�Od����������O��?�0������������L�^�7�A�$�z�7�'�~�����~�sU�s���W����[�s���w��{�:����W���y�M������`cj4U�D5��Sl�������~�(���K#oOn���x������`�-t$w������M�F��_i��~�oO�v`�1l�.`�q�u\������v�-�y�����S��,�����Gi���d��+��>%i�MPB���FR6��Z]X�(��0�A��r�p��D>YPk`������|��\Z��-�^�X�D�H'�t#$�s
�q.
�������FU���P"}r����b'|�������E�%<��Ib� ������t���?���(>�d�9)}�|�������]�^/B?��Lnl�<5W�U����tat ��OI��_tW���������5������*�'���3�jChTc��D^cL]�s�g�#��$�(|yB���L�L�@���\b���!�T~�nk��{���mO~ ��/7:���?]��[{>{G��,Ym���O�|��C�/+=NM�����<%'���fK�0eQ���$
'F����Q���H�f�w��v��^/M�$N5�x�&�E.u��[D�(�����1�i��q����������6�h�U.+J��D� 14`�h�������h�sG#��D]�l <��*e'^1��[�\���Mz2w�l��fv�B"�}������8����R	����
�����~�zv����dld>XR/�
�
#��q�Xm6��P�Q��Z�4���'n&���������#���)(8��??LLz+!�D�U���=���d�\T�3��BZ0'����}��V����H'�f|��UD�YX��EP
Q��dzNg�a,V���2�D-)�9�HG��-?6���N<���+��������������s��P�'���4�Z�)S�Fr�S&�9zr����gA'�&T�$��xb�iI�J*��
�+s*���"&eH�:���GG�x��*P��&U�)Zb/i�is�#��/�g����3�.,�%�\e�+�I�e�x|��_r�d����	�-��iB�'�����3���c%�Dpp�$qSGQ��������*�i����*f��t�����A�_2[Ec���d��"Bz����u[Vd����-�8�C�-�LCW�)VQV)c������Q��|[5��`�z����Z��4Z>Lh<g�W����bg���x����~j�
��7���pU��I�2r��}f��{����x���F���-�]w�80�^�>H
m	�O�)y]*�m[a�X�L�e:�#�KzYI���U�������xz�r"�:�I�L�����������D��9��3oYs��:@��N��yBx�N��]��xH"��%�����^�W�3�����~���C=���8��W�����,�6���P9��#���u !�d����kS�A~��`���%�������(b7�TeT������g��c����)m�B�Bu�B�qb���ob��"�@O�@g�1w��4(���B�$���;:S>��:�+m�$LZ���g�����6S��+\4u)i,{c�:_�7qS�>��#����� �3g�81)����G�,�h�&�})7j����Ms����m�������tj[�{�N:Cm��XO�FR�4�����U�K?�h�*��`2��t����z��9�hY�j-�J�j�u[i���Q�PB��1�PFV3sB�&�
�e���)FGc04`x�����IqL����=C[��W�����!�'0�X���d�X!��H6�g�V`�[\
��j��$ �����
A��s�.v[PD1��9X���R�k�.��b6�Sq����������2����jbs\.V����������u�6"�9���{�);��
���B8� ����n������D$���5�2M�g�fP
����e;�H[�7A�)����Ob`����X
_:)O�bFp�GCn�G��(D:�g�����@���7�wv�<:X��G�������0��ypBu�'�!HF��e�Y��l��yQ���>�R��i�.�jA�p��������x���H�IBM�&I�U[C����
������U {����'kz3�J�g5�*)�lq���[����:��ii��@��%���q���������|���g!�G5���|,�N�K
D
�!~1��[�e�cA�:3���,�$���IL��E�4���1h�I�3^���$���v�r�:�������R����|kO��g�������g���$��}?�9Tf� U��VUi:Sw����k����w/���������^�����O�tkh
%�J��r������d����tB�H666@�����B��B���v��K���:L�/��
�L�e����}���&c0����^
�I�%�%����RF�B����T!f���S�1�eT�)�%�ya��XT@������a��#�C��B0�U;;���<�8�����`�8yI]\����T��k��d'�����U
6��C�������q(q���h��P�}��!��3h�5Q��)�O�Bp�-�u��������a�D�%C�p�����u�
�i[� ug�.��c���u��[6�����&���0@�7����&[1t�NJ��pc��2�h��l��d~��"����d�i)�;��IGb���K�R\+�%\Q�/��p������	��DgR!#����9�t�w(2����d��"b������*P��h"�L�
��]JS�Y�P�����OyZ�c�/0���x<���^�|��8]~��9-x�Kd)��xI����Hk^|�@�4�p��*����_$_�Yv�#�_�e�p��xq.����|����8�U��F7��KS��@u������p���P��.V��-�F����0j���DH3�q�v���um�Nm2�������w�A����(�i7��9N��~���qr�����\�/�v$���=�P%�!f]�ea\��q��h
�����F>��d
�������������j�= -r	@����b�z/x����1�
}���=��I��t���O�����-|'�H����eJ��@�K�d�;XVd��(���z��j��p�44
������8����TF����p��@���f��Kz.�9&:m/����t���c�!�-L��������\]��x0n%��7"
������b��5)�Is�5\z[Y���!�Y0&i�B�w%�tb�y��i.Q�m��&���c�r,�}Dm��PG'e�e]H<��)�(���t�\JGJ�q��u�����w�P�k���%}�6u��?�X-����n�]����j��XU�����������&6�n���
��g�
��''����?��C����2�>n�/n�F�_�Ut>��u�65~���U�B7c$�4�A\Tg-�&K��'�n�s��k�d$pn<,� �3��� >��N�c�_Th�^��p���o���
��Y�;��a��dA����Y����(A��yq�KSt��A6��7�
A4Jj��>�E�7�b��Y��5�>��O%�T�WsAc�"��@��}�;N�1@J�DZ=������t3�q���d@���'8���^o���8��MW�`�������@��Q�9N�� FU�H�������J���
��&4b�!��'���W6����
��^�����wT�#&6:�%�=��3(6+O]����R
��2S���
����q�������V*[g��6o,slX+8�L�@U�G�f��������I�y���o&����,��m��o�i��e�>�������I[!��e
D�2�	/�Y��4pv �>R��Y^�H$Iv^=9���X��I������Z���^"���#r+�z��$-
����-�#1�:0�2��~�V]�*������(n�4i����n��4�Z����U��&�,\��n���_�/2�d�����R�1�
��������}�l�e!���(��L���g��n�(]�S?�t�4�!#��FD`��0~���` ��<M�E
�`����H����Lz"
X'#��S�n�?�&�����*��A�:*������_�(\��~MhX����]��Q����V������B}Hd�]5s8�B7t-��n��5"��Qu�^?h����-U}�j��%�R���[*�'��[��w�/�������c��,��s�.u_n`T�kmy�Iq �`���R��C���n�����l�D�jASK�t�5*R���=��6h>�mL�W�_������m�����M�����#-rr0��B��Qk�?�a.���>I����0�sl���+�)�����
B���(G(}7�u���r����`�J-��b�����*FZ�q����4���y��<'�X���{��
�}��i[K��F���y������v��$5:�p����P1W~���e��}~�n*�Q�2���:��d�,���|R�
T��H��.�^��H(���)����������I"
�Y�: X-��E������}�����s�
Vt�Gr%&;o���O��W��+�����pb�����P�]�
6&�A������mA��u-|�"�������N���S`���8)�a���� �Bq����	�Z(�&�J/X�8C`y#���#���:��������:�/������"�����|is���_�y����l8BY[�������;������%�`n�j`J���b!n�!��45|��|���L���7���@������+�xi��2���wj�6�y�������wC����''����mW*��B������m�������r-&�U�#^�I���$�����MsA��l��/�4��s�G��v���{'c|A�w�"+�%���XY.�����'�"Cm��'=����Y����a�KU�Q3���)�&:~"�����_�K�fYW����*��,�W~��%�����"��G�mj��+��yE�3�8�,5+�Nm��L�$ Z��xG�<�P�1��:�(����c(5(�@^(e��k��O?+�t
��8��Q�dp��h���E[�/�U������i&$�RG�"��c��H6 ��������~��Ph�%���$/���D�i#f�,������#����8W�PO�/��a�%���k[�I�95-�`�s'�������D�-�(n!�6z�����-}�#����3�ne���<����<�t0� ���"A��K�*i;�G4|��x��'lEE�� �q�w$�U^�3��(8����C�BY?�^}��z����%~� &&���+h��A����^��k� �
��ma$aI�4
/�DE��y9M{r���Rf{����
h�mV����u�98<�>��G
A�pZMl=����!�	�K��C�X���p����`G��5����������^zY�@����}r^�V����;��0se�m��=���3����e�W��4���91����D*r�X��Y
v��rN#=����hdQ�a��S0�!=\Q)��
vI��b�@q9�����������-TS�Y���� �;�5�D�l�%���]4�r<b����xE�����Nt�e�!����U�U%�'])��s4|��y��x�m������N��i����D��(��I����
���?]k���4jM�l"9p?|�1<H}���P�)Q�'��R�jI��m�B�7�t��x��,�0���$��z������!}?�2a�!�
#��=
B��br!��q�o�4���K&i��#h����hbn�p9)����$4����~Y;{M��#��Y-����P��mGR��=-�@��)	�0IL�Szi�;}�T�������6��S���������%���yz�2��\��^Hr������NE�1��������tE&�v����v�j#
4x$a�I��p��:�[�[���	�&#$��TY���;��S��@`�EePh����<xC4l�;u66�o�l&�O��q60w\p�����`����*d��%�~a�S��5���BD���Rb��5F�ha����v�?
�����(�BAK`\P;����xPU�`�����F]��_��<�����J��[{�Z��iP�����4�&f���j5���1b3baK���
K������a�"�6�'jti���H�b����U`�0C�t+��t+���V_*���:J�:�[%�����aVHF�7
����N�WG�O�
���j��$)D������,����E�_dq��Yw��@m*e�%�#<����p�q�e+�M?�[��{n�@mZB��Z!���EsMC�����_A�:����$-X{�������0��.]<�����D$��fD�$���4�_<]Za6����������wJg[y�+(���d=H]��@���,������raBVW~���9dD�������������@����4�%����F_0��Z2�%;��hb5��2":�dje��u���d$`������CEZ�|�]�B�����V���A}@�6����+rW���EAhXM@�2R �P�pJ����X��rQ(���^O9
6��C��5o�TF,q|�0�����2R���Q�,))���r*�j�d���k\����T�*����&�R��UE9qf0T�Yw��S�HV!he��lI��C/�������s��[}��2��9�1��~�3x����
~*eXF=%/:`p��������d+��-�RQ�M'e���}1O�Q�Z��D����F�)%��@|#�aJIK|/D�dg*v�"I�Num�d�����������:�u?�v��tB&Uyj�m�u�B�Oy;=z��@����
l8k�<����Z�����F���Jo��M7�u��w�z�]&=�W~��)dR�@IDAT�e����l��O��%�j�g]�������M�mP��
-1|a?��b8D��P��$�����P��h�t��q|i��=�q�'`�9��Ig8����:�Jzy�����+���CY(\�n�������?8F��:��7],u���LT��)��WRhs!D��7�m�J�n ����t>����pq����iC��q�����a^R�C
���#M�"K���(��E�Fc7QU�����B�kLw�+`��`!==u�TA�;�v`m0���tc3
�\��n��0,i����I��OJ�����;�u�j%2�{
�%��89��N��s����1�k�k�^��v����������;��E���:?��4u��J2k������yt��t����2��E�

@���B��p6�k������x7]�����
��m��B+Cjo����%����Vd>�����%�;�C��T�qbh@����<W���{���
]�����Cu.��4�W~�/�OM+��|�Ej-p^�����������S	��ts�a�\��<!SkiX���(��)��QcX����[�Ek�`lv4
��Qs����nrW6�C��Ey�%d/[�<���&���9���<�s���_�uH	*3��3���V�>sU������n�hC��t�'���2�X��x�k�T���s�q}���0���{H\�iom\�_^�.jk��3�����6%�p9v N��"�h��#�	A�tv�-�Agd���3P(;
2��3�(P��449s6(�`eZ!�#�c{c	�XZHG�V�:�*l���&���T���<��j�����])
�<np�a?9�W�������[�N�rI%+�1
x�#�'4"��,��PA�1 ���R�J��-����5�@D�d�<>H���J�����e���?��;��?`��&Q�A���u&$.#��'�(���ha������v:4/��_i�C/���2:��Y�5psu���2�+��������k>��Y�H��$�@ug�,7����e'ln[��r]L\��^e�Xm^��Z*t�)~����0xf
�IS�7,2��[��7�oD����%M���4��e\7��"�d�X�BR�jl�x'@1��7�'����Lz�"��bO�F���/�&���QVqo�����GYJ�A�y�E��+��:����)�$������� u�"���|����c�l������~e�
���_~���K���`�J5�ovemT�}�b�V��H�%���`"iv������4W�;KH��h���*���p��w�4�f2N���&q<��<?�����,�S�M����y%����ze�S����M�j'�w?y:��8�I\�_4o��>3:��Gr�\�PO�G��h�\���eH�� ��1��[CU������'�*%�R\5PJ;��}z��G�?��p�#~xn�?�f:�P	���?�������J�6���W��!�����<r��MW5�`=M�����>q�g���}f�����
w������?�������|�	���7�0yz��ne���+��{��-��$4�n/C\+��p.�N�C�L;9�e6O4� %��/���f#9�
����=�BZ�d5���e�D��#RB\.�X��(��:�����]VX>pF������a0�����vskSG�U��4�,|��������d�^�qx��!E�!��:BlT�$e�����8P09��.5�����<�P�[	wF6���k|zwO�Z�'BJ�H4s�����	L1-��1
�W��&���c[-n�$yU�`���C�c������_��Z��~���	���Jvo��RIJ�c������L���+�i���d�*CY��
.���sN;����OAkO60>u�%�&E+�	P?3{�nbD�G� FC�R<��[�������*WY�����l�����I��Gu�_p���Uf
�$G�"@���z��)����`�7�����55u�31��$�a ������Z����U�7'�sfZ��W~���m�����%�f�w��C����{������o=zt�����(_��D�E
��r��U��\���%L�MeI	pc��Pnm,�
�R��@�AJ�����&J���!"n��H
��X����C<��)����5i����`X�����;������p�?���G����A`�7��&L�=����?8�!�H5h��(���K�V�G���f���Do�v�����F(�XL�X/)�?���>��T�zTS��	vnD����M)�*��iI�
����V�i���D��~��4�k4�1C���ME����UH�?���c�v�����(�N2�6pV��{L�X�x
j������8Z�4�!b��A.�/�j����b�������@�T
��URq��H��ma��Ab~)�Y%���z���,x����W�Xh����3�$1��$�h�����T�WK�ya0O
���6���=�:��(�|G����I^�j�%�3p3���^�p�z���n�r������FT'��B����xf{��N���C�J�'�M�vE3\��>�W���!\&h�)~�2A)�WC�����$�J��,ze��+,��.��`�D����E�#:��_YH���$M��#/(���h-C�5��dp�(,�63��JB^�c`�k�96�l��9�0l���K�d��#�������D�#��B@�:x/n?����L
�|J��:TNV��OO+t�3������AC'��������i����"#�z���X{k�@7��ht��7��"������fr�P!�j�10�N���Ld$C�pA������d���*��^ID����l�����I�-�����e����<|���^Y`��C�u!��-�MY�C�)(�Y��2�P����"V��d�@��~���-�5��s�&>�mo�
�
� �6
iQP�g�Z��
���N��x�O����\� �+?�sI�<���@����-k9~������{�������X�u���'K�"@����-}��������dq���Z�P*89{vc�b�m ��U�!�t��(��`�vH��(APYF�n��r�*Q
���Q0�
�},q������2~��c 7�4��������Z�>�+�a!����%ub��P�6��Q�����&i3��`p.��pd��]�xA��!�.A'a�������O���v9�LK�@��?�f����^8��*OM�?TwH^'���+;�
���6�����@1/�#�������n���]{��pZ�vd��U
f3����s�$��=u/;��VfC7�r��c���)\�l������y���[�G�S<������?���UbN{S�$(-b)�^3qL�5[��MrT������Lmiz��8��	���h7N������.�g&[zM�[[��C(���<r�7�N;a���$�p�az��h��� Q�4��j��F����%mzJ��A���&�}9�p����@c�sYu�������-q���y�����
u� �6������n���V<Z"�e@�}it�T���:�$h�������b��'�2=�QJ�H]J,���
dH�%����V(���0��T�9-�eJ�+ !�k�5��*9���q
A��]��2�����{���+X=7h)������"���j���S�D�5�bF������Y������I�P�R���)�������y���*�Y�oQV�X�����k>F��V)g����(|��4�*��n����I>e����$�JY�XT����H���G2g�CWq�I-L/P,�NQf�(cz�tg����������t��t�����9 \E)8_�UH�Q:��o���#�*�Vxh�Sj1��Z��(���^J�� B������O�k�L)���ap�\��R���79����~��@K)h@o��/��
���A4�R�.�7�Yn�����s���K^��^�H�Km?�5��@����1���y���Xw�Y�����N�k��zY���j�.����CuP���?�BW]�e�+*l"����N��hC61�iNA�d�*([!.o^��w���6�22�+�����P+�h'������&������J��H���P����K.�J����I2<h�d��l7��i�������
�����C�r� ����Cg�P�KM��*4���}t�:�Bd%,�{����U�[���9��q��N��%_DJu�o�:SZ�x�a��}��<������������P��@
���e�}�m�*��7�$����P���h$aZ�T��a���p�O�X�������M�L<�^���Z��A�$?(����� �[�^[��0��`�UX���U�7���(�_�N�	~�Ee'��?]�3�����@�f�(H�j����.$�O�<��&�	J��,�5�����T �%�l����������{����p��!A�2����"�����;*�%�U.ek�b��3�:O�����H���zR�+)l�D��w���W[.�.�h7�^&?��y��~V����M����A�A�������C^�������Mt����@mgQ>o<dy��Ng�rW�A-W>+��4�E����l���3����~�
��g~�_4��0!O�_I:���J<����+���YF?��\9b-�zz8�6	 $�P��������9�p�&���rj���@Jd�h������v@�\�j�"��,}j�%x������e�[z�2?�r1-��SV�E~��*�F[��jT�q�u��q����3�V��c)K>F�#�Io������q�B&�o�������x,����� Bn�~��`9#��EY���t���L��V��pK���H��K��k�t��8!^d��{��ug�"��h��q4�5���������@�o��mq�����u6���	��Z����J�K��/|�H�O
4r������G=1l���CG��4�!�Y���cy/&�`dEH=G���h���K�)���n'����D���!Y<�����^3��	�&�(t�B��V���e�0�$�9�5��%���6�A�X����uxyiI����g���|�,�����z����	�;r�a^"��)%����^���;�,��(N���#�^��L/Tv�{UC������m{���'�?����B��/r���������w}��t�j�������7����x��%O�_�����+7�w���]��p������x��h[s>+�2En������jk�.9�t6�(�+y�k/��5���W�^���5����-�����]�<�������Gp.;��I���%6!�E^?�)��x�ON?O_O�e��?t�!1w}��*��X<�hW�W�T���������p<���`��:X���;3��G&�>����j\sQ�w��Os<{�:\��)7	��h������C��A���c�?���
��k���������t���N8����pd����h�y})�q8���k��a7�X�����Gw�Q�����1�������Aw������~��
�V�p@!H��z�V�nQ�p�A����st�>������>� �^.���@�{��>�>::<&����Wo3�u.�>�O���1:!E8����]|k��rx`?f����I4������Ll�j�ma�:�
x�\uN`1������"��dD��*�x����pW\t�x�@��~w8�j{m�2r�Mw���q;���n�K�{<�6��wG44��~������;12�h������3��>����6�����A��\sH�d4:�����xH������`DC'�
z��y�������]<��:���f���"Tg�W�u�4���>s������5�T�l��MX::9$9��vt\z�1%I�srr4z�q�Vj}���F��9�i]���;� ���
n��7���}��Q�D����{���3������Qt?\P��v�n��W�N������W�/���lxzM����C�������Jo$�~Jo����V�x�����H��8�{�/���c<^-_3�����bfqxt4@gZM����W��kRv���a�������^���A��L9^�S����-TG��?c<y�������a{�x�Q�5>�����*��T�w�_�>�S� ����apT���wY���&������oK�|>������x��K@����\�>���+���r+��h�>����!=�M�������d�3�#[�wd?�j�����fXr(��:��!��7O>������={�?����0�����c;�y��_Q_�e�����+t���}����osO��LX@��������Y�&�W��k+��q�-���^�oE�}3��v��Q���X??�����3���g�������������V���?c�p��_����������<�]t�W�����z	��_mj�SN���G������������?��+�P�����0;<�_V��^���^#��[L�r�x������������_�����;������w��~���g�����;�� ��7D(�y��o�����I�K^$�<�����P�r�M�8������h��-���7��e��0�w(��	�L�i|!�"w�O(��W��'��N�����	>O�>����1�?zKv�9]o/���z����g�:���G/�o���	8hL��������6�=}����|'���3�pyoGs�����Gz������v��JA�b��u����������'���WoD���_�����<���s�'���NH)!+_'?�RED��p�}xA#{��2��_d�E�(~z<�.�Z�������7oEA)�k��!c�P���Ow�?���Ztk/|�^���?R��w�_B��`�/�,�p`3'�����fkA���P��������b���Eak��G��/Z��h��i8D�f�>�� ���{?��_��lG7oF�����d?9�)�#�m�-}����B��?�����_8���N�1_�
W�W����Q���z���G�5L�7�#�a�i15Z�������,��>��P#�e���������I)�W2���C�)��+]��&4Y.�� ����]�]V�+�b!w
�~�W*�-����p��@�xf�X!��7��`��DY���W��=�R�GA.%.�=u2���FF��/����;���`C���RTG�!d����&Z]���fF�-����I}�g��!�$���"P:��!k����*����M����L�+~��?��X&�[Y�Lw��j�����DQ+[+��r�t=mLl�2�]T3���t���k�*[R-8���H^����if��I�J1�b�e;q�'Yt��aB��dcbYi/�u�����k2�uN�Q����W#@�����(�]SbD��\����� F2E�X'9*$����T��I���_T2.��a�������������o�y0��2h�4�\�E�n������Xz�T�x����)	���/
��:����R����c����x�+��J'r1<4�����3�?������-����V�tp����c��3���B�v�&B������a���;:�e"p���,�y��T�>�8�������0�A�
xW4���]�er;�����
uj��~4c`��y�	z��V��%���V��3	�7|S��[w�!)I���&�E��p�*bp
��c�j�u������x���5"y���'3�&Q� ���V��L���N& &fj�%�����'���8v����@c�����>�T� n���1�(�07�8�B�le��P�IXq��k/G�I�1�rY���h����RTK�4�.c����b ��P����@�5y����g��m(������A�+��'7����%���u��(n�e0�R�K���\��^u�9}��y5��.�,��1/��������g�:x/9;����+T�����a��>��)����0Z������c #*O�����e�4����H�:�`����d���E*�V0�X������ �Y�6mF�8���"���F=v��A�R"�YS��CS��4\�oa`�T��*�m�.��G&��Sk�N�Ux��$�P�K������26j���^��	S�5�j���`���E���fw��bx-���c^0�8����E����(BgvH�.�������VT�6��J��
&
Z�����CR���-�g��	.�f�1���F��
ia��V����y���V�����9��hP�BJ����V��L3��"���$c����H2Q���G��8�\�.�������y�4�=l��A�n9)��2r�l87����z?zg�Z��n�LT�>�����Jp����@�R�K��?�K`d�_'�a���s�oZ�p�e�f�:�9MH���~o�s���d��dd��RV^�^4U��� �@F���%Fcs
�Q��G��	�]�<���hs���p��=*~0���Y��%��E"Sna�&�4L@�3�_0��	n�o�����<��*4\����w���aHH�MV�p��R�+�i�RS% ��F�2
�����6�:���@�8�#���y���tRn�����n��
�W�t����v�&@�yu;�s�,���B�0X	�����j����E����E$�^�$�K_z;�����vO��. �rg6|2$�S^9S��Ia�T�4���O����\)�G��{Uw<+U)0)E;���9���}���u�����?}�H�i0�����x���:^���HJ�*Qv�k���p#�����`���;���Fe��6��c�B�0bT����I�c=���@;������ 	w|	]�O������S�_7O���PX��	��[Nk�!���`pM2v��l�"�z+��+�3\vc���K�H�[�7���Q�XF�A~}�68W�y��n��.y�)��
��U�� h�%oj
���0���������%u�.76Y�Q�f!k�*���5gu��,������7��K����a)��Y=h�"pU�H�e��e*��������|���V��,\InB�#+
�R�j�J�2�@�N*���4~FS�c���iLw�Y*`�
+'��yW))1�%S�
f���F8(���D�|cRT!U1lN���r�E=�����s�aM^/�����t� d�����,�L��t������ �;������h������P�.i��B��x��ziUHor��\���s����>�2���
c$��q��2;��T��Hw��z�5.�{i~F��?#n�����r�@�i����>;�U�v�n�5��x��#.�����4�oc��*�{��N�(���CQi0��/RnT����~�q%uA�#�U�j���x]��q�c�|�E���I6�������S�9�
���R)����XXj�H8��
A	S�0�.�$�vJQ��l�)��~�]��u��F�.:���/GE��Lm���'p�Y$R�Xi�����D�6�.��1��s��)Mc�/��P� 0����b�I$���
�Z3�L������ezv���n4�K6������D�^O%�����y
���G������`�6�D�0�mo����6�>,�h�(�����~�F�xe�CALThI��e��e��I�
����/�����i}%�K|
�R�y�����(�\���q�KQ�T��9��uu5@Y��>V�WW�yR�K�4����U�����"��>�h�f����P'4�0��Y	Z&Z1��^�^;�M���������wZ�2������j��f|�0��P��A��X�;����[��E��EV%���yU�!�����G���J��n�cb�&������5h���a� )��>�Dzy)��5���1(�5Pf��'/.L�n9~�wOM-�k���� cq#|�����Gn�����e�^�eA����&�u7�����M-�fZG�y�D:�	w��Q7xm�2Rr6������T0����7HQh!T����C]�Vgu��lS�1|�r%����;��(�LA]bd/���E��Q �W���	��:9�*.K�����������9�$��>!3�Mk����r�����y�����p�e�����HB��S�I����[�5��silxq���K�"(b��h���"�XZ�t36|_������%��UDsQ?Mb4��n�����a��L;9.�
4���M�%�]1�y�(�@7����=�,6r��e����jti�MX����>�C�"0�u��G�����3���S��\�%<&6J��if^S_S�{�2X5�8}C?=�H%p?��Si����
-��M8���sCO�� U�;�5B���)����{�g���9�A`W��� ��)W�g���.A�K�����q� ��(�4��;�I�����y���ZY���.�s'F�A�=K�()1��#4):���N�g����6Ry���Y!m�^��7}n���S�K�%2,&!�*A^M�1tG�/{y�t=�n��'�~����	����������BL,
�O��������(�Y�~�g��~��YI�S~��u��L�p��o~��3�X���>o�Y3��������|��\��$f^��5����N�iZF=�k�s{���S[#�?�*s]�_9���k����5�mVj�J-����t>�v�Pj�V��or��DbE�L+���y*!�)P2O7�hf�5|�(9�����A�]���F���
���e�,F	���T���6H%��,a���c8��X��:l���@���i�.bC���8h�����A�Y�m�O3�<��B�SE��R/�/�3�i������8z������/![�)��Y
�0D]��1��K��������st�����^�����d+�p��F�����k��v��V7)rtd����N�{l�b��m�I���!�}�^sZ��j<6�	x��<i0��{���F�����J�8|X��z���:���Q�����l��!�Ny�4}��������s������t,��{m���|������� N�C].�2
�!\)ti�b���'��o,�^`����!�Nm�����H�_�H ��J�K�'#����j���AAA���
��J�aT�g�����7!]��|�h���~��.�T��e�/�SP��������6�����xI��3is�h����,�O�5���w�R�6�_;���OD��QT���|8t��s�He��v���U�����.����$�zF
�jc��M�����F/��q�����^�N��W�ww��d�\����!����rkS\u7��W��L����<��5���$G|������`t�gt�����
��`x��F���4�gx��3������l����h�*�44�ZU�K�����V�/'K)������HrED��@�H�s�e��L�N�����9��I�A���0v@
lj�v�x��rQ���~�q�~x�^�
�)���5i��������`p��a�����),|7��I�fKF�39�Y���^��k�@�@m�B�:��@Cj�=�F�	�;�s''%�=p�1}�j�Lc}�]���4��X��y!	~����M��S��9
����)=2�%&�.^%����HV����m��o��@��H�8S�2��r7lo���DY��1��If�(��_b����_�d�1
�0A�V{pz�
�N�����&����M|Y�*�T���<�v�*���8.G�Bm^����>��W���'cl�S�Qp���+"E�.�=&,X�d�����8�6R_�,�r����\�B���B�^E�������*(_M�o/��Hd��-q��_HP(��+?�%���2d.�W
4�l��S�:FH����3�VJ |0���N��^g� �����4�k���@�%5d4�l�mK�����:��GrmY��t���k�H] o�f���"*��t^����&���`X�E�h�%D�|������Y�O
6M��4|4��T#9Eq��,e(W�fX�H��h��j�*[��y���ae��L	,FE m_��T�]�����>������1�j'r���+E�S����:(]�K�e�w��ZB<�%O�\��1?{R�����]E��dC����{�`<���2e��z���������q�8������m\������pI1V��A��"Ym���
6�;��5���67�����s������������E��)
�R	�������������:%�f6��&�t�~�����b&)��g�8j�`9i�����Ud1(��v4������Z�X8|��J@]R�� ��Xk��A����|���������c����^b���6���6V�; �[�Oc��v��	���G/���0�wLWZP��d��S���������j�����{�^���Qmg�L���'�����F<� ��6e���5�.w�;�%sb�/(��Xnfw2YA��O�}Ck�Q��2��%$x�i�q�@W�r��S%��rc��Cz?E\�f5\�����Y�����5��w�����7���:�e�e���};w�C|\����KZ����6
�G���
�i����?����2;�����}~���$�m4W�������>WE�(1C�qs6V���g#�F��4���
����qo0��@�2���l	�8?Ye�P.��[�B�-��r��LP�5�����1N�M?%��8��WvJF�Q����F���Z<Sj.��~U�V@��*j��5��i���s���7d���������������@����!��� R��q�	=�K�kqB:~5���
.�fG�����A95O��2�:����5�1^��3�y���q�:9��S��R��n�M�e�f��5��iv��DGN��������D�f~�{����N���v�{������m�Hr��9Si.t�6[Sk.��f�3��feX��|
������\&����������$]�:������B�����)��sY���~��~���yZy[/�����������$O���rj�4h[�0�8���(������i�*`>����\�@*�U�?%q��s?�Y�k�iKe��J����(6,����E��^�e���H�o)h�f3��e-�"��E���{��h�?��\�����]�F��y��d��0��47�#���!�"����~������A�W+aH^��>�3�*W3@Yya�NP�[{KB�vT�����69�M��8b��g�)9z�CH��k�7���V���?��'��a�x���]�.U\�0��k���Jm�w{�zy�\>�+?����R)^��^�8"�W�2����r�l��eN�hN�#���-����PN�h�8u��������.s���o,��U����4������������{/���l���@�`D}��K�|JEl�*|��a�;�����t [d�I���{� ����-j�u*
u�?�I�?�|2/���r�i�1�b;���/����1�+�v&W�S���vO=�*�h��8�B�z(�F�=,
��kn�%��dr�w�L����A�0|�u������b����G-�4�m}��;��Z�������MH��{���s�����{2��3>��}F�4����������@�]�K�����x�s�h�� �s'����T�Z�pFA�Z�Q_���������LS�o���s9����U�X*�w$tn~��k�����r|���9��"�h�,{�����Az��i:S�^^�4x�8|�M�:C@ClJ�B,��w���+$�rc��u��!�n�^N����#���W(dw���TMKw�����t�V��.�F����h%����e�����L��lG�������z�04FP�mu����A�}�A<r`)���L�Q.EQI�����+�l�2�lA)��,�W�7�7�C�Zphn"/�R.��@/E�+"�w����d���N��W��
|���}i'��.u��/V��Nu����X�h
�
Bc�B���`d'6�I��f���2�����y4���e5�I^�5�������N��:6:��1����DC6���������zQ���,�'���������]�.|
|?��k��T���Q�RH�)P}N:�%T7���������2��%[Wz=|����2t�H��'����1���56*"�b'�5������������d��������0�@�>{2�$���89�r�����0�/�����<g���4(�:��K��P���MC!��)�UF�Tg^L�VU�����Kc
��9�o�L&�wDa����?�#������|��14��'|���\?u|f�E�UV9�g?�+�s�z��M^�9v�10�>
m�5�Y�L84�
pr#|ob��,M�� �&�����1B��/����)<x��x��?g������T���-6y�B�9��0�-�W�O��R����@��t��6�����"�H��;�hV��=�o�%�U$�7�K����'��q�T����k t���bi2k}L���<�P21������Yk���O��k�����Pb^f(Y�
��m>�����V�h#�g`M�I^���l��0�B��*5����L?3:J���o*��8��������,��r�z	r\���������������Vc������y�����+?�����0V.�W���.�&����
�{h5=<1�P(��l���^���`n�:N^�y��FP_��G��.���~���w-x����d�P��gx���(��v�Nw���D�CE:s����*[��im��%6��:��P*0��
t��}��r��%�5�����5�j�4��#�L�2�fR��w������g�^8e��;��Q|�$99�E�d�W�Ap�*����b��� ��=O[-����'�O�qc-g��w�����]��|��6����p���L�\j�����s���|��}����R�1�.�8y)E��������5aZ�?������%
i.P9�����?�iYu���P��H^$*����Erv�����,a�h��^|��a����vZa4�[��n�
'h �
~=�T0��k�@���>��;�|������AA`Nmv���N2	"N�U	yw<?����}3(QJv��ib�c4����^�����}Lh
U�����II��r��.���q���a��G%{������u�fP�����T�K���Xr�s�m���������u�?
�������Rq����	��I�/X6
;�?7-���A!���L����I��������r"A�J���x4x�v3�`3z�yDa�jm�9KRV�:?r�,������<��&�^7�wo�O�^A��`#@�L�l
�Y�$�u�7�V����^����q�(~g��K�+?�3dt������M���~��o���8�7����w�����'��s��j����Jt��y�����hh�e��v��I�,o�0D�v����e�y���My���rZ1�n��$5����������i&36�����
���3���~�]�,�1$)��D1���	�y,N��V�R�����~��,{P�:���
����x�t��^�F�)����n�1#7a����2����[�}$'/����FT��q��)���Vk[�uF��\K�!}"y>H��M6��.r)ur;�/^��L�\�@����&[�������Y��=n���o����iT_���r4^������%��u��8��1��,�)X:#�!����Zk@�w����C#�%W?�f����'O>��cn���~u�.�k<����ZhV|��Ic��7��#�5�����Y��������@3�I�%-Z��T��h�:y�e��'��-P
ta1�}��n�����R�b�E���/'�fS��B=���)��@W3��7g�E���8?�[�z����*����w[{=z���\��M8�:&9��X������S��x�� ]�~���`@IDAT�j��`���
��������n�Vc=M�d���
}�������+�U�=)�!��������=
t��p���TY�}|k��#�$��y������������c����s@�lL�h��T�.4�09�u���g�N����i%u���@_���(s9~����	b����7�D���W_1��w��p���]��ZsR�-`��L����5/�N�C�L6��	��D�w[���c����Fj�����a��(U����y�f5�t��0�t�V�����$Mrjl�0B�A�9��j�+E�:�B�=����
��h�������g@�r�����`����3�[��+p])I�������P��&�@�t0i'�(~g����h�������dz������pakm�a���l���/��z�V{#
I�Dks��� ��r�j�����&��?d��$�J��[��Z��p�sQ,��_R���%	r%d��@�D��#�����+�e�����s	�e��{�.L���_�J��zY���A�qi��j�KS�@�8��p�t�i�7:�d��l��n1�#4����d0������ve-u��%���bL0t��\I,������A_�'���8�p6)��Uy^9��]���hy��&���>9Q�$R��u�$�����mV
O�a����2��u:����Auh .j��V��b��:��z�8S3�����u]�����#�����F���^��F����]�����C�����%O^�G�{dS�CNt���M1��;�?��Nt�<�CU�������N������F�Sp��Y����(���~���
NX��*�r�U�:t��Z��O��Odv
b��l�_D�����������/)�����T����^S<la�AzG- �\{�&�	�<>O���C��&�/%��`!���g���z��y��nf<@��YI�xZ��S���i�<�5�����������d�J<�?�r���������2���K nO��d�<���r�<���#��O����x����8J^�>�N�nn]�Mz��x�z�������{��<�r}.�H%��������?�K������G#�;�y}G'O��#^���s�y<��{��^pR���������h�_���|0�?���|RL�����W;O�^�7�}j�,�_��)���5 	9���^�M���kv�=}�j��?�f ����1������,����O��'AN�)9�t�����&�K���,�C����w��A�u��A�	o�+N��wx��q��	��`�l���t���8B��I�u�M|�O�~U�O�#�a�� �h������7����;�@�������'��Z������k�w:��bq�}8����M������<�;�<@�O����zs����������;7�
���x���Q����(�q������A�����kz`<�������V�p�sk�� O�w���%�	?=�����������[;{���EI������6>%'���G�������w����N���������N�Hd)�n��A�06%���J<_��V��$����?�A�L�����;�@������I�X���'��	��
.����I0���n��;���w��'����EC���0��1�afz����}?=�`\����#��x ���_jD}+�i8��%��|�s��x�@�4��<�h��G S��rd����i5G��<��yP[�h'����hf���N�wt)���6�Ip�i���z����x.�r�?Y/G�xU��'`���t�����d����W��4����7���������tN�������[G��������W����e���K�;��3�Y��������2uT�~gk79����5�����:�W}�F'���Wkk�k�W^���T���dy��\� ���;�;$s�$~����7:�����]cp����W����xHM�O$����D[,�S_����O'�����S}��'|���8��<O�����������������x����/��LG���z�x
�M?3�eA�CE\5g�����Zk{��jK����\�oq�-�g�h�u��g��:%g��GQ��=��q���x<�	�����1Rw�C����k�	L>�N%7:��m�I���$}M}~��A����~h;��/i����^��omv��sv#:]�[�v4n���~��f�����m�B {0D#=�
0{v�C=m>�0L�ul���ii�?�px�2��'`���S�H������eP����#������?��9es{�@��*��;~����>|�	�xM�C$x}���������xw���������]F��)�]2W���Kc������x���Jz�?����F�N>+����� ��n��
v����J�y���4���z����������{�xLUi#&��>�����r8e��IO7��'���l�]�qr �k.jC
�F�R�����M�T9N���w�*������
W�����5�gBO�����O�z�����\������7��)��������]Q<=�*���gW.����WJ������w;�\6*���
���"�/?Ck��0�{�QN:B��JzW�/�P!���3P�>�3���<��t�qZz�e��_����*��'�/j�����.(6�������?t4]�����>���q0&]�{�Kt�%������W>c����-�7P�)��^pba��3C$\��dE�����%�4���{����I����`���?��dz��hqx�F�
�L��0��D��O�c?q��E�y
�@#w"����
��p����p�3���`�h|�Dcs�����}t.�$�c�6 ����~��?lc�5��
.�f�L�jQ=~��6FZ�����x������[���Z
�s�eK3�\,�tj��Rn%=�gZ��=#}�9+��=�x�|��l�;2�O��2*�r^�x���{��9�c��'����"��x:�eFR���L�L�Yu|��|N�SP�d<��)�>�M�V��������$�+���<K\iY���s�E�'q>^����M;�T��	n�-�=�l���wN��b�B�T��W>�L��{��d;`��Z��N�x^0��������������G�Z8y�rM�s��]�Qmg�����A�)��LOeupy��I$���R�$D���|tQ���B+��'�a�#�?)]��k)E�K��_�7��J�`���4y��q����k�&��;����3��Q���]����hp|s������O*��Yas��RS�
�e��:T��bO��;��.��Z����4u�^��q�q�������x
[���Z��;��~���;
E��-<�8*w�E���=���V��E�)W%�S�����r
��B
���AmJ�����Ww��|i�_�n+&2��y�hN����>����[�(������q��	�������LsO"���?�����7[�V�Tg��m�6��q�*4/a�%�/�x�������i�d�	�/�'�[��!V)&�{��!0o�EP9��v8��A�?���p�I:�Y�*�.�)X'K��k+�B�����\����V��@���������W��-
N�����s+tu71Ew���+��)3��s��+�u�&?�Vh����������U��0(1��C��T�������%N6�P)?�4��9���%��9�����5��>��M�P)?o�������'��kZ�eA*U���I���O�/EVn�l�9��z�n8�n���Y�)AoR����Mi��<K��~�2�P7}��x�}#V���X�	)�c��y���r;u_�Z�Q0�gl��! >���L:<x�3�56������..��4�B�%�����03kY��l��;��:�u���6�%Z����<���.��>[���M7{�����*���.��9�����s����:0:}�5O�,s�D�����}g��B�<�;�L[���VcA?��B,�#�1wZ�VOv�E���~����"����3 �`�D�EF�:5
u���A�7�{�p0�a��!q�P_$�+A�&BO�ChV^����c�[|
���Fg�I�d��	�b��,Ip������a��6v����}t��j��%���&���m�!����p�e�$�%��lW���?�V�y����SO�z��qq��<��h����o~�h��������[g`h?��O�J_<+�6�-��r2c�L�2���i�d�8;�x�:M5�����JA.&8y��\�_�3��7�
��Y@�$��MU8�5B���k*��v��Co���j�Q�4~5��I����NU�&�����|��Q���W�������
�S�x]�E1�C���>�9�Q,Q�R�NF���=����{R_����^����Z��6;�M�&�g��q�Q�	�<��Z���{�b4�
C^�3����gjVd�G���3��#+�Z��;G��M��`��zm�nb��a��������M�4������h��3���.�~�T��\�e�C`���IzA����2���3�w+�i�I��t��Zpk�R�e��7�/Fh"c�����;�HQ]�����7�Ql2[m��D�C��)�j�6�ME�.A�kmM�G��:��6�I*�S���S��@K�z�����h���QC7��s�&��^yw��3�;�F�@�ys;�@E/O#E.I��/�}���aw0
�4��^O������cM�x;'8����]��|����4�fu�;��w�5�?f����;z����;�o�,V+��Y�W���i�*�

:�T�e��)��J���J[mA�X��i���7�F��vw|����=Z�9(���-F��H�4��W��N�}5i0z���T����j�Di,���@����� ����S��up*R�eo�Ym[�P�j����Q�L8��������H��R�	��Q�2#�!V��^
|���R!~7E�g9'e�>�z5�9Z9�s�b��k�F�L�m��`�0
�D���v�"/>�������������������7=���(��s��
8U�i�s*����a�x:7��3��@`��b|{��D"�l��B�q�t��zu���0-c�\�645�:?d�$\��
����j��Y��!�8$�&'	n���4��N�,t�R/�#�x4-�����R^z����f���|��^�B{���p�� 3b"l�[��l9���w�O���u��UU��#��,�[E4�7N���X�:h\DT������Q���e��a�N$!k���<n1��[�D�PT��B��KS�������}�'��������qr�*8|�Nzy��Q�g�A!���^�:<�C��)��J��/��J�w����i��2��,��w�o3>n��?���8|�.����|���|��[��*�n�����u^�:��g8�AUs�F[�DT��\��8y_�5A����M�4����+��'�����5:rPYn�8-��a��������{�]�����=
���v�{���P���;�%�l������./���/ Ia�j�w�7��w����������Q uZ�]�Q��(���������fx�	��N����z��b����,$0Fm��u���o5����t>����W��O%��x},+�c����i\n�"N�I�.�����e��!�������d�s7:	�da5�5������3
�rcS1��H��Z�0�V��r	��P�E>n��cI��\&?�t3F���mI��2Tg-`����BDy�B/z:.����gS������!]3zw?�w5*k�}~�&SF�&�	SI�K���C[��c��O<=�q�j�;iL'���|�gt��O��S�<�X�������Yj9C�Gosusgc��	���O��a����N����&"��,�"���^\�Q��b2��~������o��I��r�x�F�7����F���L���	���n�0��:��T�I�����1�e6�5U�B}�����d(G�hFO��:o����y�9��|
�U������L6��S�Y�\�+(`����C�V�,\��.���W�*k��"L��6�����/Q2
6�4�r�r[�����J��-x2%t(��^�"e1?�����G��/Y���Z�M*��^��T��*nm���d!�N�4�1�!�P��~?,�6���rfb�	����`���H�n	�W'�7��
�w���}x�����"�xq$=�,��a��jM5��Ar����,��4m�$s�*����)�M�j >��i0�8�?���'O�am&���v4��t�����v��/�+?�E�������k�GW~�K�����e��Au���Y������u"�$�*	a�Ac���2}aC^pn���� ��{���$��&�z?�H��(��	��I��#�4���L l��g�����kF��rQQ�,HK�4��h��B]H�p�y5cjN��R��E�<��E�?��h���!��j5�|
�~��6Ee����qQ���.USRxr���rh����[�v��3��Ae'Z7�n"\p����|�Qp������&���7�x|l����j"{J��?gsT.}��+?�����r\��>?Y/T�������L��.�W>'�v�%��A�,T#�Z�L�c���7"��LM&��$L�@@
E�����6R�q,���&?���T���	Uf{%��q����nQ�����I��*_��������/�N��]��*x�U5��>�A��:|��jb�&��k��"����c H�l���z�e��e
7�W�/�u)U�M$`A%q���3A��T�&��QEg9�m2���l�j}�����~�� m���B��Q'�Y1e
�.���I���U�����G���!��&	��(V2v��Xb�Zg����X)��~����	�4W~��(���buz�
�i,��8o;��/
��:���X��.��!\&h�bS�@O�����H9w����m���������V��\��2�f��u����l��q��;��D�����G(y��&Z�Idi�DCr�6O\�h�n�����]���Q]�U3�J�D���v���k?��"55@�
��M4���v�B��
��V7~��(�K� ��SS*D:�1(Em�_T�R`z�c	o����j�]s�nZ&�2=$��g����k�vPP
��G��.�q�4��R#���;+�<�l��[Oy�X����=O��M������i��>|��@�m��#������������U���Z�T���jE|6��X]p���=0�	ku���)h��Y���z�Qoi�S/�	xO/�al���3�8�Z�[�c��429>��	
��K_����X��"d�~�2�������
�3��r%�`a�)���A�$v�> �0Z�1��v�t�&����`)$6�w��s��<�Jy����Xu��������N�_�9�2Q���h������@K8�����M��A�J7������2������h���w�	�==����<��1N�5�qvIL:���bN�Q+��^}hl�����VA�BhR�+?�"�Sz����Za2f�L���@�P�g#��]PMZ������1�����d�`�?���{<A��v��g��c��9��.�r:
?u��������2����P���@�K���qK���:���6�M����jF�d�#�34f�����ZUYe`���R�����*[�TP�s@�a�SLD�n�?3��`5���������B�,���K�L������p���[��������c#��j����na��c:�[Fxd��%OZ��M��Y��������V��&`��q���c�=�$9�|�,�ZFa g,n�	�;A>#�F��/�/s���f4#i��n����[�.�`�Q���t��w�����jQ]-P��Auf����Gd�?<<#���j��s�>d��U(�rC���Z�H.!]�*��aK|�e��=�z�����8������{v���@���g������tVFW����	bT���%Ba�K�>��z
�9}���rT�G���()����������QK�1��e8
[���^��_|?|e�n��>��	A��]�
�����:d�!Gy�M��#����z#-cPf���3ov��@H��L��}�]�L��B�TX�Z1�&	��i�p�EOx�����H)�O/�������r��X��T
V�Jq~��c8��b�������l�v�{+��(Z�g���b��,�,�Q�C�]Jz�G����Y
m��gD����+7o����t�.��7nj�kv�8:I<�*���g������p����Bnc�y�B�4�������`2�#�4�38�:�8/[��}y��;�c��i'|��K�\R���r�����R��>i�b����\�����������rK���|�-���#�r,RpyB-���1�!a!3>�.#9]��9���<# �A��rOx�s&��^`���(�%��N�l@(
��F%!����Q����t��eJ&�����(v�������9�9��(��������+���N�����������N-D�}�w��������!
A����3��&��5�S��kkDQ����V+sU<�4��y�����'!�J	����i��hJ����{,���x-��)��G4��y�Am�b��I�{,^�}����6a������k=���w���>7�N���s��^�Yvd+V~Y��y�&�l�G�{��q���3�4��}���F1=U><�����A���\b��}t�v��d���u4����G�v��������@9����5`\!1<�O��������^�_>��]�$��NyDq��<b�2�a���+k��gs���to>��x�4V���CyI�������kN�gyTpLu`��@4�Z�~��;�T7r��7V8�E ^�cZ��N�bI�[NO��i	���g#9}��=�gx��:��eGh-��{�<$��Jn�����ZH���X5�E���hJ��X��R���-�W����JuAb���R�]~T���	 cf��(��"������!��/>_�<��b��6���v�~���?���"�n��v�������G���p�>�8�l�p;����i�{�v�����*0���O���=P�Jz������q�t�jp~>r�g��S�yc����:�����~����_����o'��9F��qz]�u��4���:�iz����%<��%���N<���C������;sh8e�eD�R���x�C�����G�'9<��:B��U����C�@���H�V{�W@�q0(�r��'g�����}Z�l�
��S�c��:r�h)���C��.^Z�@�?�HAy7K�����9��I���G5a��Q�_SjH39�LI���1�#E���^G�(���v�����szuY�����*�~Uue�t	�����s��P��O>J�s��3S����"�yA���EspG�
.����M�w��?�0���s3w��6���iL[\�b��@_�6�I4�}�y���{�
qq�C�
0�� ��c���j>�	�O�{��*<��������N�_l��X+��G�����)Nw������A��=����}Irl��	A�vm�;
�y��~�|�yQ`�o���i�=G���=_
��XV^��>�Y~�w��<WY����'^������SA7�(�4"��D6�M���,�ZNGK���y��
������X�_n�l����S�$}����Q�9JZy�)l#V��I�!\!MY���HO�u�e�VB$�;f�W�/����,�^�����|�!$�:f�m�6DX��C-�h
�n�*oC���F�����fs�~c���������2P6���`
Db���RJ_����9&�lS���ip����9q��8��@O��d��xp*�� ���������>�W�?4���M��.���
�y�{j'��-Y�'|�:�i���)�����D_<�qy��\�p�@��� \�$!3�=��t�����n�&�@����DI��;���+A�.8k
d`M�
��}�$�t���;�>�#��q�5��G���d�� 
f��V���� oV�@�����` #�v0Z �~aF9t���<
r��nV���e%*�����5�7Hx���:�"�=J�X.���y��z�pS��X4hsH`�T&si%���)�IYF�R�r.�v��4�'��+(|lm��s
��a��5���P[����=:��('��lbf,R�
�g��i!1�cW1���
MC����~��<
Pg��������}��r�MfhnB6[�&��B�%���/��m������+��w����!�\\������:����&D�������<�4�5c���/g��U��0����R��<y�8AR�z������_%7n&o�&4�
�u��
���K���$9�l���&/'��_�g�� Xh�t�Rz�-�5�R��=���e��<���8��)�5i|������ H�C�������,��{��GC1�z &�
�J� ����rd�@������W�J�Gu9u������Z��r���Q��E��Ga(��H�"Y�qi���\�W��F-DXd)�-��z�����A2����������;��Q��Q��O��H<�|y^��j>��v���k�`7��\�������i@�*��Yt����V<Gc��<�y������N�u��������N�eR�:A�O��������v�S���c�k:6
�]:��q��9p@6R�����v��-�{�*���$��<�kM|(	��R�>�X�3;�P�I]@�9^����ST��$����Ll0�+�d���#f��w��z@'�,7	�I�`l�st()�� *[�C��:l�A���YM6�nz��-{"���������Z�j�p��#�����
*K�G�A!�8��0Yu���#?Mde
J&����g���s�4�Q)+�,l��<=�j������	��M ��	�A�<�����r�Z��8�K�r���@��Fg�TB��,jed�)gm�$3��_^!L��O�.�����[��|�re-a/��y�q����*����t!F�}�M���@��Y#����H�q�lt���\��<
x\3����2B�/�<~���?���Rx�EF�	�#�o�I�D:��Z��6c��%BP2������}9�8k�T�U_�'��*����1�����*�=���S�����Q��������`~��c��s�q0Z!�T�#��G����/�����8��i@���c�g��vG`��'d~��5�|O~��w�F��g��fmvPo�����F`��fb�0+'Z����v�73��T<�gva�_��L����7	!�'�N�V��jE|����|�"�����p�
���
����f�������E��yzj>����8�V�A�������$�����F��N�s����?s�;wyy{w���������t+5t aF?��U0���|;J�t�*�R�uZM���{~[R���u��Y����a�m��f#���X�����4��Y���/��}������<�O~����iwg���>cb�\<Y��
���[���*&N��������.+��#A���Z�"`����vy
��v;����|*5:��`���g��5jV>| ��R�� ��l[��w���%�o5U���H,�� '�4��%OV/|��l�o��&p���)=�\��Q0��js=����f��wq{Vg�/*�)����H��y���+)��t~j!���M�+���[��%�DP]��������P��7-�����A�f�������]�S���wy��
�"��2j����Ez�&C�����S{!?(x��w}d��r�j��`p��9�7�������
	���T>����zg���?�s�������Y�E)�3���?"K��%�������>�Q��:�J4��&`��9`hJr�Fq>dq>;}i>��S�N��R�`bP!����|hJ�C~������������uz������v�OA�[���u;�����x~hG?�p���<��R������6�����Cq?=�|��^W����{���Z}fa O��_g�fX��3kZr�����R$��Y�O��u�f�����%u��T����?���W�����E�Zbf[ ���j���#7f�O?��
��������k��H������pT��.l�/�G�F��8�V*�C�f��~��<�IN����`�	��?�O�	��qxWb���jwy�0m��)��Q�k����Q��(�����pk�j��~�lDS��8���
*��Eo|��AC7*u���7D[j�N���N_�5{2;A���c�[������W�<@&`x�Rk�1�b�S�,ZZ���������T�f��f�����F�����x�{��f��.��Fu�F��BC�CA >���p���}�s��,0F��2P��pwa��S������mv��|��O>���Vm~�n�z�9�����A��L$�<�z�0���@�j�Y}�[�r���xu��D��3�L�����7m��>��
&*�O��Q%��iz��-�������~������%m��w���;��^mf��������2��|P
������4����c8n��������>]��'��|������������!��=�g�	|����y>���|�y��0�6q��;a7������0�2A��b����vW��W\���L�|�@�N!��?�g8�V����Si�w�!��������������c�!�����$��O���M��h6���|n�����p�`F����=���V��U�:~�OG`����G������v���yx��:�5���w{/����_�%K�����*/�=}�<��L6_jm�����!�\g�;Ax%�����~7y�$��a���
����Jb�=��N���%;���k2�����<��I���[���9�w6_����r�����P�_&��QX��OU0$j�������������#���W��������:"v�$����OV����!!{a����do�wx��W,�p�GN��L����0�q'a_�/����?�M�������4�����o��U-���AIM�����������������p���������	�� =�NVb����d�F����������SU�y]��g����;w�?\\���i|�I��a$��������8W�	D�"-	��_���L���|��6m(�Mg�},~�o����v�qGB~����b�*����x�z��d��Z��/7�W�|���H����_T��Z������z7�a���h7d���A��m���R����%$��&sL�T�+H�����S���(���������_�/����&Y��~,D�P����x��ai��6:�����W���{�������
I����|�?���
%T�I��(Y�H���y�]!an6>�UZ���%��@�S�~�{������k���[_�����q���%���1N}htp���Z�����@�?���S�4�����G8U��U�c�<l����IV�lom���q�K9:O�t����NH&�����x�4�+�e/Z�%~:-U��'�-�R��R(;�D�J�������$&R���(�0�uB�B<]
~(�F#d���j���hHG��!��T*������@��R���0���Y���H��6�pJ��Fn��l$������_�����	��O>�$%$:EQ�D����}�k�^��H��	$�%��"��I2������	������E<�:h�L#���������4�����@������i���1&�o��F����[���-SZ��j)��C0(�#$����+[�B6��j������r�[L�Z/�y2���M���+�S������q����s
4�Z�;!\���4����H�`+)k�����iw������������g.����.������xz�����B����Lt�N0M�>�z�p�^"��o;���tV�</]�	
���i��p�����)��|�/���Fp�RL�r{�O��%�b�H��idc-�-v�h��������J`�8�@�1���- ��n8��D�+����k����{n����`P�����4�`��~\�^��l�WH0�\x�U,��b�$�U�eq�P`Q<eA������p�q�Y�
"��8��5
p��a�o+0h[�_���Z��JH�:��@�y���������Q7����xz���q�p�-@�F
�V9�����U����R- �vl7�H�PQ8� ��T3���_������]����H$xQ��F�������J�v�j�L2�;|��]���U|==V�ruwo���)6�8M���1�uB��"���<��8�b����l����w�4���b[�yn�a�����e��e��cR��4��@O���������8��9����=����:�BK�o��TuH�1WI�3��S�8������a�&G#��o~&VGA4�:����@���[~7�A�
����
T��<�fE�
%���,����,jk��{BN��#�Lc��9�&��%b(��|0$;��X\!����[{;�}�)(|1|3hk�Xb@<�C�#�������M������-X�_\5�f��l���2C�cg������w@�4��:��z4y��7fPS�I�Lp��2)O�X�"E���)=M	ahKR���ST��Lv�y����s�*�
�%Kd�����u._�6O}�ps	����kD��j�k�B*N�<�pF�l�>��	b���;���ei>����.�-�1����QLY��V��Ix�����-[������;P{VFW�<#)��xV_
O#���}�Oc�������{�1�F"��e�	3�lv(u�"L��Q!�@�������1l�Z�17
P�(1p.�#7#.H:�������!�Q9�����u��?�f~-��������J�d��}���f�hc�~����Gms������4x�KH���H�|�
o"v ��]������m�����>�B-�2MF35��*5D����q;� :F�P��#�(�"Os���w~��<�)��7	e&�����>�Drav�~^^�?
DO�=xG���Y���������Vh�6.��IF�X�$NR�������y�K��Q��^�=\};�N)��tW*4�T��2��ngy)���h&���Oe#�v�
��P�=I��5��}j+9iu������3���"�I2�M��N�-�w�_h4+.3������_X�T�)/��N;�����dzy��/��z���M��<�>���=��9R�������q��f|��h�d
t&MS h���l#g��jO_��#�2|2���]FY�������]v�������:'�7?���,���������4����~{^Y+�� "�9\��8>�Lr�DG�IXh�����}�����'8uA����%d���+�%
] ��w����������d�� $ZHd"�x�K�%J���x��z0ht]���D~=�|����>��{���V�������m}N<�jk`��&t��n2��	n��5���^+�l�x��4�-h����8��pAT����S[��������\���a��i� �.�$*K������u�O�=���4t�rU�q>p�i��
�b��o�j)"������Y�q����#���l�q|��s4��F�/����>��tU����uP~u����8Ai�k��J�"�2<5�073���j�S��;�|h`dc���^�a�?1�3���dJq
�Nbo�ep�{��ai�p��|���� �9u4B[��L������#�wp'�;�~\�zG�1c+�����'	4�@IDAT#������zc2�K�<SK��'S�u>}�S�v�ggf��	��<�L�r���Ybi-F�6���1���^�t���Y��k9�om�4���W0��G�P�`
�bRO^�V��S	�v�<�"@r�
r:�Kq�AD:�����!y��x^Wn$o?�?\�Y=�2����.�2������� ���^�2��.���c3�#�2d�������)N�d�5���������!���++��r������C)�Rs?���s3:���z���\g�����Mt�*�������$�����#n���|9������������O|Fch����~���4��S��C����]�+������M��;n/�3ij�P
=������2�5
��������7���F-����
=C��}N
q�=.����2�,QY���]J��2�r���F��n��
��S�hC�2
�`{����'�1�Xc
���.�W~(��U��=y�A���da9i?K �J���d���yac�2`4I�`5�S�cO4
@3��xc������9J�!�G-�Y������j�-�+U�T�Y�c�*��oeEI��	+]����vc���{�����wSx�^�����~����B�z#t���iz%��nvh�Z�:U��zEF�W�:��E�8�����[�((����)��n� Z��(BqL��~�
�\��*������O
�ba���_����*w����P�M8�&|0c�����s�����_
[�i��?\N[z�8k�P���`v�<��,@����29	�U&���9�����z��4�

�2P&��A{��0&>�"xy�K1T���~P{�+����Ypj��n��-A�����v��j#�Pw2j
�d�	�RsDBT�X�����m�)�Q�`V���$�G�;���_|���D��&��94�S�����(�#{*��Q��T�d�R��y<�Jw���`|�pg����&�&��%�(�^T2e+�|�7����9��� �\�������)�MF)�L�c�D�+�kJ;��]m!g�^G-�hC��4�Y�x�U��3�t��O��l#�<�I6���A*�E��l8���
�q�=�2dt�����D�<�x�rB���|��W��=#�K����������@����h*ow#��r��Q���R��������H:��vj~�\�l����D8��~��|@�OX1�/|O���������=U�=+OUz�x����D����9Mor�i�b��e��h�;-��S�8���1������I�`������ls�I����43����/PI`�q=���+H����k��EvA���kD|�a�0���5��Y�[`�Z��LbXv��, ����tBL�>�z>�,��|�����!f�M�[[`�<�A����|���%����F�#�"9�z�M9��.�~����Q&h�0fW+��8O���=�6��i��B*�b�`d�����3������`]�/�x�2$����o�N����v����e���U9��}��"#�
}�j8�|l�Bt�;zE�`Rd�%��?�_m�@�V�������� 3%o�KN�PK���)�N�X��Z�n��/)�k����?�<��;nf�EPRm���>�Q������$�5��9����������F>�S��}�Y��}�	�9�����t<�|�$f�B��1O������~�F�*X��uFi�}Z�c/2� �X�(%0�I�+��<e�L];N��dko��CFd���9��H�j��V��R�W����F�(����^;H7�9�1;�WS���m9�/�������<��X�)���F}b����`h)��@{��I+\r�����_���M1���?��uT)6DTDzrb6�)�S��Xy�}8q/����2M2�^���<�(/� ��m�L���/rB��;���������������G�����)K�U��eb�����6g$I�*g/'����5M#-*Z6�F� �F��-�����5��"��QB�:��#eY@��	uv���O���1��n=N�G�q�7KT���/�M`�5a}����0�2�H��H<��xV��T�i���������i�^����w;n��A���.S�L�:�i���)��������1<��.7j�N�������xo�g��&�|���������8 ���$T#b�d��A�@��a�W���Q�����?
y0�
�Y���D~�'��g����u���9��t�U2������_�RZ�Y�2�N�4f1h�Z����@��Q^F�� �X	kP�Y�;���8��l�U`���!�
���
�)��,����)
���"�5�P#CS:��4����k�%����(���`�fj�����T���?E,�������Y9�u�\�N�w;jK	l*��~��I������x`�,'-�����������"����t����+��"��$��^�|��ZS��A�����Y5�Cf���{�/v�T0K�j�J�sJ�;�<������i�:#��,��czs���xn,�9���^~��WW��&�u�i����Rm�s���}������M$l�d��HV�����{���X;�ow�}�����1�'�����G�}����M7��h������`��&�4�B2 ������4�z��@^!1����g?f���R���?���<�P�pB��:�6��0��f�P�k�����)1����?>N��J�����.T��O/	ET�eh"P�7�B����t�Mk�/e}��K����DG�[hA>�z�!����W,���t�P��k�*��4%�+������2 �rbl���R�W>��t�r����I;0���������om��d0:�i�,�b�k!���N�,�)$:-�O��}��w�u�yC&�$#�/���jC�J��D��d@y�E*1Q):��8~�d��fw�J����ZBB���\ZuZ�~��(H���H����Z��M���%V�B���MS� �_�}�p���N�;��n�X��q�"[���Iz���[��2d��)��}��B
0�T|�YF#=#"�k��D>�K��'���49�\���/�x��YA��v�=!~xb�P���{F�X�D��1�e>N��v�0�ji���)�8�FH�,m����_�\��8�!�p�9 ���A����ov��j>y�4�Zj��H(Hd-�_;-R�������J���]�4������e�t�����?�
�
rE	t�>�A�a�2NC�@h�2\1(M$�B������b[L�X3$8��`^�!?�X$�`�bTR��i[�#s(N'71<n��[y���E���D�<�39J�����/=������6��d�4?dzC��fj)M{O�>�����2�P����0����Yg�W[rF)d�6�qh �TYhj	���>c��>�g4��g}�z�s�����t�yw���*>c�����
u�ej��&��5A�9jh
m���9>R����J��f	b�������+���E��i<�����/x%s%>��Y5@^��'f.qL��.���a��]X�m�'���
n����������.n��y�s(=v��K`����8����j������(4���!��2]G�/���+s�@.uyB�W�1
���)��?Lx�T�<��	W�	o(t����,��H���d�'3��3�)��G���J��|���.D"
�C�6lMpD�"*@,G#y�8�z��I�_UVH�==��V�����������~~@�q������mZ����9��:P�E_��bN�9Ud�p:`�I/,&+jeN1��)�{n��}���H�^�V��veeue>��;�Y�-�s5���j�$�6�I��2�k�Ji2c:`�>V���+���@�����$��3��BE�wP�'���������;���.p�g������s���y.�n��;
_����L��h����1&�������G9#b�@34j��l�e��(�g��E��h<�<�y;�C�w��q��mC���1��7�#�����������
�8MBT��@e m���`e{��|;as1t��"�vT'�2������$���5V_�0�89 P�XPBd�)K��������,�@,�������pe5M�(�@��d|)N����q��P�Q�y	%����4��LL*�����)���	@$�n)['B�
�~�9��S�$5�T�w�J�����L]q�������m�������������8�(R+E0�CG
~�e���-&�?I�����v�,��z9�����nR���5=
�znm��*E�djz�����q��_�e"�nf�J���v���}l�B�3�2���F<����R
�fF?�/E�3UJ��05���sj��i�P���{�Nr���"p����v������XG;rh��,>�1���|�3?��v����|L���k��q2�.���5�6U�	0�����R.eT!��������{�Fs��������<����HZ�:�|���,!��!K�
f��?�`w'��3m_8�8�C�����V$��3`����y:����7��or�\������(W���K�c=~Ih>��$�
�1��	� 'd\������H9��W0Cp$C�<��V'^hgw�4�@;J��8�����&���vr��/ie!xY���l>�2n��i��j�qu
�7R��K�v��`D#&@$��|`�=�v?|%��Td(L��r����$UE}	���2���.��4?����T����^�zH�&<�?��#��f�H�G�*(��������B`�B)�W����`z��x���^�=;���}�����z���L96#��4���:�i��f�I:�}�4�9R�2�Yp�yb�'h�K����rbq�0���1C�<����H(�>s��\,uh	� �������q��
[M�L$0�F�a$S����7�(.�I�D/i�1Kj��	���(�=�2ot�%�����B27�5h��A�X]IM6�pbd���p+�K�TkGHa" �L{d6�%�$�[����T�l��Z�V]]��we	-��UoO@P~�8�����N*������(��I0���|X��#KH�/bS^X�
���c+����0��H�A��.���WVoHN���D����UKAe���R��BV�j)MR���_� �.$������E�������?�8}�P�;2��X��Nu^��`�(���Tv�*����vU���|��x�8�z�����������	������0��~;?�x�[��������,M��&n���!_�y:M�5��+�N�Fk@�4��,6����X�0���#��#���|t
Xi�'�-|�c�`��`\�JLs��C\%�Mk��b6��D]�$-&��1
�K�����j5g��
7��p��s	���(<aH.J]>�����UQ�ZC�v�q�B���^�G��w1�!iLi�2��0u�=3KC�@��%��[���j���|�P'���������
��I�,q'��(�.�5��������c�`'-�n��Z�0.��������V���5����f��{�1ifJ@�<�=��DX�'?n&�JWB�v0���k�~g��B4���B�����{h�w�y��m�x]jD�muw?���"Yq1��#�'�=&��[�:���9�(�d���2�'lm7KTt����Jn���b�]�}1v���pj6�c�S��������7�|����}��W_}E�o)r��?�y������}����P��!MS4h��}�}�5kj�hXe\�8<�*#"��10����4�����wI�F_�}��.�����v��|��8��X�7#�����$tAq'.q����c�B&.v7�d(\�M�[\�YJ�!-�������=,�0u���Vc�Z�j9�6t�-�ka�� �*hO<������I9EH5\��b��$�
�=7,��L�O����(�[T>f�y
���T��A��� <��E)�p'cd������������LO) h�d8�ei��kO��n_��6 9����QM]�W������Hp^*}��&���l�"�[p��&*
�<�_ij�;���2Ti�9 �*�^����F�`��f���l�#l��cF�1'�D\��V���z�7bvy�A��@O���e���z���t��&�4�����g�g��]~��}�6��h�����_MDz�]�=K�������[)��*m�3p�A4{������Gk�Wp��GV�D�,-��y�S�k���h��W`��z� ��V[����l�`�R�%��9��a�!XS,�K,��C���pFw^�[��j��9���F+k��
�������������p���Qh ����kq,��Q���oJ�T�����TYM��
Ma��A)U�l��n K��I����<0�D5��[|��@(S}������9G<�������px�2b��e���v:�e���&E����5�z���	<C-��%	�$+�s`y��Z�R�tQ���s�uy��H
�����|�,�'�}$_-���l�f90X
�vs���+����L��	_$�M_��@��p/���W-��#'���5	���		2����E!���,W��{�D����a^l���=�u����|�G`��>���,�,O����_���X�f�����>y����%���Y������>���<}�4M1����@g���`P�����kl����S��%
���6p��j��R�!G<�LtOP���}��C��.D��%U���i=���R
�3I@?r����nJZ�	�C�L&>��s�#D�D
��ZX�@�~��������d�\�]�Y)'-�������_�N�����QP�:A���vu���j�v��`�`��b��vj�R�"�tyM�;RY�N��ev��y���K����8�t�G�I���+M-�Y+v�����9E�J�Q�6��-3 ���}:|W�U dG+�h#��a��%�?����=��h���&'2�@�pD��t�u���`��|�+D��>}��=���l &�����X���� �7��(�������L��������v�_����>��o��k��>���|?<&����?��?|��G���RH�c���4*	+�|'��	����b���D�O�6ti^"����ul#�P�GJ,��Zl�Pz2�,���i� ����2��������)�6�����M/����M�����o�x���V����#��dv'.������f�9��sa�m����6r������lH}
>�6���e"�l��������x�W�uW����2�,w�Qjq��)4
U�I#`:����
V��cy<�|�]F%TV=�j���
{k�������Z���*��]���l!q7�r������N�=��������(s���6-�j���.�U�`pP�z)�`�"��%1��w�����'I�L�h�K!�Y���N7�.B��:��9���JB�itm�Q
�?�	B�S2�&t�B�#��	_UD��a�Z[Y]M���Y�-�V�\&�4p��j��2?�w����x9]d�n��X�[�=���S�Sb$%
?�����f�0�:<�������s�z��1�x�����8
����#Z��G9�
_*�M��l���%���p���	=�H�M���2m��G�|��'��[���q�7f�K���w��fN���5b�Cj�X�6_+$
��|`���u��K��Cf�)�CG3���T�d�\} ��dN����HHE�8*�^��W�M��nu#��?��I�s�b	�����{)��$�Mm�Z�F9�k����m���JT-C�1��eX������fj�thiz ����;08��7�	���L����3���"�.��KJ6��O�$�
0����%����
�B+;������F/D-��'�4!��j�I�5��0X#e�P��������\O�"��)�t��[7�a��L``������?>���,�hfU<����
�����BX�i��0A39�����"3�h��M;�����0����9`��+c�����n)�H[��?���o���vs���1�3grI�s��������@���J_���zb�iI�i�y`�v�~V?��C{���iX��w�������g�L�������~���3�z�1
w�������XG�4#�
��0������w���~��j��4|�����'�1����$H�|
�%	za��!i����V�9^�2��Z���������"��7���
@�3����(
��HucBr�:��5��*h���Y�W�@��[�.�l�^��@3��FN�NLf�>�������^�Q�@�pd�����4�t�@��TD>���

������E�d9��3����3rT��jPSjX���yC+�N����=�PI�DA�XgyH4��?�!#��/��,�	v���T8����I�|�I�!P�[�F_R��:��cD�"���T�K�4v�iG�	X�R�f���x�Y�`[��'@����&q�^�UdM�s����Kh�6�,���o&��H���/��5�#g�t)
D�y<����n�/>����g�M
b��PZ����^G-��#������8[��2KR�
�n��,p�+(*3���>�c��
^�}F>K��:���^���z��A8���������
L����&���)�Y����!&Gy���q����z+i������$����������!���w��b����$�1c��B t�Gi��l� M���l}c}#i��=�\����w��y�L\�����������R�(.1�B/�&;/��xR)���{�"o^*xW�
e�V�g�A}vqi����&+���(�@Q���Y���Hy�B��YWn��5���2�Bc�GA~�����.��9���N���T���'�$��"k���A|���KH$.f�'>K��"v�@�pfQ��Y4����4�q���U/�$����B���'57tI����C�>�4���$-}3i���G���4�4�?�����W],�Y4|-���>)Bv�Q0���U��G��T�%�0yC�Q�2g�'�-uA}�[����-�X(�K�[��.�vw �$M��?�'{��bmT��
b�uGk/��������+��&���D�^�=3���}�����b;�>����.�h�^��u���Lgq9�o&�Px�|���W�^���L���'�����������.O����.�0����~���������������
�����K>>~������V�wy<�z��|�9U>����|�Px�
��C{a��^&p����&>��`Y���>:���G�����y��\D��|�H�az�c���/_����z�G6����HZ����w�����}y��������[w� jwwo�V����0����N2WM��dw�`v}}?�i�mj�oUf���~egog���ou�ko��������Vmf��K��Y�W���z�d�}��qw{ks��=��i�z����]���(>7?��h��"�[����Z������=���t�[o*��m����m�_��^�5��x�h�X=������~�������l}�����&�o[�+3�F�������xk�:��]����t���_��|����< �����jg~}���[\o������3�|�y��N�7��{{��j�R>�����\�����w6+<����9������)}��WZ�N�pwk{��8��W�k���K/�������a�W?����l�-U[���~�?��a|�����K�vo�u��=\~���z�h4a;�x��Vko�py���~p�h.�W�v�����������T��f����bG��<��_i�f�����:l�.���������fm~q_�i��a}�Nu���SnC�����Wgx�pvf�Z�{;���>)�/Q���k`�A�������Oz�fka����~kI�}q���mv�����k���s���n����n�fj�����io�R~���~��Q��v����m�V��������Hl�M�U=������;]�N��1�r;T������]���E��m�����up��_�Vj��������L{o����^�K�*�����7�;��������?v7_6f���n�pk�1_Y����������z������������H��UEo��������������[���������%���L�u���o?�Y{��������Vmq��=�zl��3�dsk�:S��m��3������o��u���K������g6_��l�-�����F��|{��Y�}M�K�����F�����������_>o���k��W����:���U�b��k�s[�u��mo���~�[{�nT�����7�o�����"��c����S�>m>�)���z���G�������*
��<�����|�<I~��@O>`�8_�����6�az&�%�3�c7�yFO��gb��8�G_J�N��x��?"�KN�04����9a��@O>=����=1����P������L���,'��������'�v(����4z!�������s`!�"���<�P�[JOo��x��P���pA&��%��u��g��������G�9������,��� O�������z�5�^�����~$��\N���@� �>��T���5�P�I�)������k�������Kc���������7��>!�=����g������ps>4

���z=�_��m,6�&���~������)9�'�������EB�c�z�??��>�H��������u�o���/�Tz���K��.,T�6��<y3��23?��J|�X&���F���<�m�F���Rc��mU��7*�J�W��6tX�c%�R�������~o��;�7`����,�z�������Z��[�6@����v�����Z���j��xucq�r������//-�m��v�e������`������<���A}i��W[n��^To��h�T��Js�a����L/�~��9h������e��kvn}�mWz�z������5�;���wx��������{����*,�sun��SY^Z�/�js����>7 f'(�V��gj���Q�@�3����v��i ^��@qt]Z����
����5����i�Qf�Vo(��uy���.��Ju����� �y�o.U{�%�k�5�1���������[w��4Z��<����j�X�zX_���z$��T^>S��4���"�\���,��g������&����b������
~�nST���2�-+�m�s��������r9���n��[���mVz���,/W���c���B����2?Wa����<�]R��������E�����fk��./;VV�����{�N�������WV�w�p��28��4[m.������R����re��`�6���_��Tb����W�&O�B7�q��^D@z��y}m���!18��z�]��-1�U+���Z��i��n�J�^��%��~�mH������E��y��on'k�}Z����o�^�PoT�f�xkI�����z�I�~��;8��+�Z��~c}Mfa�kO�����/g+�����3�����&�MdH��^������&<���i��'�������z/=�� �	`@>@�y��Q�czz��>�s���H8>6��a�s�g#�O?�u���!��~t�����������0d2����]
����i��	�����|�=��9uy�����9"�����}��azX
�M�'H���9���;!��b���s��o������F���R���
�_p>��D��z��d���Z�M{?~#�}Q���`�-
�X��7�V{)��b���]����VY�z������zZ8�Ia~���Z5���Y���wT�hY����^f�[����5
���|��Q�����~Nv_�t�����VM��He{}�4��B��KR
��)a��������sia���CN������~��jPo�VY�Pq��W)�R�d���(^[{p���I[�J����+��M������I����>������v�U%����$�>$� y��������@�!��*zLfZT�8���K�C#������3��>bu[��?L���<�ME�y���
&X;���
�(x�W��v�G������H��@\A�BBs_b��'Nk
��L��f��`~�
	����M	��>:��#eu��r����Mxt�Ad�M�YN�����_j�*-b��{�
�6B����4��������e�������j��56��+W�*�u�������f69Oo�!�
�7~�+��{�z�@dji����K�����s������..�C���M�^��J�����~UK��lx�%-�b�X<FP�0���dF�(>.��F[��/��=�``^����#����\Y9������aJ������9	=EY8 ������ao&�J;\9��p���``nSE?���K����q���p��Zq�5�K����#�����z7
O������X�2�����)#��b��h�g���h����Z>a[+0 1�
�Ea�B��TV$��'&���9�H������Z{�n�����}���	����+b��#��F��@�r}�
�9���8�2@/�������@���_���f��]���'�:g1�;��P������w������Vy��N-�Di�5�2H"j�#0i���aCcV�}8�u>c� +y��|m���%��$�z�"�����i�*gb�i	���l� ��a���'?�er���9UtI�&���y���\L�%��\��#�
��^c�j���:,���ss#{��v�,�e����Ga(1��5Q�=P[oP���"�
B�r3���$kP�|D�^T��6���i�~��_|��)�� �%B����J���4������m��p_���B�j�Q��;�`z`9WGp.��Ty���s��W����������^&�����f���*��4��}�������x]��b��<���������L4YZ���yi�b�KBeI#k��[I4��e�?O~�@D7�������)Y������=.�/l��T	!������@TI��dC�w�!c���'4���������A�HG���V�.c�&4�%	R�
K�x��z��Eb����e�Y�tt��Kw$Yj�'��Y����������G�����u��<?� ~R#���8���H|��K�GJy-����h�	����l�"yn_����Q��z�
�M��{�_��)����%��t�����[A%�h�uD�GOfX�5�>���m��v�F�U3��@rSJ�gue����1;�E@"u�
�ST�����#�z#rr)��
�0/k���I����^2�(#�r���a+U��O����l��y�������J����Z*�b��C%����4?��z��#�G�����.��7M�=_�<gW��1���)N7c$
��+"�Y�C��q�,��[�%u��qK_�r��!H��	wJ�x���f}��8}��h
����
<��s�I<O�\q��\=
�@��/���]l�d0��0I����3��|����V3f��	�^X�_2C���E]��i�uv���b��}9���!�#���*d����2 �,�����ttB�\2u��o%�@]��j�k������B
���r 2J!9P���X�(�x��)�&��B��<�x��?���

���OB�a�,�v��
������o�6*�����/e�yr���i�Eh���J�IY��Z�-����=*?��_����l�N�l�U�m.��`�.��6��������!j9y���<�������E�F��q������>�J�y�#{����q�����dq����"
�@Zu���I�9���W�E5[�(�n����cx8j�KRg��s��B��4���P1&UMs'���8����
����S���4�Zb�YU?��W��Id=/_Y	�,`�(y����6bhd��n��x��sI�	��|��!�cf��jd%��|l��p��@[�@���,,*�T���K����6�}��S�����e��H1*����K)�h�+E��,E���L�m�km����)�pJ����S�/}���?0� �6�c
���?��|#�	�b�&I���6���$����e�;'.��c��u��9�{1 �+q�?a!�]}�rdR+�>�����[��2�'�`DY�/Q��r��wT�g;,�����7�����m�m���tA�Q��"n<�w�v5����ZU;O�9�IX����d��vd&��J�9���y�X���3����~�;��(�
���/�}���j��G2/�#�lk����*���5��~/%��W�����TNx�\��gjbx�
|���J�&T�w�������B���!��<����0��>��3�������"�f�&�yWw��Q�4M1��2I#��UVGE|s�P�C��81�3����_���4j�E��K(�2��w�����\:f\�2Bi��>i���{~:s��K}Q��P~�U4.���lS��!�`�!����4���ah&~��*������o����*�F��p?��Syj�����>&YI�������G;VCr��b;YJ;�c���v1/~����T[|-�M����zcu����fOV��,�74.����^N"-��E:Ht��@�a��uR#��D�aN���9S �I2�iG^$�%xh����d�M��$�G�R��*�7K�j�xla��u[��mT��	�Ts5�#
�M����z�5�P�F$�Ym>���`"�C(�F��v�q�"2;43������X��s��;;��j����)�-�"�i@�		|���D�����h���Un��7o��>VTl��)�~����I�ic��S���f�<M�2�����F�2�Y��uJ5�5V�;D7_%�|f���������������A���m%:-t������i/�A�
�v#d��*����m�[��W����y���\�!!��(e����8n�'�s)���<P�#�A�XGV(K�x���j�����l�H���diHRJ{�1��q�2>�|���^���8'w���@$��I)-l�zN��VK��M���$�`��+����e�B[��X��� �s?y���=�����<�
��;p�l��B��w
���6cQF���H+���|[���tB$W]
�����fN��lO��$o�>��(��nk���C���@����yK�����]�������W�;$J�,>����C���&��i	�@�(Y,��k7�.��`o/�����,1�2����.]�_dc{�d���`��zv�]��a�sj�����M�u�c�s��f`���A���.S�L�:�i���)����m����z�
?��r���pn%�B' ���]��;	�8A�2����L<X��|H�/{DT��w����r��b�-�RE��b����8;��$xL�H�}���Q��p��`���~��Y<$6�)
�fHt#�0L$���[��W)�4��#��z���TK�@y�BT�|c[�"
���l�L'S��}�j �@)����zsf�
����N��D�a���I1�����������3s���^|����8��
��F:��b�~�/�����)��$���{��k�`�����l!�htb�0�
2!��%� �X�������->��,��J�d��q�{ 'RI�(��b15m>aU�$z�{V:����8����i�p�D�vV;��4��5	�g��[������O���d$E�\��Y�Kd���O�1]���nFP���ap�i=��.�N����X���~���3M�N�(�l�r�y+�Tz���1<��!�:1@�tX5h���VV����}i=�LC]���4��=N�"@IDAT�n�v����F�{<t�����I��������<�-0j��.Z� WD2'7s*������K�W�!!A��x >����P@�g��?L^<N�6e���x$�p��]��>
	3��	�������a��qDAJ����t��9�����?CP��	M�z�`��u6n[\���~\���y�z2���#�P���}�?������Q*�wDR�Xf��86��,����u-���WlxL2�)���H�m6���b������h��]�Y�v����S"�59����P�
KD���X���q���M���@�� ��
�&����X�z�������B3D�g;��w+Q]����$^B~��	�2:8M����]��O'��'�8��#�HI��%����<����c����:��@�{�9C8x�f�W�@s����O���1���~��i�!�e�d��V��(�=����o�\������v�^��by5y��n���
�p(#��
�L\ud��q��q��
��m������9{��1M`R~�3yb��L��C �/�=�����$��'A�R;��R���?�k����1dBUD����v��^�F\�����
^
yg�Bk�z�g�B�g�z��*y�L����Z�>G$jA#��]����DZM�'fI���Lpu8y�<�����MW�yW�S�f_R�>�Z�&�>�t(�mdC����l��[�J�E���Q���%�}a�������#�w�����q�M���m����O�����5�'�!0��c���,�y�4���`�C���O��Qw�Z�@���cg\q�O��u����/\D��}�/��G�����jF����^���WW�SJ�����|�(��1� ��p�0��C&uqU6�V�%�S��b7_
i��u6�����l]���kI���umfG���'�nf�@g��(4N�@��k��)��rp�	�f
����	��jB�rY%�(w �D)D�;x��jC���_��m�%-m��F���\������j3�c�#8�]x	�p�W�D�^lx��|P�g8`�������,~�c�]g/h,�m��Lp:�)}��Z��I�h�[�H}D%�b���7��]���
IE��%U��Y�R���,C}h�K_v���!E�$om�]�u�������M����R��)�����"�����1\,�����@�C�w"����6��!Z���$4/��
Z8S�]#5���
���s�*����>�b�z��������8�r�mtQ�����|����ZR�h%��'��Uv�5�IS�>������-Z0b�d�d�v�Xld�Wx�Sa	M��FVK\���������S��������"���`o���
-�[t$�M�o���,r��^��O�l��	�X�((Dn���E_���i���a���{��	���+P�8�J� #+K`t�>f�]>��R@��W-�
.��PH����p��o����Z<~}���,��A�1*�28=���m�E|���p`����������a��TQ��6s(�"�8�a�"+������}��'�I�^<�q?�
Jf�r�;�@0e�/E�MHk�=,M�.zi14)�Z�WLHU��������;���
�2�,�0����G&�En"�Q`7c������c�@m4* �"��9]�NrV\>��f���ie��s
(���tZ�\Yz����wZ��}���������\>��Y����D$��p�W������'�W������/�:��fv��a8��������2u2��k������t�J�O��v7)�_K���!_����'#	���K	��r�X���#����p�7V� '�1��#�9�G��

Z�q#`�-�"3>� ^;�d��!/R�2I���������)��������l�};��FAPp��B��S�b�e~�l�@�vX[AGr��J��v\������f���-"��y��_�t���z}~Q�����MKb��|2	�v�	�s(�Qoz�����tF�I����M�Ef��6�O�6W��|�]���LT��^`���=[l��%`7��O����Y�}_������?)a�H���D*�����wn��5�z��L#����'�yhP�)�"+h�*�G��%eY�(���e��/"�jC��}�q����-#�)�%"��	���OI����?��O�����jE^W���gss�(����t"�4[
��w�t��~���+x���W�M��uH��&����p��s�8C9G����l�e�[�>f/�1�����Tl��
yU�H^%������u��
�2/;���ltbh��}'��'O��[w@U��r|F>B*�c����/��u	�v�������i*�cA�R��I�a�� �\A�&����'�T����!W������=8� ��v�Bi���������X	3�k�Nb�L��V��T�PI�J�zmfu�p^�k�	���N!Q�QVM`�*���"[�\����d����Hz�G����opf�!�8�����a5�����9�
�������[��A�%bH�6���J�2K���-�] ^���[������`zTa8,6\8�=3���i��6��]������������z��r�m�,����\����
� �������t�<�t�x�:����/STd<S���|]����������}
���R�b\�)$�FPv��)7�|��3�>��x�v������0�SD�p<�E3�
=dx����_xEq����C0�?�@�H�R� 8ha�E����g$y0e?�����@�#x5v�-<��>������v��a��������[�
��n��A<`�(-_�a8dp1��|J��/�EF��f�aA��=!����Q���a#�	���n#�3>�K�#�`�W���h�Q	�hG�6k������l�0���h��h*vw9*�Z���K���G9��lhx����!O������������S#�n�(�qkx�����Y����c��3`.�x��|����:�O�Q��q�]vn��}�/���������v�����>�G���^�uH��S�t�t@��0�)4>e���l�h�hPy��a#.5t!���7����U��on�J�1�������<ZP,R�|�~�U�����P���T�����N<��5��<�n
rW�R�G$Xe>K�@�[#+�((�z���a{������#i���<��P1A�D���j��C�0m���@��&�|���T���T�4�R�]��LdGt�q�p}�B����:F;�aN�w&�9*�������d> ��{�(�|�"d�|���0E�Z(��2x��q�����d+�����q���[����LJE��d����Y����f����@�:b
�B�@G��w���z��Lw��}�i�,�9�'wh=����e��}��&�rg����i\����h�\��48��Fc�Q����\a� ��q�\����L���b�cCi���!�����4�����"i9�%2$`���N��EM�+�������Yl��Z8�P0?�,91
��yfF, �aPA��^(4/,�B<��'������f��<T
4���Jq!��T���$�'M"i�\�#�X�9	�K8xj3�Y���{�6I���/��{�����J$!R�%���������8�L~������+Q"E @b����==�Wu���w"���2��k���O�Q�q����'N,,��DZ:�*��Jy�S&�D����f�eLA��$(
�����q`qy�X\��Am�<��j`��)����2��+�?��N������FZZ4wjA�u(8+V}�.����Is����������WI{��1�fV|'M����}��>Nz�w��q�I7�^��22N���t�-$]jH���fB�D�-=)"�
|��0{�}�Q	��Z<��]>�7�j
L�|�������B"�I��p�##��@#h���Q-]d�D�I��C��2��_e�^!�Q�x���x�$����Sge�7����7���fG�m��E����O�.NB�(����\2�Y�1,N�`(��I�cP�h"BvP����D�D��+��ku;��U����<�,�uj-T����F#��Z�#+��nb�����dX���T{�d�Wf'���M�
Z7#����x��h�z��(1i?���S��[i��S�/;�a�&z���&�=w���k;�sW+!���-[��:+ZF�Z�0<g=88�wmm--�$t���PF^�G��Pp\M�9�05>���b'h��O!	4�!�X3��	���l���2�vx���e�&���!�_QR�ri`����~����$*
73b�+���Zs5%�)Z�Q��U��i�+��<1E�@��
�@��]Z�Ea��$�J=���1�A[5�)[d���;����Q8�D�?�y�k��nvD��N��3���v����Q��}�����q�&~uvpH)������y�u�k�v���jujV�<6�q�����W�q���� @c��EG�4w�N�J��F�������F%��w�f���N�PL���P�ym:��1:���v�gQ�i�PGcQKV�`!{��-�����g�X�����.|����/_�z��X)
	<l�m^?1"�+kc��x�{e���F����+|�s'�g`r+4E�#F}�V���DL��P�qr*	`�)�D"*a:��{4�r��#@sI0���O"���a�'�"��xW��Y�����7���e����i;����������\��Jn�/0�wf.�3��
jTwA��o�!������w���d�seC��p'�����1&�
K4?~�u�TPU�BR�b������c)��*����dX���Q?bT$����]�r���+o�Q`���v�A�quOq4�z}���h�N*�.�;~������i���t�5�'������lM���1��7�5P����G}�Z��'O�y�}������4����*�4��UN3�T����Iv�0b�C���LE�]AQ��� ��@ ��a��pt���p,,�Ff��W����'��b^�<�
?"EN����%���Y������X�����Pf�F
^W}�x8�����~��,t8f�J��������?�WBp?�l�Fu�Q�7*��� 	��N� ��"%�+�	�-9������>��).o�K�G���^�*�I~0dNi�{�X�[25U��ju)�����r�M�>�y���eM�
AQO���~�t��������Q���h�� S�p�a���Q��B�
�y�=�����<1p�����R��7��k;�	�!�����>|��	hf�/��< E(O��=/�(���*�� ;�W�$�����Z�$t9�7�!pp�0�<��HFG�*��Bd�SE������R�Pxt�F�F*P(,)�+h,E�)V����Yu����r�����w��'�0W}�2�B��������{���=����r��Ew0>S�Z��*!p�����d���5Y����C��������G�	H��t=��,XNt�2C������.:Bi9�s4����A��,�t�@?CT��N$+�6�q�?�S��@�<@�5n�x��<�����0�#<��$;�-�������8�y	�%���/����������C
n�o�[�����A����X�����U���C�Mr��)"r4�N�v�N:��GK�v�r�_��
��(>b�`���=�`)����.����9A�Z�h�2	#EN��b�;����\zS�co!P�����1N4B���'���J��P^��t���5����Y>+�5�bb��T���DKE���������1(|�D%bH�R��.������=�	Y/�3��E��?\Qq]Mv�z�����q
D����������Q�N������b�dLT�0����F"��R;S�|��~&
T���DH��k�a�e�a�� q�nx/*�=���C���R5��@�~5�����cpHPX���}���
4�H�d�u0�}aC?D.��/�#;�y
��P�&;�WI�Q��At��@r�@�R���kC�N�P+3m����W��*Z�#[C�f,@�(G�8�MY�����F����!����
�)R�g�P;�e��w�	�L�r�f@�1�:=r��������|��a��/�d�@gM��%/���)l�����*���LKc�<�Y����"]&�Kx�w��m 4�M�q2�C��a��}�(O���u�b����Ncc����7,,OJ]5�X�	���K��av]l�A�;}�Lc�R[��I�0�x�J�
����vT��t�,'�)��yA?M��c����I���?��p�q��
���:������p��5��),�=�6D��@o|/�u�s|�'��$�:�<'i�Hu���v�t�,qIl������2��D�	tN���M$�Ll`�b��)	4��)�NN2��������~=T@!W�q�8f�;N)1����%��
�Kx�����9AYh��Mvn-C�ip���nw������zV4����a����k��������+�S$�%@BQ;�*t��
Z��)`q�C��IG��A��E�T*�*���f��Zub�b�}����c�ini�P���cc#�9�+��VF��&�N.bh��Ia���[%��(�Jn��6U&G��y�W���#�`4�%v���UCt����$/��@�e�t��@�������`��eZ<@��A0n ��D�?���u�!���_>����yW�A
���<��}
~qP����������'���>�IS�:����Db!���@x�)g���?�B��
��0?lvh>��,L�2�?�@Kj���I�<x��?M�}[����|�h�y��d���ne<���Mc�~��L�H�u���9���i����VJy�	C�����7��4�w�������������8=:�S/d-�Y\r�sx�~�([?j��[\2�������Nvu��_:��}a���6��[�3�[���4���I�WZ��l��?�����.6�>�iU���y��������-�������z��"�����V6o/,��&�������)�k��i	���K���L��c��p�\n���|���7���N+�����[tO�"�f7�F���iI���R�#<0,��t�!#��_I���l5�3�\;�'i8�������J�t�����'���u9��$��z����nz��v����e���zT�K�^i��}h6�s�~������Y�-���v���M�����]X�r�!�^�X%I3����~%E��F��������1[������F�~�&I7�����W�z�QZ�(|E�z��y�����h5���hVr��\f����/����Y�����:�m��o3Y,/[rL�r�*�
��>��N%|W�2��8�_�K��px�J����)�g�l��'B�R�V����Cc&Sz:�HI�^o������h��3�A�3K�$�t��	�?��I����q]���z8�X��	'H�
"��KRP����������LA0Ng�?��FG�J~���S5��I��B&9
�|p��4��������V��S��.8rMO�l�H�5B1y��B���
B*���)Md��	���H��O'�����LZ�5����^���&>.��1���
�P��I��N2��<������������blK9j�q��D��0.A��1B"��0R���~M��T�bo���nJ����E�k�[_��:��(�L4*�X�����l+;�8�����=�	.�
2p|�B�j��
*h@`�8weh�������:(�H�c���^�nW�.��y@����z���l���Ax��Ozdw�����nfC7���"�;���/yQ�x�#L'X���}�?_$���xa:�\�G�N�`��m�P(}y�;�P*�G�*MW�|N���0�!�m:Q
i�S�{VB�Wf2x�O)�N�'����)�0c?!�G|�O�����|z�az!Z�!���j����/^g���\,x�����!��hAN��&�BdM�� Zu=�_Z9�\���T��.��l�0�_��\>�'�����������r��X���xMl`�$�$;��T���_����� |�?�@v��-,��d����������o�����'�|�j�F�+���q����������������q�k����CfsYv|v���2�|���_����q����*n����QZ6��'P;�v��>3�x���5��%�?�������KX(l=4��R|��7���1.oDh$�r����2��������{������`�,m>0�4.^7�J�zgI
�\�M��z�;a����
�+ok��~�26����&���eT���HD�g�D�O��K	<`�m?X;N����������u�����N�������^r'Ji��\�NS�m�����rk1��GM��L��9k}\����G���r��27�7�~�{L
}dp$)�5@�����'?1�I��?<~,zV�e_�d�;'�������E������=EgI���d�X���g��!(�7� �D��l�>z�_A��e �G�B���t$4��z$�e� j'A���L&����u���Fp����YI� �V8(��sY�6<:�����n�������qE���!0�_����������������/�7������D�"+���NV�^�U/���`j��@��#�����6��t����h�(.#��@GN�������S������UZ����(�lz��!�����Y�lq��E��4�+�e2}�,�;�����vi�%7��x'��G"D�a���\P��0����m�����$����7E!��|z_�>��@�����&8�@w{�S�n��I��J����������f�0~��<h��Cf�S����sd������S"��,p,�v$�Q����`eR ,7��X���D��[VqR����W��0;����SJg�z��Ic��~�9jg���2(��K5�-��GH��Ob��<
����d�X_*.�kt�_g��z����f��t@�sVr"�A$��Y��QC�WJ j-G�����6���
�����`��9+b70�����W�~4�x�L���9�-l���+^7^��Ye�h�*��$���O�����!��)�<=v<hor��g�G(y�|h2B�A�+I����y�'f241:��(��$���#r��f/�>�W�k:����*n�c�>@����>���Q�L�
z�����%�T(P����U�	���y);���{
�q�%�r���af�Fv����3LH�)L�
�����rK7�/��
����t�����G�	A����a-q�����|�j^�����H���i�A���a�0 ����������8�"Ov�5qB��8��c��q:'G�Q����D��
���u�s�K�C����Y����\>��2�/D���
&��y=0����!������i�1������sM�0�$�D=��(
d��MC
�����[���nP�u��b���������2���PJ0�Oq`�<u�	tVQ	��+L���
����8�7)��K��h
�h@vf_;S�8NT����Z���L������L��Q�����o���������!�����$�:�-��0F�F	�R���.�*�0<�2�O��I�)35�C���G���#`�n�!Q��s�����:]8�O�{Q��2�B#��b*x�$=���U�A�0%���52]����,j�{s`(���80jvBU}�
N:� �S�[hnllD�K�]eWu��j���P�uD���S��}t���IJE�X��'����I���8�������S�O�@L�,�:f�S*����a���sf)�(a5��R:���M�jt�%�'!|]	�ipnJ,2�C��������y�`�D��d�W��d���x�$�l��h�������Z8��g%~�����)��E��$��ro�_�q��4���q�e���P`pc�f|���	p��k�>��fx���G����Y�i��\o|��<�������?��5�*(����CdG��? d��;����7:��$�$;\��?VS���f���W&;�����'^c�-X����S�I�d�S
C�L����H�^���C��������!=W,���H5�@v���c��4S������_����K���1��-�^�Od�:��a��x�^�Qbc�2��--kq�^����J��nF�b��zJ�
Qa��S��T��'�O���F��IS�����ik�C�����b�(�Z���j���z&��
��V����pE�����It��
nI�^?�rL-������~>if���Lv���9}
�c���U8�ot��dl���p���%�gbQ�U�B�H������`s��(�4L��3�qO�<��MO	�@j��([+�p<�B5�,��K��!|��d���p
������BvR�t6�W�O���N�FE����Z��Q�����E��������@��R+^/0,i��~�}���7j��G�Y_����f��3�����|cd'$�:���>#�=88`W}V	�,]�&���<�dg�]e�	� u��8
:u�
~&�*��O�-���R$2h����$���Wh�=e��/B�����
�u��o�&G�R���gj�������a[�D�JK������/]A�m(�n�������BX���� p���������R=���'�6�,��k�����a�~U���C�$
n�Z�qz�@�s8J�A:�`@���<���9��(��y�X=b��F3��+c��2���W?��e�H'����%L�5S;�1�$;�W�$��AM,�v�7�*#[+;��B����������L�pf&���xv�����P�Bf��)�R;�	��L���E��c&�'���oE)�l5M�LN�!�L���Qp,>}�_�}t���S�fz�v]������<�pHBX�C�'�)<�`����0�8��X�N���A$q�L���B�����}jE?Z���@�VN3���UZ�QZS�3.�q���A��s��7n(8�=�qr#U�1�����
����f�EwH`��}��Ad;F�/^~Kn��K�kg�m6s�����)Pg�$[
]����2mvL9�irK�:U�������v����
�#4<��p|	J~��cM�	4���8��Z�d)B��*����I!;H���N�,����`!3(\�6��/�_
�jZN�,b��4D�Go����y��.Ol�{zm&�`������#6c����";�����!;�WI�Q����~��N���0s���Dg��z�L��P}g<;�3������������Y%E�����n�r�f��X'�LN]/�\��h�-��R�#9 ��[�����;�3P��v=Li!q?��j� ������0��e����5ShF�����Y�
�
/�fxmzh�9�������������I�r������]�Y�:c�dj�)�yN�8������%��)(	�
��WO_�(�gz�$gI��yY���X@��Y�`H!;`>�� h�y�8��=���1������0�a��-���o	��b!���.h3�@k	t7�M�vB�ai�+�����	4{1�����Y�D�.��������=w�bh]���@�\���8Y��h>�cC���##?.qK=��!��}��T��g(��Y��q��@�,1M�ko��8we� B��,�H����Vd�;��]���A�&B:5��8��aM$��i�����K�)G�N����0�����fs��V����+�PT�']���y�
J�����O�Vc����=:�=�q��@��m�J�e4Zs����=�0���v���}n"vJa;1�GHh�!Z�����8#Z$��gm���yfrt��;�����i��^�Qbc;
vRH3j3q�J�CN���z�T'�B���h������QOR0hq�������v��vC���V^���fr��cX"�Q�#�;y�������(���xt����C���@�s-�5�x�*��-�y.�a����}~����������3��$l��>����)`���9j�_��B��T;4�7-eD�_�m���4��iNN�� ���G�24U�����h�NG-��jj�
��~t.����88':t�Y%b(�.��}4}���^�4�^/������@;~��l�����4?����g5?L����9}����v�����LW9�Dg�"�h�v����_�|���=��;��A�g�D��8j���@O��YK���!�� ��!Z�n���)�:lN�4(�r0��Q�	�R)^P�d5<�'��h�������Ot�[���� �4�
n5���r�Nl���������s��B�ymz����R#'0.�9��O��Dp��)�mTJi�'9f��>���_)hV���J<�W���T#jz�Y�p��=����v^1�z
v���8Rd���>%�t�d�@��p���e�@�Z�_(U��w��s������K����)������������������$;�J�G���>o�������}�WwM�zR.����gS&z��&�����\����C4+�^�����z���d������N�H�K�WI/�&q���Z�T
Dc������y�j��������/�Ld�Px5���ZZ
�sP{d�
��i�#�Nm���q���pk,y���F�����y�"���H��o��o���D(9�,_]��#�5�^U�{�0�EF
�g��1����"�{��O$���EF~������g"N-����"c����}���5�I.�l�x�s��������p���f�er$���>�Ot��3Vvf������7;	���� ��������'o����K�8?=�q
$��nj"��e�����x���Lvp���2�(�� 0:!�q���a��v��{NGb�q����J��1VO=�!s�)0=�Dv�B`d;!;�������m�����S���`eBD��r
;��,�����^��e�*�|�#E��a���g�_��-Q[KtR-]	t8@,�������$���b4 ;���1cW8��������E?�S��4�5�e������04�d)�@/�33i
v�i�4\@�����c-�N��m����AF��0{<I����t|�91\�1��'��h���n���bJL|m:���������4]s��Bfu���'������1a�1�!u����ec�-�������
l�[������*�&fD����my�G��hz~����U���8�
z�����@#��O4�$`;�<xH:������1s�Z�\�Z��=�W�2�h��d��\3�}�y��Lv&2uN�"8�.q�W1B������~�����5h�K@��b4LG�c^'�a���#�����)�^�!��TL�!"�������I���ei B{mz�<m7j��i��+ms����o&��(2��h98�����F]�({���&
Y�� 0zc�OhBk��%�V�1�PA��[7���2��y�!��j� 5|�R�����A��S�k��c%�6)�#;���J0\$������f6����3uRd'A�)���GH����04��v�HNj�(9�^.'I�� <n;I�RH�6��� �:�C�
+�1d�&�����s�Bv��hq{�9����}��>z����NI'�[��aWZ�X�#���N�4����B�v=u!� �P�5Z
�XyqQ�j�l��E������3igpc�&J��x�e2�c�z�M�e��##?�h��0�3{f4 /��
�(��k7������@cm���KuOi��Z������a&������o�V�Z��#�p=���IX��	�]��acc�s��g���a�O�
0��<E�)G���2J@g�+�?@Mk���c�5�r��&	="j���}g�������Pe����S)��%;�e��p����V�HN@���8��f{������ ���	����&����^7�X4p����Z>qOdR�b(�v:�A�}���U'9�
�#hM3#H�r��K�P�

���@��+�S�)��dl=p|zT�%f�����8>�CP/ �	�s,O���g�����v���	��0x!=eX���O8DH�0�|�����5���"j-a�
�<O�OtNr�]��������3�/�����#���SP:������>��VG��c������yH9D���p�����p�����?�/^ly��4��+�M3;�k����!#��:#���?U����
'(�A�2�Q���gJ�����u�A7�N;�����'����
t�k��y�Z�k:"�#L�?(<�I
����t������~
���5x��?I#X�4o"?�'<���/��"��T^�O=,������4�P��8��t�i���~`��}o�������H��?cm)�e�c���7�N.������w�����c���og\�@L���<�4��b^�O�����4��s�K�+7������a=����S���,��������1;�F����i"u>�SR�c���7��h@�a�&u�����\GV"���u%Rg?�OO�������c�&�����C�y�c���4������/��K"}������Yf�e�,6�e�=�G�~�&��i'A�$w	�A�NHP� eD�@�W����@�u0���'.���x�%]��<�#�����O�KLw��	����j���+3�"i>�
O�D:q�5H�j�����������3��Z�R)K_����q:�����n&;�������'�OC<,�oz��5}���%�		�3�x����������Y������WkVU����}�6�K�a���G���	���O�	���������)�Xu��o�����n&�����r�����Q�����b�u�'����8�t)vN��a�����*
8�v��n?��A���	�C�W��!��l��������=�����	����0}�i3�Iw�?�LM�g4��?����t����'
�lir:�pxr����O�;�1G��z��lK������	�P������4����FK��0�?�!9bp��N�����]k���j���� f������`\����\����lJ�L`qg�� 8��e��UYXr3�&:�`h��0l*,A��h@$(A���z�\���-�Jkw^�v�`%��9Q��"���B����`�.��)�OUG'�������Q��n�r�|��������
���a��@����|tTn����!u,#��V��M�zZ��F��N&��+N'�������8��_��5?��!��%_�~��f������\ ��/�)������V�>�L���
'��?y��_.�������m�����U���>�#�O��� .�T��t���B��'n��d�^�@b8d���$�u2�C$NG��y�>@M�~��Z��KGw
k&(7
$(�p��������?���Q:g��������������G�a\:�ox��������-g.�'�3M�0E=)7��g~�j_�s����������k_�l�t����N��������g�����G]n��}�i�>����$�;M��Q�����Z5G�D��$�M����n�|�O�g�u}�����3���N��7�N����#����$V��:����=o���K��%[��Bg?|bR�l� ����&���F+<�� �t���O46~�p�c��G���U�������W�.���1\,f�b.�89��F8�?���fM�P��c��i��A�D�>7���r��]zx����[g���$'��xz@IDAT)�/����P�0�_g�W�?��������o�4>�����������|��-���������X]5���YX�^X�];�
,h�_����#����Y�g�=:h}��,?������E����7i��4�]��������Sd����K�u5�]x�G���7��,��o����>�<���������b5�A�X�m�~1s�`���r?I�O8<C�5�}4�A���g���������b���Y����W?��0������#�B�����U���Hx��t*�����d��������������-7���%N,O�����0x:W���=!�_����::"t�+��B������������3��d�j�m�"��~8#<��C�N�_��X�E��G����o�i��z��^��px�C^��|
���2~���!t���b)^�#�7�pxv<+"*Y�L[
�����L��'>�N�0}9�E�}��o6�'����>Z�������m�G(b���A�����T�����9������uAa�py���l�}(����A����<�?�4�R�����������`y|>3�a�����!����T����������O�+5�{{^s�_���V�_�0��~"d�F8�?��
�oz���h������5��t���-[F0DgM@@}Rk�.�Z����?����]s�����/X�V8����P��Nx�<i;�,���(.hr:wBV�btj=3���e/]�!4�*����fopM��UHRR����`�C��p~C��tilL�Z��g�F�E�Q���x�!�
�����!����"��?c����Q�n�2
}]���{�r� z�0
Iu�t��'E��Hmo��a?�S��;Q�6�-%O�?(�����$�	.����_�h��D�����Fgd�cv<�Lv���edV�K����j�jM{�3hLC2>�'��g���7G	�J�g�%I_��8������e�QP����7�M������QA!�����Uu�E"�;�w�&�d]�=�
�{�J.J��v�
6���G�����Rg��}���MjM�L�h��5�ny�*��,w�d���km)��Z`L&�� uf�=�
�3�i��	�G����Sw�����^��L�1,�!�z�%��)������wccc�S���pt��T]�"j�����Eb���������� }���W�\����Fv���E1�V������v�DB��$'A9�������;��G����|&�����.FJ����2��9��gv�1Rnq��(�k������:��(����	�2|&;Zk�t�E�q���F�����Qr4��2qI��h�c�8�
��y�������l7��k�����+E�����������
�Y ��e����?��V�<8�8P�j�$#q~�q�}���?%�0����T�{���3)~�
�\������
�
���4��97*T�9�b�q��[u���Ed�'�HIp�$)M
�59�a��ad#S'�`j�P�d��t�"���a|�&�%Tw���}�#H�JlLW��������2�W�aO��h��Q\14��'4�
�� ��@|:sF���p�������<��|�68������
@���:3Q�,v���P��3�����F'�	�'Jv&�}�l�� �u����Q���.&GNC~5AvdS�t��6�s�l��:�A��K��Xt8l���q��`�Q;o.�&�v�(9�"'���-?M<���2nq&[&��k��8��I���k����j���M��������[����#��}G&7&��c��}W�s�yf-.K`1��m�����p@)�l�2m���aGu�lJ��h�{
A�����=���wH
mQ&�}�I�UG�E��=ArD��p��%h����wg����-�spK�L��F�<��=Z�{U!���s������Q/�Hoq�B���!�4W*�r�,B��$��0��x������;�N������������;u�Y�����2aKl�T"�0�O����+G��q�����d���������/��I����|�������<�y�U����bVY��� ��y�V9�n�lmw���o��/������Y���Z*����l�xW��~m��Jl��<j��|�S��\���J��[�S�O�@C�0Q��7�A�@Pk6�9��!�����+��	��G����@�2�������0dpq��:���p�*��l��Gp1<��_'���h��|�������Dg�$G������%��m#���9+�8�S��EU�\��J�����j>S>p����y��n
�<&�7l�2lH5�G���Dy��1%3wJ���n�-��r���`��Y�"H���P
�U"�}'<���{�y�
�@�:Lp�?���pB��X�@�q�y�
F
�7hG��f�{Z�W�R������'a���3e���v����+��/S������:5�p����ee�M��i0O�����h4����������������v�#��R���~}�����i����t�i��L��h�/@���B+"���X�_ �#q�C^p��2,���]�n�`U�U��l/���e}��RO4��G��.�����m���(�y�+�@����o�O���2�d-��d��B���Q����������������\1 NK�U��Ho�0.]�t�b,,��3!�R�+W+~@A���y3s����"���<�aCZr�l|��s�%��'^`���������,���X��}��q���n3�R;}TB�h�c_Av_G����|f�z���e��H���:�s������}� ;c9�������}Lm�e���H"L�I�&Xr	{��3�}_T��)����{�\��6���!l����9�D�yO�A�"qc~��m�y/����B�&�#��V�@Z>/������z�xg�~g����Z�Y�-����+=��J�`6Mw`��x��[&��U���L��X��? wwL�J�&��(+�p7�(������
�@u��H�9t���r| 9@�����"���4��K&��vvZ>2Z�U�D�.�0�����������_�����1�u���G��W���n([�� ;�>5I�Tc���Gr]�������w��m
�j�BX�"�%�������lSq������r�Z�{$��^�/%����pX��T���Gz&i
s=g��(L~$
K#QQ�����8F���r��5�����Ki��a��zN��m:\��2}.H�Z|xt�n��^LGH��*(����e�y��lH��`�Im���?���sgss�ND8�e��&+1P�?������3���h�W\�
�)%��;D����_l{m4::�X50
��a5�^^��V��2���]��30��r����H�PB\Pxn�0 N+S0~�o&I�=)2n����&�����uP� �~ .�������h���<&��������C"���u�@c��18Gt��rHz�h��F����`�o{����qG���
�������'�^H6h��F��%�H�Ol���f����I�W�8�����<�	}H9!��^d��4"��Q�b�������� ��_m�gvb
����� l����M7�k.��-��K����X�����$��,e�|����4�ZX�mP~`�;�AH���B���S&H����^�s����� 	J����[���5�������@~�`����w���qM�����+��|y���^;
����
�U�9���U26��U��AfuB�N�)��w���_�`�V�z�|-�7�<�����z��'��6����
�o�.2o��z��$��_0�-� ��h�%���Ei����*�����RC"R4�Pz4�y���@���}:�%��
����f5���B�Ja	�+E���M�X�P�@�(�H��0TX�Nn	����>�Bck7��	��@�f����X
�o*�W�.m�/(|�5�R��<px%-���:y+w6_d�j&m_�|#4E�����4TN�J9w���������fc�)Z�r��\����rRM������^�t	� Up�h#�F�&"��+���&���T�����9r(���t��B�e����D����aLCK���#���P ��x�tb�lo/=y��
y����0Y��f�9���������g��?
B����"�hW@<��8I��k}t�C�PX]Y���@D�����T�@�&�=�@�8=/�������c��\(�j���qH����gS�lg����j�}@�2��+�l�=��	�G��c��EL����E���k>�X�I��A�X1��,���^�=
:�wt�9����Q�s�St*�`a��>�_o�TE���@�|h"���s���4J���-�L�l{&��d�lb;��������}5�����Bp���#�]��=B2�?�{_�����@M�

f%���4�D�a�!:>� !��z���#��K�J��Z��.���H���w�l T�B��D�h~#���R`1�@�-��)�_�g>=���%r>��;�1� C�����-.�P�z!�fG�?�n9�����*9��8	�g���1~B�%����������F�H��YV8
fP��)O�H	Sq�����I���M9=U����p�����
H�W��R_������"�&=SV#�N�����A���J)�������8Qnp��(���HR�7v	����d��ZK��2�9����W�L����PM���I����n(�y�K6��=����we�;�*�:u; ������y�i1��pu&k^+�����N	v�������"�;YI��X�v���b�>��9�����m��;�)i�RJ�R����$��oAAt����
S�X��N�b����G��!.u�4�4X�^-r�Q����B��}w�I|�Tx,����W:K�ehF�/a�7/\�x+����)��k�3���./�A�����p7����_��\�3�
��+�h��d�p���j�g���MR��f@sc�V��B(�r��;�'��J��$]�<p\v*<�A';:$�mD�,3�s�`�I�4_{{{l����e�����|R/H�;�a���{cf-�> ��X��72Ki|�,��0��N������Tb�!N�l}�{��Q~>���Bv���m�`��b�=�2a�n�4���� �Q��������a���+M�	Js0�� �����Ni��v��`�j���UG�����o,d�[����o�\���?��eP��f�oU\j�oP)�Z�D�
���~�}�"�Y���MD��i�J��S>g��0ETo	q�@�3���oz����b2M�}sMb�jS������"��2_��T
���!�]tha��R���nj�D�^PCBA>Q�P�������j����0K:G|�!?]�|���n6=�����������y�)gXcg\��*�r��pk{�k �/f��V tg"F�D�V�pv�)����]�8#��K��b��hH@5�������*"E�(/�K�_�\A��Q���P� ~�j�XqoG�#�i99[L�K@�vc��Y�@s�CD�Y�;�*�Ni�`f�/��!a�WY3sY�����z�����W��%D��]�!Kh�`\���GZdY��]�u*�Q/eMR���(�@���[����������X�����\D���r�����Z-�?V1��U>��YqP���	&�����Bd�$m���z��iG�OV�����
l�>#5[w�+�����"J�
j��(SX�A�q�L���U�5�gu!C�	�f%��	L>�� c������B�(@��mx@���T^@H�{i�H��F�Q�����>1J\}B��<&s��f��t���)Y��q�^��Vi�����C������;X
�������q ~l�X������8�0�{Ba��i$�H	����2BQP_b�m���g#���o���������;����Y�&�9�$	p������hpl(rbZEby�����-w�vZ4��!;lC�H#ex�|e�=�8,��`�5K��	��#P�-1X���%w�f���i9G����L2V�t�5�����5�rV�6����!�.K�g\uX.�;(F
�(	��y��������������37K�\#�(�'��:���H�VsV�-�>4��G�]">�{�Mb�
5�}�'���0�q6oCV����u\��"�53Yca�^3����D:�D��pdx�s$�AS����}����T��
��E$�@"T{	y�����	4�	�}Y�c��-�!JD����Dy�?%�bZ$"�E)qmU���^,�&>���W���;7��������P����Vc�(�0��P��$�f=G�um�P��6��!�|�����"���j������6�`&��7�&��0��K@4����6�U��)��/QP�B�R>������[�z�:p�5��Z~	�
�_�X�3J
���hQ����AXI�X$D������F������@P�U
�B�s�F1�!x���T4�Cx����J��Uu�3����>.�/��
H%"p<@.�9�,!���59l����h���)��y�m5=�dp�U��M6�m�
�� ���Q�&-�
�q|�U�6��X��g�k�q���Y�L3���U����������c3Z-nMT�	���u�h18<�z�m��S�����`54H��������oXco��f=�P�z'�N���1�}V��v�}��./�wqaa���	z���wJ���cU����4�@��$M���%"�'|5cH�9m�#��+���pdQ��v:A�������f���\�:�<�j;���<p������ynrD/�Ld��C���*�}�iY��2�����Ek���E�3mI��%W�F�I�R�c|G�t*BY�c�8#�'z�[��t�6f5�F�!�f�	�P�����v�4]N���:�Td�A�d:�I�^��3��h#'ec7�.���:���[���cH�sc����[�����$���r�J>#��JrI<L���,
���Zn7|��H�g3~I^�	h�H��e��
���-�.��
L�8�����.���6b`>�@�F	�'��O����'�@��@�/�)�c�Y��t6�+O��O�tH�����A�@������<���h:h�"�O�`@	��D��@�d�l^fu�������T��+G�-���;��JAdD�J
D@��R�����KY�F<���|�2TU$���a��ln>��kg��S�����0�f�C ��`z�[L�'t$��,���{�~���Y�)��TI�i���:Rm�`������r�|R���I=Yf)�,������X�P�/Ar`�\��n��f���W�M��)~�l�_A�SHPQ]4k�/X`n����$���Bb��+�^_0�(Y�4(Fj�v#���A��1|jI�"�������7�y4-�
|��2��+�!7%����xx���}T0m�e��	�5�n�������y!,N��l&��[x��'A55	���r�{�����l6
X2Q���Z����w�bdiJ!�s����J	�hK$J�tc �iK�YvQ�-�C���C�AC���'����5eZ)M�S��a7��2ko���`��JJ��Y������"���Y36��3�A=�b!Rj��u[��F��� ������� i�_������5���k5��@��W#��7(��ori����[���X��|��G5DO���_1P��;� #�$FO"���O	Pts$�Gu��B������-��="��	����'���@S,=cE'���d�5������Y�����lp��:�Lt4D!F������U�%��D� ;	�x�`�h��7�5�Y����<rL�,bd������dcc�S$���v�f�T�.�m��k�=�}�v�T5�h�q�{3R(&�n��j:{_PIgD}Oxdv�X����q���#{	�EX���q�����n��US�gMIf@U"Y�Z.��b�
)+�D>������M����o�!J��s������
J�[���r�u��o/P&~�����$����K��c�E	�����e��E����)`&�G!���bx{�b�'�*��@��"f��Q����6�b:��bA��V����StU����
�1��/[�#$b��Yo�U�Pqa�����r��Z���>!����	4<��.VrV�qA<�;(-n�3^�=;^��)Gi�t[��(�e�����N����g��"A4aFPi����-
����FO�b�+����%l 8���eV8eA�H���p�.?���k�k��v�����!�=W���[��n��xi9	]^��"�-P��0JEXq�G����B���,�,z�v�Dm�XV!	�Q���{-��	������R�rn`2W�4����D�p�*C�@��=��������OB@�"���M40��!Sp��o����P
J5Z�����d��h�v;���!]x�)Z�aS=�}�#@�%Nj�u'���en������ -�B��\�G��b�5��[X�OB�V��F�r��������R0J]g,�5x��^���d��~;�h,�v��P��WZg��!��W�����syfXG���\�i{�"�KK��'���U�n���A�KQ�����$@�����E.zS��e�HiKK����b��G�@�����
+
$� m��������a�����Uh�V&k���������z=��7Ykw��]���"��4�f6g��I�������q�B�f��=2��$�E�!z�G�/�a>�	"�e�#�f1@�Qt�(�U�Qf�n
+"Y�^d�BPxD�������������XBt��53�N�vO9O��k��@���nA�y�d��NR����ui��4�w�o�|����j6O�����W6����AvF�O����0dx��q75b�=H
�;��rYf	�X,	�%���������8�7�%����n1K�������
�r1]�6��
D����)����&9�X�L��\�"�b��v��<(�/��H��������l0�`��[�hX�{�;�F��+Y���
����f���Pfb�'b��;����\�L���{m��d��7
\��
��<�~�d�6��t���Uf��r%g�~���m�j�`���������A��Pw.(]p�&H�dV��>^;X��� ��P@R�P
���=��A� :p���g1P�E�)�~��_u��������u�OprG��B�Jy�$�L.D.�-�l����2+:�J�$�&�'t��ED���r��������<�Yn���^d6��E����;�������b=@�.�A~�<��h�h\�?��GD-�����#�,r��l! dq�����Us����H����Q�23D�1A��"k�����"2Q��F��2� �#�2xJ���d��J�P"2�9Q��r�[���e%�cs����@�u�a�>�V��E)��
�?R����l�T��h��"��g���%:�����P���ci,9�y�����z�'������l�Go�gP��).4gX���A�y^e����4+ �T%`�gF��G��F�ID[�~�$*�+9&`��`U�+h,l�T������
s�e],���x��,���
�CQ���Z�
���;�p�e��,|,Z�?�������L�������$���t7��h�PRj��'
%C��E����lG��b�a���XPn��b��,����RBi�O(�0c1�ci�<�	�18��_(H�W��?��m���GH�:��{p�;���O�3CA+m��B�V����!����&��;d����`0�����bW���]��Z)Gd
TeB�:��j����^��^k5������\�j|����1W���rxy���jz���m���� OI���Y%xgTy�gV"d�g��kgg���h���7��6��\8��(1jOc�aI^����"�/u�-Q$e�'#8+9��w��w��g3W2U� ���\��,oqwH����n5�rb��	zr2O�f���X{����_��J����2.Y��~kAt7� P,HF�Ph�������'���(��3�[r�O��+��U9>E4���3"L �Ru��9����=�V����N\�Yk�m�1��R�L�W�6���T(���:�)!���!��]���6�!�?Y��X0���
�`�,�R{Y��$����D�yK6�Ar}ez���A���v�"<-��;wn��|%$hG��YJ<��O���D�^�vD��U����C�1���������n�M�<���Q7AZ��
�m������Ir��V� $M�_���RT8�Z��N!u���t�z)N%�
���B� �f
������x�b �Tp�S��� �6�)���WU4}�:���W"g��{�6'/l�"�Z�a	N�<�6�7�E���v=�z	�f��r��7�����u�7�.��>zz�^���N(��������uD�TY���E������t�+�����FO�bQ�V5���Z��?�7��QiP&��8����$����:�Y2�Q��
�
:�%��_��������)
����Y3�����dQ<�:5�A�R2�����J6�W�c]�K�ey���f�.a��"���<:��
������y�o�bm��l�0t��`��<l<�:"��Ik-�N9#�%%���b<�X����(��h��s���������K�����B�c������[y�C+u0�w�t�&�C,���2	,e2hB���N�AG�=��^�I&8���������F�%[[�b�b+oZ�b���@���+(y�V��Kz�<X�K�W�2~�1��c�.p���3{~��.�mK��W��L�m;��!p��)\�X���	0U��������V��3�����:TPEGw{��)9�[!�b��	�g{���A��#���&��:���l)�)��:��vi�i��:�0��0�I�k�!���u������W�����
MD�$:�I��(���|;��������8�} ;�D;��D��rb!(�8b2�!Md&kG�z����o�Dwp2G�l�60�Z����[�,��:.�7�P=|Q�}Ty���������l+�zJ�a�e�d���S�7�P(J���F���%_���"����JQk�/����99�05�"k���*G�.$�l��^Y�����H�.�n_�o�{����9���x+�=��'|�C�K?�����Ul^�
r?�j�
���tm�����1e�<(
����+H�|�\Zy���_?Pt�4�fX����d@P7e ���������(x����L����&�>��'"�r��|�^�P��,�d$�����9��X���������
G���}i��&����p�������v%�����h����sJy�����T"Q(8"�x���;����`7���������2���ye��:�������.L����4�==<�����\#y�����X2D��i���?Z����t�`����5D��!�%��������`����1���H#��&�����K�*l}���i\A:	��$�*��B:6�������eT���17�������F�V�I������Jc����$d����Y��`�s�}q��{���������*��E���X��;U�����C��Mp���f�Qk���q@��	^G��������E�T�����=���#W-��7�3�KZ"S/�Hd�H��+��,4�Vc7v�Kkk}z#$��I�J���S
�l'��@���<�u�x&w,H
y��x9.���������;zR���Cy;�����k�����p�uD����������GH�U\g�����]��Yq���9�
9Z���&���(��K�7*�S��cf��>o�Y%r��.Z_�NV���0�h�v�a3]�b��r�v����<����
���X�U\.^{bs�H(����LiM���_��l�MQ�#��k�4	��9���F�h���Z��{�;,��X�w&o.  ���a����.Q������X���n;f�>��{qCg���K��_5e�����j7����o�K�������L�h72h���T���(
u�H|�9�OQ��|
^!E�1������j������|��j7(�L�[���n�t����L���j+v�
�e9������2�y<��������bt.#�������X�)�G+��:.�~�dk��5
��%���M�p:<��]_�c�W�4_��&H0��((Z�O��,g0�y�7�x�����09�I��QK�|�����"���T�QK�&]���+>Z��W����t������I�����6a���`���}����w>]��N�$��5�%H��KP�i�� �aS;��J+�,�#L�=����z&R�E�u��e�Q:QI�A���r,&�+-��M
���*7m4�i��(���Z^;[X(���� E=������6����&K�}��Au'R7�C�vd�MN����#��]��"�>8	�_I�]�v�j��iC{^"��<�!gU��n��b��@�52�&9MX�����o�<��U�����B���`���z-e��?�6�	P�V�Wj��v��6���Q����q������A��3�h��.&�P�]7~�J-L}������y��`�w�Y����,u�9� 4�0���"�'�F�$���8
�����"������f�X��� 7�����x������o/ZL���3�0�h9�a��z}/V/&������1�L�&M��0c�Q��6�Ls�N��Y�*�q�^�&�"�vP����pZ�!}��w.��G]#5�Fq�E���r��M;�$�E�phy�j�AQ"B,5;��0Y���$o�xs������Uj�+��s���vpI,��jQT��5x`��AV-0���{4�6�f�C�|�2D
��7�P?������h3j��h9>��A�a��L��5�Rq��e�J����`����O0c�����Aa�?�	�����v��:���fy���M�������
��O�����j!F����
�`��?3S����w��nWak�|���������B�o�,��GT,��C�D�E_�����y�g�h|��~��������;�\H%�vZ�����{�X��Y�F������~��w��lr�3F���0���V��v���R�n�l�r��jp���/6�6��ZqU%��3Z|Z��<���%�����{������%.��>��5���[08F����Pc�AC�_��(�y��<$��'��� lrQ>Y]s�q<��>���v�������#�:�<�?����BG�1!�gPZ|�c����_�=b�$�K`=j0C��A��?�Rm4�r?,P��#	1�8��%�_�BHz�
k!�$���� 4t�r�0����bar��<d]A��LIr�	��p��3&���S�,P=C��0(����rX����g[���M�C
B�1~��B1:���,���1R�i����Z����EsB�������N[F�H�	��U����W�o=����l��Z�~��A��4��x���m���46�������������_�53X����lt�a�}������K�Q�U�X����`L�X�
;������[��K���{�
%�u�RR`�pP;+������o������A�������q��@��!k���
�.@��H-�R�_h2=��\h�<���|T�Tv�������V��.��7!�beV���
��G~�'�&�q�|�Y��/���h�W �p�����y��Wb�/���������jh��8�#3{0����� �������|���o?4����_���Ol��Z�����F�=
�R5��JL
���*ICGO:�����"{Ja�^V��4��n�Z9���k�g�x�`�$��j�%���������Q��w�v�QH�&T�J6a�c;��#�V�x�4�U����lC���i��.������a�IC �*-oF��{�Q#�^�9�NU�|�;W��
Q��
<����kY�: o8A�U�}I���`�y�����}�kZ���r� ��O8�Lc}s�F\�LC��`����_i8��z
$���rp?l������`\R����1� �����m/.=�{l\/
���ji#�^�Zs�<�W�NW�!@�(�m���`�K��,U���&��d��H�g��w�����E��ty�L2�����W��7�6��������������4�eH���MVb�g~u����;��Q�$��}�SF���)[�+D�1�@�����l��Mq@�f���n��
3�}E�L��?��>YZ���E�h[-r���{X��6�W���A��kb����*�,8w�������wO�4T�\gf�N�j�+���v�tc1�(�����
���3���r����e�L$pd�2	�5����0�+�>X�Iz0�K&��N��c��5b���%��������,��[o��
rR�j��sc�B%=,&,�ev�]b����9�h��|���A�+Q*��(&_bJ7���C�����_P�h�����jm����'��K����U,�x0���A6���D
]O9
�mf����
�����Zg+<�Z��I���Rs���Y�������<_���r�)����Hr�)|Yp�Je�=��]�+�
���hT�T�6k;����[�
�|��.y�_���#�\�9x|�p����R����oZ���<�Z���;��'������Kol�������������������?�yo��[���������|�i2����+$�-�frg������G-���%��<�r	"N
���\8�@;IP�����U��-!����U��~�����6�����o�d�r��	��t'��%�t&�L��c����9�3���gz�����	@���Z���V[[{!]���r�����W�s��e�o��rU���+�"	!_N'�3s&������9�`��)��9=�o��}~��M���th��Y�`��>�8b�.�([`]D0����AEq��/M�G�r~�^P�-_�A�p ��Q�H�A�2������`(�8��~���W�8�%�e��(���kk
��3�Qf�8��>��/�����<�H�0��|8����4�2�'����������]���~�|#�J?xa���J��2�h����������{V�����!�Nf�2_Z�g������h4�X{��\����N?�E�\OaR�}�+���o:Y^��{��e�$�8a0� -��"�����Y
�J� b�A�����"�N@������/~��`����0�F�*}���?<K�����L
��<�P%�b�|C��	~����&��5�O#V�-�9�������U���k$��L�>fAQ������l9��s
�\�b����SX�h$"f������vZa�'/�����.�Pn�"#�2�l�''�>���Ec<7�{9��2K"��}��P�b��]�c�?���+�x�E!Yd������qem5UA���%>S�\��b|�p�`��5�|o"�|`�;"��t����o�P�dO��.r+��������*�/`��7@�^g�vT����?KZ���C���lK�m3�s���:�n`���l�'>�N<������VL}�$���'�h3
xE.V?���t����q�E����NTh�8xJ	��]�WF���h5�1l�p����y��S2�_W)z�����6����}#Osk����%U����E�
�1�L7��1{f�W��C*Fj��������� �@p[�gAN(�3���B�9��i&W%��ap*c�i
�	����@��^2W�@IDATW��g^R1gZ������H>w�t;���+�s��c�Mh�����/�������\�q#��2��������d�H�]������JAh�`k������{�����1/��� b���rQ�
`���K�K��#��MH�e���
�nB
�[	���'��QG��x���<��>��?���Q8���n8�\U0��78�Xr�O+���?wY�������W�_���1�������	�|l�p"�MHd�NN�k��k�4�2d�����fFg�k�No"M���`cG��o�H�{�$�Y����n��
�]���#Z��5�(�r��Yw�i��*^u�>�@r@��K%vQX��2'Z4s��\oE�~��Q��Y>py�8[��[�;�eMt_��H�`E�B�2�^G[I�PBN�Md/��Jn��N�����no���t��Z��D�>M�����G!�J�f	f|�\j$��]����R0yg
�I`��Pob�����Y�����t�:x4������������N��GlL���U��c�����i�{��A����y�<���a��,�@/IZ5��c�����ARt�z|f�OF<�hN�E��o��B�������5> �-*������8P��0�/�h��A��x�TY����MH�����3=�zi������+�#��`��A���A�D���'/�o\���:�f�>=�h��_'@��{�[�I�����Y#m���n>X@�"��h�-��Tj)�86��B�>�3��e�5Y�s������WE��`���#��M*�Lmdx��@���1S�n���|r�����'��@���L �� ��)���w��u�cB�#	|�|��\�]dZM"�s�ba	���h����,i�9�VD������baSa���W��5)�g����E��=�h8�BJ@(�����64��1Gs���T�lQB�����:� �)#�b:�G�Oh�U.�=��(����6'�.~��������?��?�V/8�j�������H�n^������h.>�}oe��N0[������������NC���4�;����4N�-�~k.orl��b�b>�f5�=���PA�F�;�����Z^j�����Vuv��5y>z�H��\KX�Xt"-��&��d5�B�(���i����-*Xl�o�A�a�9�"c�?����
���]Z��c�e��px�[�����"f�b���A�T���'�e4������N�������=�H,`�
YhH��>�/���D�I��\
��|9u�N[�Xe5����t0p�oT�Ot������R����V��$�)P��,�=�?q'p��ib�&�>�$R�^��w���;������Td�yem�>�o�K�&<�;8��� �u�f[�0�x������>1M�0rls�i�|��C��2w���i��pa�][�))k�q���G ��6X�3�`x��f�8���*����R����b��E��"�vP�TU1�6\8��H���jC}
�� rF`^�l]by�\<x��^���|��l�
�%���s�����$A�/K���,��C����o���P�3��W�T$���`6�|���,� ��WT�,�}�m�6���_�����F�M����^�/;�?��V������F/��lC]�b�~���������%���3�
�����@�
�"O�F`��4r���5�j������=�K�������D��vi��/�����Cdv�O+��`����_*�w�������BK��@�h���&���k�`��������;�����YP@4�+����_�W�`�a�����_�'������$q������_Z���oc	�67h�~������il�KPr:#�������\s�>\8���Kf`dJJ��b��,�����#C�P��o�d�M�"��
����_�"�2����!`\	).T;l��V����}o�R�N��"���5����g��n���
�3;b����JN'��+hH���G'��]��r�������3���g���Ul�9g�+�x��z��(�X��0<��%��:I�$����M���J�ab�W���T���N��!�6R�{Ubk}R[��=R�Dq=0��nw`j����1!���ha[���)��W����:��+�]�_�FrNU��t�0���Is��2�����P��5��h�������_���q���������b*�����9k��J��?�Ocj�U�X-+������$�&,����
C$(��>y�?�.���"bO���L~��8w.!����X�Is����eQ]�����iH��0��^�� K���J�Yf���
4���N*�������{���cM��������b��WJ ��Y-m)L	���3�Q'=����C�U�%���x{xXK�r�M)l�>)�R�Pyy(!���V����W�VK�Xe��4���� �f�3����� �f(�Fm���
�2�������G'��k+����M���K�b�A �d/��#����!���e��nl���0&��k����;b1������� Z|�{���7�E =$��7C��������B�o	�ij�9�;�@�k�����c��-�%n%�����P����O�'���9��2���8���u�0�t=0UN~g��I��#6����a��#a�W0�S���{�M�'�n$
V�p���}��W����-����	���a:�mom�X>�?	���?�V��8n����Ja����k�����$�?������y��JY� �����:����3��{��?�2e��	sL&c��%�&��S���c����t�R�BC���'�����to���2�EL44uC7])���]6	�:���LN��Q)�����t�\�����u_b��J���t��k�o�2��1���b���g�yN���C������������~��NMe0�FwE�?��
,_�U������������t@�<��RWX
������dy�V���g�V�q��T�f�����l���cHs��{�:	
w+7:v��>�Y���Ei�71o��*����y����B@?�H+��m������.W�M4�h�3�5����g�+��y?|>K��	vR�������zCE��|�i
z���w�Di��7�����K�5|����� �B��I��3�t��kASP�2h$�����wfN3�c���@s��[���ayd������p���n@
������2��W�	AW�s�q�@5da����f��8�Kba.�b������o���k��+mQ��������S����������M�9D�o�~������~%�7I�2�����
�=s���,[������~�l��@p���<k�RQtf���yE,�N (��4���8Wm�P�?|u"���c{��K�8�������JE���c]{0�G}{R�z��ZF�m�!��-��@w����U�|8���1�<=���}���[C��5>i��2����[f�����<��O�wO���+�<��V�/���SlM�w������X0�����^A��"+�3��I���h+r2M��{<=.��??����j��ac3YQ�e������}�3���:af��\Z�����D�)��"~���_��,4m	�� �6��~����'�<�LZ�;\�����"�/��-�����97��'�������bJejB�!QbC�m��K��*$"l�v0�	2D��.���QL6��`QCB�L+����p�=3����HF��aA�J=�	)������U�v
m�8�"�X]jZg";�R�[���\]b�M�"q���������l?�B�Q)������k�����)�>e�WH�x��q���+oz�/����[����)5$��#eK)S��n��zQMj��)8F1:)���j�0 ����J��G7g��=>��X�/��R��e6|�Q$p��[��o� u�9~c6^��e6�������i������+���[�����L�e.����"wR�8��K�C�U���*+����l�����lQ������D��h����{}�O�p�:yCF>K"7�Ap�&,L�P��	x�����M�����u���OlvIad����������6��]J;��[��g�s�����(T�J��
����������/���N����m�bUAr���f�F��p�>_����;75sv���)e������/,���i�R�.i(�=�T�zz����B�:�����y*-+����gj^�r�R�+�Y�\���'gb���QY�I���0��X�X_*7f	�j;��6a�i��S:�t1�����vs���$�zu��vW
�f��;�#C�_���)rB��<"a���cZ����Tq�&kC���+�e��xj���tD�t[/���`A,�d�U%lGv��b^w������
m���C����	���3��n���|sc�����o���5�[���xU���	��z���q{����A�,���?y&����#�1hR�D0��$�R���b�
�r?\�/��;]��v��J����D���/������h�5O-���Y�.��ukh��u�z��V�;�����+�&���o�|~��lI���_���
l� �-r���HR��y���9NgJ�j}�~w���P_����L�M���L�fN{8x��[Z�/��q>K���^��l`����N��d�J�L]����]�5�^���5��������~u��"M���-3����[
�)m��(����Fm�p�<e���Ow��#}��V�������N�n
�����5�s�JW��?����y�N������ �s<��h��q:n��X-4��vE���j��F�� �O�B���'2���IA:���Yz�*��_�*�l7�1@Is��`����T�����4V��"������p��O����D�A0�PD���J��G|��LIW#���3��,�b��<�/l-�~��%fh�`\�k��5"Q/+e�E+v�����������(�/��9i��~K���y����(������{�t�x�@/)i(�u��p���:��u�K�
rntu�a;����0��R���\�L�^�Wo�vr�����U U�����uR��|���g.���W|Lw�)}��D/���e^���CA���$q��%7r�L�6BOC���\Fe;������<�����K3c�=��i�Q��M�&�S�k��O�b��G�����tjb�Mk<g��\���$kq4(�P�s5�
&?���,^��@���[��
9~��������]�����h
��6^����[/_����%U;����s�_���C����d>�d���M�������-������Y�Z��!�C�N��;�z�p��k�*8w&�G��(���@��0�BCaK��9�
[]k�AO��h����qf�������Y�+�*W�m�b:A��zd���;3H��^(n��bt�`P���)�����	��i�b����Cl�1d�	g�|��I-t���Q�a#6�+�RyQkcm�54�/
���A(��/9��Q�/� *`b���i(�}�>�Y�����xo�Cg�`����za;!0���Ag��":����1��@�T�;!f�6
p�B�W.a(_��?���
�K�r��/,�0�:���Gc�jl�;�E�]B#��#G=qO��3.�O�<��'��p�1!����.���������l����b�~�a?��$xe}90��Y|9��cw����5�53z��=A����H �W�V�r
6�kV��=y���O�X�8�����9n+i���E��'(�[g�P.����b�5���E
�q����(������l4�1��4W��6������o��x>=d�u0*�-�#�J�Q�/�2�N�	�a`<.Z�[rT`t��_S�6q'4�r*��C3��P�<LNb�S�K�����d�\�<�`�<J?������w�����������l��
�)�_����j%5��9�v)�U(���WTA<�'��A��>R���V�h�t�x� ��!P��ynT$����$����z����fm4<Y{�>\���I�����S����H�����n��B��������vKRJ���J1�C�@�s�p}���d���K�"Jg����"��aQ�q�NY���h��;���~0�JY���ruZ]��u�>9�YP�$R������Y:���+y���O�S�y>�{:�;]��%�k���~��	�������9~�I�8�����	YFT��:Y��jx���]����E��i�;xp�#s�j:����??����4w�\�b�f�n���SK���6��������Q�����
�������7��A����=��u���d/=�j;~��~//BJ/��g���(j+p��?|zvv������������RMS
�����!6��'KR<8}�R�HQw�L���mqY��y��Qel
'�fq�^�z]��tr�x0�����d���������@���������������P6��"�;j�������G2���5&������� �w����2������s��_^R=����L���.f%"�SR�&��$����f��M��;}p���L�j��{f��i
B�o*7�[�?�`�L���n�\�*�Ti[`s�������z�+AE�.�&(���C���;�8�������yo?K�d�g/^���/<��X�L�4��/�S�N�5�8�����q��R.���6���X�I�m�yy�����m�)l��j[o)_+��mC���w�o����9�v��m7t��W�<�������yR�=���\NiZ���������*5��4�S�V"��9�\Y����y%��d�c����a�����NM�X<���������o���s�N�����?-�,x�K�����Qc��(�!�;������.N+B�[�]�����K�Z[[YZ�����GS���
�V�K���oT���s�	��W0�����[=�34�A�yKZZ�7��9��@�bs����!k��������;kA{�'���/F]�OD+�m�`�"���ykuc���nG����r�^����1[������B���]����uP���5O��1y�y�M�#'�*�t��T�o"�%NA�
�o��UP0��Cw�7��'��~t���X��
_Lz�����i�O���c�)����~����O��Y�	5g����?|�v�*��_tL �e�z���!T�.��RR<{y��v]�O{?�6����8f�V�_��e���6��Jm�v#o����o�rI��
S�g��I_<8�N;&�L��ZUY���R+p�n�_�Y���U�,1<�����,����li��2�{���=��z�(m�����e�Q�������5g/�d����`�XJ�M�B�A]Y)��F����nu����b�k���#�q�C�$����=ys�����*G�����',����^-���Aw��
�)���I�]���2f�����+�eA�����#�o�=�������M�%�,���?�!�����S����Q��m���F���>��Eh��P3���������>U�"�T@��;]��2'	�x��S�U���\�#,N�{�X�e��3�'��]V��w�F�.�=�V�_'F�H�l�����?�����jqJ����4����y�~�t;t���_�a�r�"��>Y���i3��[�.�[��������?!�Ht�je7��&X5����d#��},J|�X,��uHm�0.�42	�^��d`�Q&��A�����2$�uu�jaF�Y�nN�9���\JnC� b��b�Ccj��'������30�z:pj~���|�q`&�,{��s����X� �=��L_�M ��C���2t�@�(��E��O�9�N���E6�;f}x������U�g��f�`O���
\Y�W ���y9=�8�����$C*B�4b	�i��_�s�N�M0s>3�d8"����)�	�
��y��c8e�+�
_y����4Ceh;��d�?�Dw}��(�A���+��;0���/��{�,�G���!��&��E��~��^��������b(L�����+�"��y�=�����ix��,���i����!|�x#:_2�q�`���A8x��������N��
��Z-�x�C�b�Po��E�ga���e�v\��l�&	�Z�g�F�z
�'��3�����w�t
_�
Ah��YM�c���E4W;�Bd�
�(UK\P����{d���Um����N�h���:	x�U%5Y6�y>���B��:��5�
^#���[�byG[[U������G�|�?9
�����*������~�b�����������p��%Dy){������������9�D/����Kl�����=o���V���T��Cz�
��3����l_W�`�Ww�:���N���V7W]�Y�>�vv���n.����nhV�y�v.��M������s�xm��i�a��s�C������m,��W�u���%L�����Bw��l�j�nj+n�e��C�w�f��}���V������|x**+�x��kW�JOOd�ml�B��^����o����R��W���V��+46j�*�m��w�0�X�n�}�0�"����J������S�`�qY$�^"����c��;o
s�(1�6�5Y������L4�����^9���f�,C>�N�A��\�[�_}����|�y����j08�U�UV*a����_'�[�K�5k��=�_�y��Bqe�8z1z�>cko}�����V=�'��i.��{���*�e������2l��t��
�����*�!��o.��|�O-�\�|
��A0 �Gon|e����gfy`A3��q��������Ng�S��_�V�]_���d~.�If���R~C���qPZ�������d��Z/�4|js���uV@"
���_��a/-��"���)������UQP�1��\�To��^.�y?���d�-w|���A)7��U��%i�O�G��F9���qT�
�s
�b�JTu��ZZ�����60G
�.C�����_���v����a��8E��}��Sy���3�����g#}(���I<x0���6������A.+�������������s���$�A�����bK���Ub6%4�X^�����?��[���(��(�Z�x��?vG�J�m�p�O�[g%:����?{}�x��)�kA�=��^�o���O��Hn�����Cr2�o�U$����8L�T�~0p��2�����@���2���*��:�����K�tu��	�:��\�9eo~�@CN	��//#��y����i�0�n����P����t�_������.��n�y�/���������Y�o5��g�7����h?Oo� ]�8��^��O|o*�k�2!U�8���AX�H�
��A�����o;���]]f���3���7$���F^>�i}���M���5Q��
��!b�L��k��pz����U�w���:�Wn��W��~Ahk���B�BWw��������X�������������������p������%~)��d���an%��k���������������n�%�x{��|O`���F�Q��
:�3^�^4�`az����.b�@:���U����~~;,K�5��<�C��(��)�|�u�H�1�*=�o-��J��~}��9���N(5B���a�L�V�bX���N��k�����]�. ��d�-���h�pkI��cB9��L�:���4�������Rn7:h��i�	�������,�X��Hl:����E������,6����C]e� n�|4�V2��<�a�v�����Cs��*M�n4���;rjv?Q+*�A` ��2���,��J�����J�,M��p��%�N�������B������O�rQ��uz����S;Mk��k�L�GY�r��t�sOE�:
�,Z��9�"�"3�9ku�h�,�o�)gN�t7���Q����)s�X*wA7L��WQr���e�M���!On-U����O{���}^"�4�_���4�c�u�5��I^7��D���S ��|�xq�������� �&|m`Fl<�&n�Pg���
e�F��a����;�����X�V�B��O�]:}h-|���M�Z(�����a<��������"�%�@���A��mu%!��;����{�h�:Kn����*�+U��������
S�l���������7;Y.��������U��&��F�2u���F1{�mDv2��<wk>�#�}����Do�P��`�K�j������;����E�0
���W����w�)�
d�P^�Q^|�;�YT��]����������E*��q���u�Du�����Y��j�C������g9�t)YV��a�G��d�YB��KBn�V,���QR��Jn����sG�H+0�����=/���gQ��/LhR2��u��xG��S�[@Hd��)����S���k�Q���d��O����bj�K�p���7��t�h���B����v�.p���s���nZ
�D^5�w�T\[����5�x����^���H��������E�HO���3�/�7�W��P��K�?��L1J+ 
��CY)�����a^����������j4k$fJ�ei���
�O����u����m�	9���;
0��@CqLS��/.�6{��iv����!7b��>=-��m����^����N��������ne���
R�l������k��3a�����+���d���
0����=!\3'8N�H���������Wkt�lE��}�����\��s���~�+/=��z�3�Z�uU���7�������G���1���Wjr�|�o�nu��q����_(�]B��������A���-q�_�Q�,���!���G�������okO�������O���~@����`�.�m����no��J�Q�����l���#��'
.�D�Kh��w������{oS9�^<<�z����QvBn���}����H�0���{2Zu>j�{=Gt���?�,l:v���,����~Gs?x�����Y����t�?����iq�{�-��������%�7���J����'B�f��'�1Jc�V+9G�������&#�� �R��d�y���l���Vr�%��"g)_0|��=��T�p]�|�	yu�������Q��wY>G|�p�/r��p���3�O6���TY���=)�����<d��O�d���l��}�z��Ia����J��O���$u�D��I{�9�~7��#<rlX�������hgL!�=�~f^-.��j����}�}��L��� XY��Kv:�����"jDX�_�9<�0�t����<Gw�Q�R}K#���l��+�_�k��������-��s�����u�y�����i���/��
Y�s��@�d��GAQ
gV5�������`��.�Ii)�����PkGpi��	I-�
}�'���YM%�9��NV���c���,������w��3�@�'Ks�R�ko�aGT�����oI?���E����Ka7d_��M]h�<�H�K��y����ZC�6����f
���M�����3���#F�q�H��w����P>���/4�kw����8������q0�V7����_l�������?:|�lD��q�t04z	]��
zZ�M��Y����)��\���"������ypf�m����	�l���(��?��aa#����U��&��r�.t��+�r1N�������c��I���o|��|����0&8�bm���<��h�rN�v$���/1�^��[�v%���CD���~ct�S=?��^�J�9�*����7�������<?)���'O���`K�D�g;��E��Hh����b����������c�xW��CSl������|"�Q�am5.Z	���%2p-����Ue�yC���	I�/��;.�M�ON ����Q��3`_�N�nN�:�A5\�:�,��QH
�qUq���_��Xp����������HY�z�"�{C�{h8�'1��Vg���n�������l�&Y�Q�+pb ���P�N3��.�vlq`xa�"f��&��y�����(��gth��~p�����#��M�0�)��.�����k�q�����5�j89���&-���\��U<�	B����_��0)����������V������SB����*���+���������>,;�1���|����g
>���$&]���G^��}:���b�c���� k�\��n��\v���7R$>= ���D
5���[c�hi��ew���TqXGF>`������b�y��em"�oF|�+p���5F2�i�����P�������7�����
����*Qd�9b	��49�j�s�g!�f^���#FZ'V���`����� Fx���~�%���m���(i��0��$�cM�F�9�*��'��\ 
�*��P�0�'Y��t�m,�2�[1:0���}8��e1�h����e��@'@6O��k8���J�14��r��2�]*�R�D������Q,j��2����y#gF�KVWr��<+���P�T�����%a�3j�Aq��@���3������\h���P��Lo��.�)�	M�d��:��d\��_W� ��z�);	�D����+�0����/AN���8
m��I9�vS�7v�C�#��l*
H�&�.�oN�f�lI]��Z}�g�3�e���G�Q��H�/��y�Y���N��8�s�����CNw�J-��|u����L����m�*Y���X|���n��K"�bl�6a�M2�q�:�9&_��|B�Dr���s��]�.G
��K���
�(Y���i;��r1~Tc)������x��N-�[�B���PZ ���RaT&	k��&��F���[�f)y�c�V;c��U&�fyr#��s�f�F=`����G�]��R�9����?��Qg�/�!���kE&pr����g���(�a��c�)Rn+�kDS�����@�tH�\!���x6�?���\�F��Z�W��w\�//
J�e�����P
��y"�;��B����i#>aU�.�������06���1yn��F�.��i08iZ�n���|K_����i<��jd��r)���f�fL4�������n~mY������?��%���>H�D�5���y�*���p���3/'?^(���o��-��N��(�+��;��:>U��1��#�-����
%���BD���:s�����j��|��=��m�����Y�@�G���w'+��}�����I�Sj������$�j~��O�����Z�):��!l���*k�S�������/�������\M<|;@������_1$��:�0T��TZF��h���<#)�c�������t��������W�Cmg~$��Ql�Bn�$�z���Ei�;R�����w?�a��9��XK��5�\|#H
�p�-��}�?��������Z��"y�J?���mQ"C��ph��F�x,�!qu�JJ @��:&��?�������y���������L"0�p,������E�cW��_g��D�+_�n���Al�O�B�������+��D���xX��%�3���������
#�:P���2�}X�b/�I�X>xP��6��>������-��=.<r��:�/f�{��������r��J�>��f�������PN��AL�D��A��3��73^��&�Gy���yrg5��`�����S���+��u	rK�H���BQ����^?#dx���A��M���o�P�������-0;��c�����`�*B'� '�J�h��4.-���bcECvU{F�w�7����|�����3]�%eIer��C�
���yTYQ��������V_��i���I������k9p�q#�-��`(Xk�t��Mq�*������%%:R���#;X���~��`��o�A��i?���jIy���Gs9Z��q8<#6	^�r����A�����&En�^cf���
���zx�Zr��?r�^"�RO!�=��5$��E�T��e	�����8^D
�\VLqr�@�k��+U�
�:��_�����:,�����g�4"v�4�H��R�X��������t�B�F��YaR���6��T������	6d�d0�)��X�*�����cSY^�/�Z��t>s�/�+k$�r�b8g1��7�9�����1_�B�X����f�`�yf���z��4WdlM���:u�"7��������
Q�����H��-� ����"�D4�bI�P4C����X	a6Z$*!l.������|]����l:����]���������F���M�)`���
8pA��x� ���@J���ejv����K�g�pA&�b�c&�@��En������/h�B(8Ik���
�=����"�
C��f|�F����r���6�d���a����,��Av<���s$i �<� ���;7���X�e��-
���	��>n,p��@��"���Q�Pr@*����C�p���	R��PV��^���h�e�9g��|�!_��Hh�L�AbJ��J1^�������U����c_���|V��B�8�=O$�*�e�.9��*�\�d��^r3qG�`C�1DD���PO�L|�|�'�rHl�D��M�4U�
-�V�{�*�e."�J������5��v*L0M�@K����%��t�l��f�-�IL�P�
�hy��Iy ��XAF�p��>�L�XH'!`��NcX650�C�������"[0�+�%��j
���Q�11�D���v� <v��r}%f�+Jq3)8��.����8�,
L�b<�m-GTT+��d,�i� (/Y�0�n/,��#j'X�DH��!q�X,T�=
Dkr���}��-(����1.&pBE�q�B"	C����I��u����4�`w�OV)
����{����5+A�F�S��%*�n� 'G\j��s��l�.�p��PBD�k�Q@�Ypo*����<?�Ap�fH����z�6�|����'���V�)rtZ�n� �b8?�3+����aB������>�I�3��I�#a�|P"�E��$�M%�b�d&��K���a�,KZ�����8��H�X���D�I���>C��f*b�
���������B���	��	�TL>�J*X�
��<����F��������XYb
A��i �Bv�X�x�[`���?D_^b=c�R�6���S�1;99����;PF��?������s�Y��4�C��.S�����Hl�)����\(�4��� ^�G}j4�J�f�|�"v��a�%���3���`4��*��#U�V����U>����%.iHe�D�����?a�6��y�,�"�O�To��sE�&��5�"'FlgZ��
���*�	5��{����Aa��]��G��^�r�x�����d�M�&��V��9��)M2F���_�!���n����lJZ���I8S�dj�����f2�]i�T�K����d��a;�EH�0�j\�QTwZ*I�7�\�i�����R|k�����:v���y����H&Dqn�z�dU]�����(�E�^�x����v������*�,*�$2�v�w@�@��&�����1p�J�J����z������Y���L�\�n�� JZ!	,Q-#������U*eQ��D��~����t���c�F��@��fZDn�v�<�5���&�Q�����0EX/�<��t0GC�A��z�g�D������*&�*���N��tBp \��=6�ZnD3�#'��*Lzc�%�o���TsSs���<�glw�~�}1.�k����+�CN�����HM�>`�����$ub)�j�s+j��\P���������%����A����x�Hc���9��|�8���n�/�44:�����/�,�9W45�<����W��,jN0��V����?�(?��F��J��j-����rI�����(�	 N�����Y���e��`�"�$@O�Z�a���;���`�JC*@IDAT[�"����P
��c�D�:��8���uT~x��.~����S�E*�\G�{p�v�:0��]�fpN�{F���I�V��O���{@
�s	��|3���z���Y<���N�j�-��e}��x/�@
����P��.x�]���~$x�e9Y�X���E9�����������}VN��A?�i?�����P����d�B��#Y/�u�'�_�3�0������=�(�cP����u������8�c��Y9�}���?�h�lV7��i/�
1ohQ6.p��Xg��9�+���Y�1�(1g�~Y���Ohf|:1�(�	+$f�e�/�qQ�71x��%+U������mD9�'k�,b8��*���
�'��2�\<����'/��y������������(3�~y�EAY���d��_�%��M�����e���{v��b\.���E���g������e�iV���8�.��~�z���5��:\��U����~C���R��0�a��Y�/���	�Y�/�@�2Q���po�x�:��������������|?��:.�������8~6.����� }�|�9�����g��=h;��	�-��z^�Y7�I6��|��|:FG3Y�%ZhKpM�}S�����=�mcIVh&qwLvQf�,��x��=�>x7eu���\����wo1��U~��������m|���6`�7���Q�e4���u�y����Q"%y���)Oy�kEy�"E(/Q)
L�h0``l��4`��6��mh�������j��9�N�:U�}�{�l���u���Z���9}���#z�Rg���]���(��z����+f��h�l6�+8h]��h�xh&�S��o��}�����N�o=�|[���Z�&��%������d6
v�tI4����]k�
o�oL�����J�h�R0�tGg����2�
�q��w����~������Xo�5Bp��$��Zhq�h{�e����\�v��y�����j[��~�|��>�m5���$2�b�))�t���?���������(�Z��v�V����W�����M�XGj;Hv@��D���Em�v������!�v�������o~Z}-Fe�r���b��W�]_�m���l����Q�/v��X�z���Yo|6�;R�����N7�����n���V���e�[��<��:���<�����;W����o:I���m�u�t�Z�$�����������vO��?���(Y�Wl����v�ng�����-�����E�����y���+����&��lMt���qn�k��I�u��U�G2m>�v���3��e�I)��]�{��v�d����G����v����y��'�t��O�WDZ�]���Mf��I�}:�boO_��m{"2S�f'j�{B��v�&������vmOJln=q���v��C���n�D�
����=-�]8O���m���z�ly��w;Q��r{���"��A���ss�l>�tO}���������)��q�<�i2�y�8����N/jOS?�M=U�������
q������~!��������``````````````````` �t{�2320�����[1���H�+��������y���n��J�>��n�������s��������'��#������n���<z���~������o������Gn�?�ll����_~�Ovw�����������9�������g?{��w����e];{���HV�����B�����^����{����c�C��RN������������b$��W_}�
�����V~��_���T����&q<���So�! ;����YJR&��?<�A���&h�"T�D�
���F�)�������>��A��Y���g��&;�:�
Tu�Q���T����j_��I:�-��4����������`�]�z�!B���'�����*0w�s�ZP�Ry@���\hn���/6�����=	A�� e���ln8O�X����W�.X���"c�I�{d� �-s%�s����O"�3��R��]U8�-O�g�6� #:p�e����'w3���?��+w���
��Q�ld�[2�Y��K�3�K�]���&�7u�#��w��H�v��K/��qY��!��������N���%��������Ue5���k8o�i=#lK��?��d�}��b�����o�Y0�����!��\�������V���[o�2��-]@,��]gIt�����)���5�
	��Y;SH�Q]�tK�vPw-�7���'NT����k2����6x
)�5���RTr���sBpWe:�L�
��`��T��mO8�Gi����;�j��#vweP��/�)���-�dY���C��F�IJ�fRx���F4�`o�Wv� -|8�[��$wV���"r�Z������p�3�-���.��
�]g�,c2����������\�(6��|:��$Hj����,p�
l8��^V�����7���]mMeZb.��]
_�yP��$����!�R�<��s&���!w�h������W"\[��|3iwBp� ,�*M��,�+[���s�=�y�0�������~�#�p�!i&�������*�F�g�����T������C�0Q`�I����'?�I32Ar+�|�b�S���o���]
M���2�42	X��^������o�����Y~-�pKF�6���>���d���o�C�-Aj�������" =�[���d	G�s)�����E��+'/pn��%5ff]LhZ�CA���2;}���I�0-"�-J7��u8�!-X�bq�����Ce�b	 U��RKZ�K�~�(GV��"#�Tc^�J�LS���0�s�=@zd����@\�KF<w��C�R��!/Z8B��{��`����E9A�}i�^��H6 �����Q3:�t��N9�j��
:u��2���
��P�g�����?�a��3g)0�)g)�_�b�v�
J��������Ll.�Sr��^'n�t���}G�.�s���!��[�5"�0/#z���r'a�K��������L���Uo�8�����b��<����X�^��>�a`�Q(*F2T�v������WL���'"^�
�j�S&d����w�a;�3��^��h��<-�:�l���� )��Gy����n'�R�'#}$�gF-!_v@������za�p��C���-���EW,��s=��C������x�_�F�9u�!�c/����I#��-�vM�� �7JQ�������k>�> ���`^,2�e�y-���r$R�l�y1�O�bi���
G���eJ+��^��`���2� 3�v�%��W`V����k����[y2H���QV	r)k���x,����v���z�@#q��������<Y����j2����ko���	'HVr�����b��Y;�������K����]�\�y��-�lHX�p
��`gI^7Vi������^xA�K��PQ���8;������_���u�����1��,�"�o��*�����e�F���y�e��Y:<����-�)���������@b��(4��WN�I����-�I�=R8BK�Z����pK_�u�}w���S�p�g�����u�������d)H��Y��f��N�PK!M����E�'3�d�b.�W<*JD����X�b��Y�"u����GQY>An��*�dG����V*�$eG�]��������\G"Lbx)�rZP�0�,E����l�WBp
�z7N�O��S^��O�6#�� ���\��M6��-���b���&�b.�D!e�����
SD����%.y��(��h�[-�����!�$!x Si!f�@$q�b	��Z����J�Y
,(���HZ;f���<�KJ�M8�`;2cR�����Rs��D�����|>����D��T��l ���79��}��v���|
( ��wb�$0�4����MoG�N���v��s
ao�Z�w)d�;��"���aI�79,x�{{�����b�g-���N�%��-l��.��k�CoxGh&	�a;���|���LB�������e%d
Z���Dy�F8��Z!��W���+
��1�,
�����c�0�W@'����HVK�J8�G��=�dG��'Oi��K8B���'z��#;�ihB���LhBH8��{���F8�q��k;)
k?Ql2e,F�YP*M,fb�H�����>d�LFtc��Xu�\��C2�����p���lnHX��X����Li����v�]��0�ni�\���Uu���)Sx����]����,�b��+e�w����:p�{;�1�������0�$�H��b�c[T?@
A�A.P���_	 OPZ�DI*B��o�X>=�OyOdq�&�\�?P���>��:�tW$�,3��>y>3@B�X.��
��fB0���>�����\�&u���=�}r��f��;�\ 	�L�����8��"����ol��"�����������������+I�������Yc���;3��pN��O�>Y`���`�
����(6�������H�X�zW�����	�v7q�?����Y�SWr�ne�X�����\��-�����������*v��MAnR�p�|'�\	m6�R�o��j�x�9�Ws@&�>��~<1��3�;������T���������������������i�����i�����~?�����������������������Ub`�W�����?^���+������c7-�wD�`F�������������+���[QGV�������o�oo���k������;?��T���W��o��G��.�_!��e��$�K��������Y��
���?r��V��6���p�0���h����n��~p��O.�o|��c�z��!k?���Oz����DC7?u@���}���gq�L�(��v2���g�#v������
�����H�>���v"����y>�������P$�y�k�����b�L�I?�b�;/�L���m���~i�WG�F��)���>�������/~����'��_[��	B���
gn:5�4?�������H|g����ag;���
b��/?@���,�2���e��O���
����r�^����_eP��a��#����i��#��f~��/�	���3=}5f
*�T�`	;T�c�"�������q������������/��}�~�����g���9�425
����B>>@����=�}�r���*4������2��W]eG~n���������6��~=��)?��x���_n����Z�\�Q��OT�#��������Q���H��UQ����f&�e���I��6QeW��Z{����������#���������;V��
���C}LtsT�QD�2�������%)��g6��f,��v+�eR7S�f���J��DL��N��o��/����ZU�m��a����ts���Sr~��1��K/��Xf�o�����f.wz��<�D��a�{����������z�no7�{�q��E�+bkF�P�+��U��Z**�@K�|��2e����*}K�����R���e�w�c�Yr~��NoEYf�	P��h����XV)<V����M��"l��]��+���G�yv;�l<�K�_;"k�z��G�`|�����7�qE��I��C����l�GN5)c��y���u
���������$��%�z��P���H88D-�`xi���H�\�L1�
��Z=~���{���^wxe���
3h�-0 �#�f��\�KL%�Es6|j�`�7S��L���<�6-�12I�����@zY�� ���%�������$�������'���1��C%(�S*T�R���������#��J��u<�P')��rRu\��[�R/���J��U�g�qP�k�d�nq$"�n1e�rh��AY���xK��POU �:`�������n��r(e�=��s*�]��1��$�biT�]^�����������F$��}PE�>w�n��`���#P!�-��.<.E�
�H��.��1�2����r�I7V�����)��$0d��8�k�.�0�[2�fVq��X������\����f�`�X~(W�+v(�#d����,A1�/wF$�H���x��2��z�Lq�5������&G�2p�H0��2E����b�.�3B�e���Ts��e��j ��Ac����2,�H���Rj��1�i��?uH�Z�[��qycyu�U`�H%�G�V���)��V��*�l:.K��@t�L)"b�b�?P��gDk��a�����7���L1��$*��A����6���K��5�p	�L��#d%F�#����"ya	g�����I�S��A-�A��Y\�"�(�B������;���w�"%D]���/@:�rF���l{;?��U,5o�5��t����X����G��X�x�_���%�1']�r��$���25>�Lx��N��c��*�������P�Vp�Z;�6d�{
�5+�3����2�kE�z���^������d���M*V,E����5���/�����Mk&����+����x�Y�$Y�\�$,E�h9[6��M
��5i���HY�~a�AX�h���_�:,{��d�r�����/�56@��i��.}�Q�� .�S�RZ5(#|9�B�F���@z����#I �x���x��)��E��5�v�$Hw2-�l�f<kJ��0i�e�6�O�����8a C�T#�i3���M��P��\���=4})��3��d{f�>�f�����O�zJP2���EJLy�/�S�$x������e�Y,���r��u��s	�s*t��[��Ga��H8���K��b*�������;x�)�,���C�I�NL�[����2����b��VTR#@���og�1�
�:��*�#�	��(�����XD#�r$p�@^�tY�h9��YZn�g�C�6����b��z~5�.3����I����p��5YQ��+�ta3�1���k�����9�N�R��r�\����F�#��a��|���0I@�pK����&#�J�3���F8��V\[�.��Y�����\�q�.b��H��1�p��K�A��W��SO������)��U�������&�"S����M��Yq��!/R��E EG��7H�B2*~}L����HQ[���>��X�I5�8'F�,N�0r��{��T�Q�i���M����G2����fAWaHv��.��P�gM�j����I��1Sx@�*�G���?0D�#8�8Ui�C>�fP����[3n9�|L���'5�-�e�����pzS�����3�����L�!�;��G��+�>;���f���~��*^F��E�U�R�2<7�N�sdU�!��C;������b��iX3n�����}+�z��[����~����y����mm(�~�0	��@2k�#3�F5�M��H�?�y�"�i�����u1~��z����`�w��NYN�i@�<,�(}��0(�@�P7�,�N`:���:a�� '���=:�&���`�yt�bF�pn������G�����x�4Gc��$t"���C{�noN���]z�MO�VF�@�A�;��a������I�$)e�/�b��d^�������hf����b^V����2\�fFa�����D[�+����A� G�eF���;����t#D�:�����Y�0�[��
������Kuk`\�B�����&�0�9��>��X^�"���T�6B����0p*�BLP��e�7��E�"VB�M\i#���X�;�M���(�0'����R1��I"�.�L����R��A����r%F�#�<��X2��� �@G���s)�$&i���/����83"���\�d�Qv�0�\��f�f2�/�`K��Q��ri��S�F^m�[�%/4����fX6�B,�����)-���K�d^{H<*����D���G^�����Dq�5�T(��������)]0����"Aq���Wa�[���������������Z��p����F�k�����G
D��b�{.���+�)��@B�u^��*M�!'F��K�����W��QH0�����_2 ��#�Y&G��.I���RA�K��A@�K%��b�]�!/��J�+����6��`�R#S��{�ZRp��'���x�7����tb�X''�I�w��*O<��&�9L~]3R�:U�:V��j]�R��������l`l*DF�)b����5 ��[�K/�=�X0v�#F��-$��sl�����h�����T����m=m�c�%d�h�=��E�Eh]���k�3�=�i��js��B,��$^b�k��W��a���KS�����'L���u�c�-��lE�Hc6{3�u�J��@k|�Nf�5�����2�%g�82���2���;1�������d���;��0 �f�%W+���2ip��d����Z�a@��B!�Hdx�����&k�2D��X2K���3&����I��*�%.w�q�i�b��;k�\��q��L	9a3�~��`� ��lD���L�2S.��F��L�d��=��RU�6<�G���T��)�3A�#.�XG�����e�oj�q|�f�@��9����;%!����8�p��"c�$�]��P������B�],K��)��g>��{�D�;a�wE��\��g�?�� �RF�%#��������o�1B�a�5g~!d�$:9p0�����q�8�y�`&���tt�����B`�a��p�q��A��JD	*��4��G[�
3�t�I���$�b	������nP��L-H�Y	�/����CP�l����a��Y����	<'j|9L�Y%p�(�����7����BF#�NUofY5��yw��H��1�*�dL�:F@U�������! 4�A�H���Cb�e�$%FR������.�G�2�T;-�$f�p���T,-3�*;`V.��X��<���A���O�>m�Q!�~�1�&��/�E2��$8K;�2��������#���h5{yc�K���\��������Jr�={�{���%d�[*�����"�-����u������KY���|��L-M�c�bU��*�E�emQ��hY�s+��W+�Jsi�N	xYN�%���^]b�&
��V�K�U$���mgf�A�gc������.EE�B&\��V�`����#�k��S�n�p>��3ba<p,cE�J�wG���I����\��j��:�
�mm���n����������\���|�;�z��,.Q�[����h��
�/.y�>/rT�
C�	3�Z��.��E��b
��:Ic�r'M����I^�0�����KFa���
���ndsJ:��/��q��-%x8J7g$��o\�DW�]A�R)6D)h1��d�d,��r�(���1�3w8�v��*�B��#*�LJ��#�1�@�`��r��NE���`[��#y��?�XE&S�x�R��A���Y���fL����������U�M�YnSm�k7�J%<�tds�����*���[��(�\���g �x9B���F.�L�<�2J�%	66�U��I��p{���0` ����g�$�!d���L������E�<I�_vpE�_����
!�uK�N0�a��2����B,w�����^�D�@���y`X0v[�2;#	uI�t��(X���=�5+	8&<��p{x2H�rG�sm,)R����C��/���YL
e�
�kv��v��3O�������0o�@bQ�Y����E��!Ab��AR���(��NW�QE*����������u`,��;�y��d� �c��]�sAK��dY��2x�t&���GK����F
��\h�6�'M{[~����J�����vt�tc�)_,���@Z��k]��y�JI�-$�����.�R���u�a�<��6+����4��\��L�5���e�n��wyA��3����0��2�l=�t���^=���kV��G�o9��L������r�-������G4����@N7�b���W�t��`b�]��4b���n�����A�,X���b�Os�4���I4I]�'�r*�-81):�lF���
6�.@*���!���P�G�X|�q���l��]g�<�R���`c�p2(��EE�0��[�L�1�Xr����zk�1���������s�Z^��������]�
ojr����vf�`;�,�d�A]m��w��)�d�I��������a��%�=��=!�IwY;�00e��.#��	f"i�A�����z��x�S!I����y�db��o'8i��B�$
���}S��%��5�d�.!�d��H Z��qA�w]����%f��I��$��t�YG���4O�8Qpa�M6��8�W�����l\|���%�zb��-�����6-N=�A���L��R	�`3����@t=��(3��%x�1��M��5�[2l���I�1�0��N���ub7�.�f���8�/�3�&]�D��0��������)*��,�'��p�P���\�n�X,������K���IgaNa�M�\�H��yH��$���,��7`3��0�5fi��0��K�P�d"�K>����]07C��~q�����[��_�r�F��o��gk��d�����!����o�������%�����p����h�2�4�O�e�e���e0�����,:�$Q�f�-��TV�I�IFDD��.�*���0��)����l�1��5N��|��F�]�����@�YA�4�������"bL���q�/�@E���aqAnL�����f$a2�����$!p���~�q�!�����p��2�������XLx��N������T�|���]����mi]�t����y)9n�f���)��=E���,���8�Tl�a�����D�������DR�����U�w��B�Q���P�2S������S2H�v]�{�M�
��|����4���b���h�������_��������'��`��,E���`2A����6���������Z��{�l���9��@<_^��a�,�����f���U]����g�W92.@N��(�P1�=�-���v�5��-s�d�y���K`�A�H
yvX��x_U��)���Ph���������I\z��,���D*-X�������-������aM	�����A2$���,W��$�A�jU�(�8�x�"���X�g���c��SF�C�E7=���h	���|6�;���;����@��{�> @S���<:L��-�%3�
������W{���0���^�k�.�9#9s2��W�e��������E���(v� �����Z$���k� ����,2#f����"�9H�������G���N_l��F�eG��@���#���oET�����e�`>�����ng���>�b�����#���x@v��/H#wu�vx>����]r���};��E�os������m�0g��1��|v�������\px��`�j20������K[������oZ�i���R��#������_�o��W����<z����������G��~��//���Z��
_�z��������p���\�B�>>~e�/����F�
�a4000�;�������|�����[m���h��u��o�{�`�`�s�/�� ���:�h��}>��>�����8�O�h��'B�2�Sb����w����!lV�y>���1����)HE�gm��Y7���g����2g�A&a�#Y����`��i����e,v�t��t�2������5�����������^�}�}��#����;��C��������M����C��>��|*Q�r����E������o��\���RH� �x~��|[W�h��j[iU��H"�jl�}.E��~|~16�"d�3�#�>��o_���y����tO�>�u|��/������z����@,�G8s�"�(�����e<t��4�Ei����|t�����������P'��K��"T6��%��.�)x�JE&
J���"�����l��r�+�jz%�t����~z��7������/���_���B'dqYe���o'��;g�l�-X$��%���5�@����������#���f���zF��H�
��	��2����#u�����oH�S��OI�6Ef�50p�8���O��/�o�u����m��?_v��#G~,�t
�'K��k��l�����u��f�=����`!N
�(w�
c���f�����8�����[�,XQ1k�,��3y�HB����������iI{��7&��` F�-�<F���$1w}
�C��Pv��t	����/��A�������� &�AtK�o�6*?��;4|�*��v���D��Gr��9�1`���#"��w���
�JB69�\y�L�9�3�&
��nn1kP��m,������r�m�M�_};����'>u��7�D��#A�6.�S����rA6�I�[L	����!�����&=4f��� � f�����pH���&��<-8������1Z����O�� ��������`p�-��K��CH�I�#�s�M���8��2��	��
��N���`������Ro^������N���+.�(��a��s��`� �n�qiP�~s��?z���}����?���#+��?�����������R7��h��[�u�������.��r7��#A8�S3db�S^�
�L�k.���c,:2����-�h�Z�$�mfK���b�V�f���1.
�4��Uv$1�#���������\���0Iz��4|��#�K*�jF�Y��CR�H���J�Q� �e\	-U�X�e����`��!G�����X����[��M�������5���O!��G���������A�%|9X��-?s�V�X.��&����B�.}�<b	$�q$Fw3�""�cW��H�}������<���#����-�����I��d���5��_�-������s��S�����_��G�Uq
�_����d���$� $Pt�T�EK����Z��F��~��+92
��c��H�����1��p��S�c``��7e������m-@5k�V�o[6�)�;�gU����c���O�:���P�t-H��O"xb��[Q~����<�z�c�����������5= �
�n�'K�&�	��A��s������~��q���l����Q#��j����$-o3��p�F��@X#�����WGr��)���h����N6$��QtF�y�����S��`�s�;p���%,d�K
�(�`��B0��_|���>�RouK �nI.�6N���Q�D�!���OY�u��n 
0�h�,&=x����q�Xv��,����1�J�p��<*b�;�4z �K\��a�*�h�$9��5���4�~��X`��L�TT����p��K�\���(�Ght��h��V+G����W}��qf�R�bG��7H��g
G����6h1U�)�0R?��g�M�d��<���d-�������3g�	����RF6��g����t6/��=D1%��'��%W��!� �����,@��D���'6%T��0b�	y�$���p���X`-.���#�X�%�/
���)H�S�G�����$�����t�r���5���c
0%�#�\t��$��9I�l�t��8�f�G�B��:H�!�He+�H�b ��Q!��x�	������P��C���f���A�)8����e�VZ�R�8;3�3��J�e���Zf��BD�`x�g�-�V�T������:���J�I��TT�BVr��T�b�X+6��}F"�.
����.Tx1E�<CK@�u�(�!)�n�
�d���D�E�2��,��v�>,Q�)@�l�TC�H
��%
S���	I�0)���R�hi�L�5C�
�������/���c������'
�a�N��
<]���w�X����fk��E��.-f�+S�L�zS�J��J��V��i�����Z$M�����B����a�c+V��
���=ao�����dk�:����miYEVT�7.�HS��(fuY����1�X�,�
~�T#�-�P-Y��f$<���%�;����)=<~��) �^��d�_-�8���g������>�,!�K�B`-O��2b^ �{�1��.�3~���'�n���tF���k�7O����v�����ugf���o���>�es�@.�%&���9A��@�j��C.|dJy���U �%ZdDP!f�TnS��	S���R`�R�T1�b�ya#��<<�� \H�]Y��3u�v5���#FF��]�1�������mv�S'��'B��*EB�������4�������nhaCy��@���q�bd_���	S���aL,��Ua�*�<xR#|��������ac�.�������28e`*e6T��,Ml�XQ��,/��kX�����z��6�R���������6x4@�E$"�<� n �!)���S6\���X���%��WT�uh%����E8��5d�<;x.pm�3�����!<I���e�$�5#�J���x�&���EfU2n��dRn9�2�cA�r��L�hM�]F 2-9�T���y.bd�3S��g�@����D(N�a�@1�: �P,���Y>�Z���~�R�:���n	S���Y��0Z*�"��� j�!���q(�=�t����9H&��B�����Y��'�C�r��#��-R�B�J�8�aGI��VmL���*�����Q�c��b]y��AZh���%2����!"<�)� '&A^�0B�M��Gc
Ph`��j��0�������|�/W�qWv-le�^�{�^�����R�k�|���a�Y0�]��D�,���emx>�Xf����A&c6
��,5����7m�L�@�
��Z��[�V�%�i�
�V�2��C�d�.E]���5i��0��)�����v���q���K�
Q�|�I���i���/}�s	�q�)�a�@�\�D�?�8���w0+
�0���f�`��"��� ����3��n���4&�Q��������`}_����bg�H�����a�H�1���J\t���y2.�B�'�z�������Q$�\:�lH��T���%c�8-�	�}�!�����dHa�G�x�������O-0G%�����b�#�Hc�����>&#�|�tv0���|���.���&�k��I�&���m���-�p��,�"���,I�v�E����<�K10�����E�,��B�,l����6Q�W6b�H�r�Y-EN�H�CB�L)L��QZ�&�n	G��$o0H���<!3�v2��:t)�\7�{���|h��Q��GT�����������#H*@���~�f�]���r�d����x&�n������Q�A,��3�2n���Gb\�]��)�J{J(=�A��CZ,��.1�kl����>E�q��0�<�@N1�i+�X i���S&���jTi`����
�����Yj�u�7J���/:C��qW��~I��t���zJ�z�U�y�6�N <2�g�H6;��@B��b��0�(��SD8�X�upJ%��~+���%n�$��\������30�����~������;6�����z�%�%a�xd�jX7Q���%d���Ig������R�vWt�R�"�������G
[�>��~\���-?k�#�I�;��Mf�d�^���� $fW��=z���:��M{u;=Hwpi�Q���y�����I.�HXs����yr������a��-��N��@�z����/�j������X4_��o���
 ��~D������k4#�t#�l�����k@�xc���*e&���>F@IDAT���.lC-k���U����o�\y�Z��.����Vyd`�����/��f���S0""I{f�V�����,��cF��$�BVJ��q^��b�����a�Vj;�����+��/�v�R8�'`s"����Y�$C�����1~qEE�����lS���S����W����Ar��E���b
R�y���g���/����S9���!a�2u�x�"���	�9���`����l��BL9����9]^�h�+K/�����RL�H�"�v��"Aj�{��2������#�_I:�Y���uHF��`U1���Xt	�G*���A2����G�<�&�.JG2N �O�2�b��c@Hn�v��$;@�KG�@���L�����`32���%a6IsJ���G�����?��G�2�EH``�@����XB0z��% �����N��d�P��l������P�yx���I��?�/l���N��eN�C8.�bNa9��vm�1�Z<�
����� r��"�������P��/�.�R*���1�61w��o^s��gg�JEkr��Q�p�)St�XD���$<���e���$��J�IG�a�]�,��I��Y�Cf
3/~��l���HZa*��k,8G����W b��/�I ����6����L6�����d2���@"p��7�Y.S�```�����px��g9����=r�3}���w���2�����Y��V�e?6��XN�X��Ek�[$t��
�Y��kq�5XH�Q��EBW������y�Dc��������l9n�,�,j�pHZ����<c1��Be�����$k�
����K.�yd�;zV�Uwq�"O-$���@�80hZ�� ^}��A@�%F���G����0*���x��������%yv�-$�2&�&�$f���h��������tKe�-���G?v��������h�RdS���Y{�"��A%y�e�#�2�H�JBjd����]����m���]�.�r�Q�@.�8q�Gw�C�a��=Z������d<S�,�(�b_�a�J�|�829�|1H�:����Wn�����4��3�Laf�z]z�2��=Il���z�5��K\x;�<��0��>g%K���C!!�3`d��0�`��	�M�s�����O�>���p������n9~fe�}�W��	���0S9t!W	�?��)�sAWR�?V���]�J�y�;���|��d�P���c�
Z��E�"!� ����q]�;�E3J�#Hk��+������K��d��x
���`�C�.K��z,��:T�C;naX�T�'.��\��sM�uI���C�e�<�����1]g���	��\3�2����g?���/��|w�����|����
�E!|vXP�\�*�����ZD\�D/����@��Iw�M��!y�D!�!IK�)N�b����k�&u�~���DGK-A����9xx���8�E,�
$�&a�\@":c`���D���@�e9��O�-.i3S�<w%H�-`�<1� A\���k���i@W���� <r0�:�E�Z\�7�����0w��V�el����}`@A�K���S�J�Q6���]aQ�^��f��`��e���5x��H�s�GsOfY�TF��v�������%�����C�w�c���j��uX���a���U��E-�:t%]��xG�7$�������$�j�;�r����E�6�=���DE�����~�J�M|��IL�d�`���i���v��@����;:��^����������%��a"T��s��B��������;i��^�����t�"�>��*A	m��0����:Bl������$4j�����G�82P����:/�dM�����p����!G�H�k�;9;Z�E@C�K�s<B�����}���`�
}f���T�]�	'
�*���S��#4�%���,
j��{�����@�.G����/����N��[6�t�qHf�g_�����I3����p�X����8L\}����[}[������v�k�����������E���Yra�	k�����h�#}�`���6T�=��W���0��8�m�����E7�#L;M
c;-�*���_����d�ar���f�CL�B����-���XA���o��G���(I�>�#lR��.9~w�������26�y��X����T:��v�m�u&�����a��U��-��f$g<�s�`��,�x��nu������Z���Lr��vT	<��)�S����xh#vddG��EJG��M
����g��*X0��-�;��]�e����z����������������������u�z�����G>��W��+�������xe�nm�m\������?��'��3����G��_m�3�������k��G�������|��o^��; ��?Q���O�O��������~� ��DT�x����I ��1��L���H��&��Y?�9��_��{���l��	�����9�+�|q����'���XAU��l,]z������������������������o�����r�c����5&��t8�C����3��e�]Y+���;�:��F�$�����y=�<G����Z55piL�$�u�n>a�nT��%yG!)��d����3.m���9�>�������y���p��k(-~���������;>�1�����}1]�=����X�ZG#I���>NZ��
�J�_Z��#��&F���L��g\��� Y���X��?����ea�,����8�tL�*��������_��Z����/��p�����=�|������-8��~-��@*�R��!�[����f��**��H��]vv�j�<}S�cv��� ����[-����E��Q����h*x:�Q�����p,m�����.���l��������_�}��3��<�o���A|�e<=;�Y|�Mjw��MM�3�xp��7s�!�Y���;��O�)h!������BP8�}w
|Q�J�O�I5��},���Ou�7��
��[2�3�<��D��2�W��=������eX0f|��$�_w�N��L�����g���88}�E,���F��w�G,��/�Pg���j�m�V�%�4bp��a�*v��U9p��G(���%��[���XZ;w��/�����������;������Ny��c4�5	������0_yU3��%U���e�j{���nM	��Q��6���t��%��c�#���U���B���e��F�����f�u,FE���7@�oB#����7��6�Y,*_����J�7��8a6���g-f�Liw���3R��z�=����������?o�����E��/]l������?q�������5>�
�D����3�����)lL�0��D�L�s��N1]~�]ajr]v�]W�T��Y����V�z�&��T��`���Q0��P��o��-��_(������4.3�2��@�dj�����"F��X(��?��q������~���/�}���y���q��cw������Wfm�������E��s(V��A�q����:�Y��5����NjJ���D����!Z�{������%
��&�e������������{���nH|ey\��K+������{(���1��-�%����oH����K���{�+K[/���)A#�/c��5�w�|o���e$O���2��{u*��m�(�^���<��
�>E���}����e�Tv��������KX���}�o�1Ie��3��I��i�u��,����0�J�nM&�~(�0u���KEZ��k6Vy�N��a�!Pv*�����;6��#���,�d��0���`%	.pnyY60�=��+��81�
i��'~!��G����=���2)(l{��A+��G:�nFRdD�����3�R�����<����V��)�,s!41�W�O,�@b���`xgU���p�}��A���zfM-�����l���i�0�a�D,��w��1����/�����^Y�d65p(����^
���%J�j@�	��w#-�tU)�h�UR	�����lL��0�t�/�Y�bR�B`�cJ(�(�@�x���5��������d�F�j���)�7��,�����
`�5)���3w|�G�� �c�l�t+T �}5��"w�&���Q.��c-��H^�!��@@��I�X�
1�8O���T:D'wA�3�d��2��q�d0N�R��$(	h)J��r�I#@.�������������O��`�=�H7_i��p�,�X��up'@�Q�+��(4�0�jaZ� ��VN|�t�q� W�������EG�������R&�OI#�$wx�e������b�1.��@�N�-T�����d3���pk���K���D������T;��5*�$����N�c����]�j�(�Z�Y�@�����c���`�	�5xT$��T�A�/d������"/���H8��d_Kq�9"iF~Y@&u���52t>�6r��4�4s`$Q�y^V�*��Va�y'��Ut�m>Z�)"y��|���0<�P�1b�����j����F��.
f����OK��O���B�W�r�O�p����e!KUTX�W"G�<��0��|`��K%�����*�;2�b#(~�����F22b��Wi 9 ��k���1.8U!2����-A�EL�XU��,�*D~��B
���KC?�f\��m�3b�R?�Eh�J�����kSR�(�h����#�Rh�B*�kK*GW0�z"�8r����i�tFqb
�"G����EjaG��h�dG��������J�$Uh����Rp,�`�#k ���H��/����:yY�-*�a,a�a�v�"�6�S|��Z�7������;eF0�!DTP	�H�0��:����� d���"3��Y���#l�g�	�w�GX���}82o�������:��U����E��Fu�&I�`��%/l�[�e�Pg�#������&6L�$;0p����e�u��U�.��]$('������*���6��3	Eb���`�p"@���W�����V3�C�y.��)�P�j~�������a$�2���aDP�0���4%� �8��8�]��e��=���A��A*��@���kSQd0��O�jUh��7����$������[B�������qYkDZ�F��kdx�_=Qb�q��.N�)
��$�L*<0�O�(��Y�3�%bx�����L�O��VD.9�c{�N&��H�Zq
9*`����!:�8�$k��N�;�e�VB��b ��acP�pa e0�LBb�.��N���tY��3a��qYCT	�,�zE�����!�}`��hl�� e@3��r���c[qi�-��5*V�6��,���	$#v����`��D
^$!�%�tW��-2\���"}}��*����YpV��@�i�9�$O*L�<�S�$w`0%Yi�
�)�����C;�n9��0	���,� ��@�����P1�j�����w���&-Ff?$���sIGlJG�����S�0,�b�Jc��u������,�aSo�V��*SLB� -3��w�,� �����x�D�� �Hx�g\���X�M��G*��0 1���O�Y�^Xc'�V�a
\"�P0lB��*1�2%�� ���?Ht�M �2O��������a���n�*1���@�����U<��8b
��Er�U����eR�
d��gE��5����"A�,Z�e^������R
�N��7��M��`�rC/��-2V�L���a
������E"a��b9����P3}�����J�.��"IB�_M0�����p�1��_w5\� ��Y�};�$���b�7�AU�E@h�Y�:��c��/|��]^�rf0���
�`h�@b$��Lq���4#F�.M
�w+������@L�z�[\�G�p���,�9u����D�"���Pa9�������1�$�q0��4)/g@S�4����$o�*�BN�<<�r��e�\/�`��<l�f�-;3 [�s�
rg�.0�Zb��4#�8��	M�``���J]��Q�d��[@J��kI����#��a��eK�$y� ���~����D�]vs)�@E=����5R����` 	�0�J�*��+�,)F)6�=�D�>���h/���RilGd��|e�J��J����*��QG�8�	y��2�l�D ���,Ky�$!�+@�5w,di��slB(4e�W��MN�,�
t�����	'_X0��� ��d�r@/H��_{�rt��"c
Z,��
B�����_��e���"[�s�y�q�h�b���K]#���|�����%:����j�n�x ,h��d�z�sM�f,%��S�B6/���!��F������H���b�
*���
QTx�A�1��`.��$��KQ+UD�:y��')��3EFH�UQA�e�e<H�e�)5����p�M�Lf)��|��o�N�	��0�I�3`���
q1���O�>�����t
�I5s6�e ^f�P]��g��,:A�������
6��hI��%��)�t�.�����T�1x�F��TrY��-����&�	�X�����
;�]����r-"mW�E�JE�d6RP;R�$n�+���S���9k�oMt5&5r� �~��%-�_��qdl���*P�d�����xb��X[���t9��C�>�Q�0��,B!)mK����Z5�<��L.U���>�3rF�A�j�2�e:]-��v�0��9kg����
����&�>��)#f�(.�Y��#��p�\q1�B��o
��?	�����1k1�L����e��-�n�gD�c��,���g�p���-�`�<J���o����*fV.�M�qp'Lx�{���lz����)��r	�g8��*�D�U��l>����A���K��,}�����.6J�}��!������
��sO��`��,L�v2���j�PQy����C-��b���0��d����C\$!L��n���o�2�~��K>����� ���S���Ah�S��:'��c�b�8C"�H#�r�2E��k?�k����&���Z��&R�@���n�o�#�Oei��d/i����T��'����j1`�qd��qf���X������M�X�!�yw��T/��t	�Q�S��Wv����q}���Z�
�5��Gl�����=�{�H�h)� #�pL"���
�YR��$#%.8�����Q$�B-����A���
��xG(��1���X�����j��gl&�F�Ic{�����Tq��?�>��C����<15#j��+��= u3����A,��:���V b�e�"�)?	RT�Q��"�[QqvB���1&�2k��<�B+#h���I�P���X����t[�,X��8�Hjto,�HK~-uw��O+c���ax�"b��k �!��$�"��Ed�x��f���"��L7�����dF�L.��/�Q<(Sm�[I�m��O[��o�#�j�GP�fG8�;&�PN��Y���c�y"^Q��A�����dS�T/��� F eDEx����Y��}eo;cAf���6��������l!v��[}-(���9�	/
��):g�h�XvF2b�-�v�G *��H�`�-�9���@2m���
m�������@��u^��� N�VKv��a�,`[vp�-���u���7&���L�r��x�IZ���>��D�ta���k���|���������:��}�>��T�2��1J�f �!�^�)_�bl�R�u����Pp�b_�{<����f/g�����`��5/m\HIagu)��ck=�P��pa��$����(J6��g���G�	�s^����K�*~��.#v��Iu�/ub����a\qc���)�=����*�
a�������
N c�����i�J��a��C#��e1+D Q$z�������\[i\��A0T�1�0��}�$)/���<ZZ)2�
�	��a��d��)l���pd�)f�,p
�ja����`�
D�0�,|�� |���@X���S�����ef�2Yv�z_<w��#+�?t��������o;��-G����0�6R��,4�THb���]��wT�yc�C�Y^��
J/f�X�����J�<����,��E^�3�jK�$��E����DQ�� �x$@����F�_����)(b�2��w�������m�-y��*t 1y�����G���2uZ|O\$�bq3��e���3��by1f\��r����5��`��He'6��9;���2�Dx�D�������~q�	��'���Q��G1�J�����?�����x/r���G�w��c�n8�G��{H_�TuR���yi�4���*�s-d2�U����F]j��1F��tc������*�W8����ZR��ai�$�w���E���Vi�Td�����C8��gZ\�LK�*�af�?3�$5x�<1�P���4��d��"<��2�&@��T0/LY�1-�	�;_@&p.�2$� !v������2�(b���{�4�N����,X�%�Y��Qf����3/�F�e�$d:���>/�����]{����//9q������q��m������r���W���`��l�D#�X����m g*�-��..$��nb�`�$.�SHFi��l�]��=����i�d�u��{o�3��$6)��DQ�,���8����8�a� ��g%��?Q�$@��0��YQbx���m	`��� ��_�y�$R���Iv7��p��z�����t�U��n��}���g�����Yg�}v�D�0����6
���D��'��aD;
����������B0��^�4���W��GN�\B��v��Ybc�`(��M0���)�lE8L�)n����d�hJq�	&c��0�������;_P�xpH���F@}t�gi��Q���@f����$qJ~z��8dde�����Vb�L*1�C��'�)o�l��@���������C�b�m|�Flg�4�bw_��	Y/��L??Q�F^ ������
t��H�"�AQ��1?�m~�/�� d+�\ 
��&����wd�q9���v��&I�h�p����E\b
W�����Kb�~t��������i���N�y4�CAY�0����pcY�J���nla�YK%`��������5V_we�`:��X3 f�$���S�O����\2z�O�SC�3���$�
��R���G��QNY��q�B**�Ql5
q^0����FI�P�C#���%�q�����V �rO��92]�C��6Sy�SH�q�`&�Fq\��`�����f���i�;�Q���t�o<���� ���.�@��#~�In[���tu	1f��S��o.�����1�mIy��I����Xbn�����lG�������;����:R���&`}GI���02F���T5��P��wpLyv����-�.��\1�c��=z_��� SpLV:�������Ek�.�w�8E!Ilu���`��}�xQZ��c�C��8"��t_"I�0�8��Y�Q��]���m� ����������X|�����.�nY�l�l�l�l�l�l�l�l�l��Y��-s�v����~�vc���w�����������)g�g��k��V{��V>�;���>t�����-�7�G��BX����/>[��yZ5��\{����Wm���B�,�BY`������^9k���r5������K���o��UY����
hKT�~g��~��~��v�������U@������_�`�������f�5���0����V�X5z�nL�j�Q�cU�="|K��Z�2n
����������n��[�j7�n�	�_RZz�H@
L}Gb��_ex�}U�COK����y�{&�B7�n1|`��k���vC|��������\�T��?��_�\�}cI�;��w��~��t�Q�
�B?��Q�X�9���~t������q��[\j�s�UL�P���E�������K���;�O�}��''8��0����c�T�>>������������������M=��
V=�����BHc��#����C���z��������^��Z��K������^?���4�D$L0vX�)�?4���H8�M�l�������D�����	@��h��|~0����n��g��FJ���,<����;���d��N����g���+�
�_��V7v}���G�Y����q��Kn1)�n��@��}fj�k����G1#�p_��6�H>I����������NO����
f�a,����YW|�H�PD�i�3�P��	2�$Z�*����C5��y���Fm�z�"���KC�r���}��0���a�V�A�a�(QY�mU��cq�
��XA��U�ma������TB�I���!��F����!H�(�KLRa�&���h�,��C*b�W_��tC�b���I�R69Q���Ww|�.����:�0�;1��	��/:�e.l���
||e+��/���:e4��C|��>�����DT�`(�XOM��5F�\HE��)�@ �GN|�V�<�0Mb������+,�z�"�k�a@�!���]5f{
2�E�hP�#Lvcp���(&7oHv���?x������������x��Dbg�$}������7���Xh`�����-y��9A\��j��D����7��� �H�p(� ���C/���Fl�8!������`�	4���/�0 ^��������L���L��6������������KL��������L��''�h�
y?D��U�ch�A�����t�@jD8���'v���/�A����KT��`��k����<A%������p'y���A����w�I�
u�����n����h��e
��`���
}��e:��.a^}!������SV�1��(��cR���_���Y�	�R!L!{8������5r�(���G�mv����z!�����5������T�$�L^Nw� d��\2`Zs�;	N��1�b=��1�y�S�BG���������!d��""	!]���b�mM� ��K���������]e�����(���^:����h��������=~�=�z�0���2-���d�W~�K�u
�<!j�/5��2
����7"� �0i�/�x� L�����*x�Rd����*}��>Q�+�d��x���q��^��� ���T��	�XFeb���e�8E��!���)"p���;�����<T�L*� �j]`0Ieh�ev��7��
���0���D(BZm�X���E?����-� X���}�"E5|��Q�����J�%��1�z���3T\"���n���9����FhK\��|��8{����!��O�WXx��i}�9A�66��(�P0�*��_�����K� n�X1xBv�1r��-���xRL�D6"�P0���jw@j����h����7�	j�t��0�7�8���Q�FLd8��)��DT����n4Q��RL�3$S������l���`�K�`���v�/���N�<���1F)qw�Mh�#���`OJ��� 082~P&L8E�eC
R!6�L��&(�@;�	�5�#�+9�X��#�F�Djh�<��)�;k�Nm�Mr^�P�����&u�e%}��<�Hq1
�A�y��h�%05LF�,P���u*��	Kh!?F�W��P�z�"n�!S?Y���/��N42Z� �".�Br�D<@�HR�=�Y�xD�I��&X�S�_�� ���E�t�=�%�N
Y^6R�;C���"�L�qN�D4��,d�!����K�1�/}����I������h�����"� Nr�(�_sb����B#O�5��5�c�g��^�%���(^����U�������������D��It������Id�t�"��tqw
R;��X����E�������.�:�'��24H����k"c>�V��`��2�)"r|im�x��B~*���������0���:��#�#���:
eLm�AGG�BY�"(
���IBmh.Q��DB>��@#q�"��hE
~��(
6$�^(���+*�!	�I��Kr���l�5�TvC$�����C�!RxS�q�����d�
Av��$���
�0��J 0�u�bv�p�����q@Cq�6z�@������	�;(#�/��S
fA�_�����
F�"$t$���"�����(���'lDc��_�4ow1vc
��W����A�wpv�8��ES��Z���K#"tD��"a[\t�7
�ds#�o�`t����2I�[���S���4�\���K_���J1
.�8^�
�C�,����1@ Hm�XB/���]u	2��3d�9^fv���T%�����j#�"L�����,HC&	q�Dx�,�tY�a�x�����T|���z��'�@wFHt��0�)�,�
(>���MW��vB�}hJ<A�zQ�� e������
�������;�JU�$����Z�L�����G��j�$'^�)	���#i��|�H1�t����D��3&F��$t�$���`�C`rJU"_I�",�,���(��/�I����:����>s�_i�809�`�M��)$)�D"�"��/����:�#��!�=���$t�o)�� ����o��e,�E��k�k��.��b��}�K�"G�q:���<�Y�������NP������=�iE��<��xq��f������!�P�B��e�A����I��"?��RL�U�O�v���#�0p7*5�](B�D$b���z�@��2�^d��[qa^���� $:.q8G0��_���	��"98k+/b8$RCT���\Ce�F��
��-�&���a����3)��$�]��*L��W������v�	���Q?	�;d��H|��aKk@��vX��>I�AG�s	D#$�����!�G4��e:I
���<�lD<��"N���}�����Xc�^BK�-���@���)��������K��������
�p	���K�`,�!$L,�_rbdP��O<Ag����K+�� ���d�#F�5����HbP��*�����A�T�)b���(�a�\ta�����>��"���l�_�C��Y���/-�F
�P2+��Fn
X@��&��]�w��/�����qc4�p��<�`�O�������M��0�"�C�%��E�l���`
	��p�������&��p����JG����R�e��3�^D�i������J�/|���dF��<��4%��>�9w%�e�����V,0I��+�����0�����V
��y�0�e��$^�/�4�BR.IFN�R�@/(h�����DjKM�KW��#�4�������I�Ah�?�7���p�����(�����7A��q�rU���H��
A�L' ��(
u���z�N�X��U)��6��%,�(Mw��������$���]��$|��
2�tL	�y��gt�����x�_C_��p��*#; ����`�	�����0N�Q�7��a��(����'<�������BB��(
�8���t��.���$�IyCP�UsFp(�?�����+�.�w-���R�0C*��M�tJ�H��x���2���w"�%C��P�AHl�TW~��%!O;�O j�)4�F�� ������F0��6��e�u0ox�%�e��/S�Y(����2��MfFA$�
Y�y8�7� ��G�ZtID4�a�����o�h��I�q�o��Lmh���$��#�,�&����!��;"�������0.��K
��h�_vC29A1��z9U��.���xb�&j�����_�PS;�q�pa�]x�(��W##��/"e:$��������5I.��b��I�D�E������;]�rBp�����Q������%fg1�Bq�!p��6���y5��Gp.��Z5�#�DF��Z�"�����	\�I�D�`8��m���!���/�=��ta��Uu�z��bL���h��&�
G;u�/ 
��;��T<��d��Ot��X���,���
�I���/yr�t�	�	�1CS�?�'$PP�z�`7��$���[����TN@"i38������$e��UG����^���
���`�o��_RW���0��otRD&�44��~�F��t,���n�������f���'���q��"#��_��g8a���������%����Fx	8e�ilQ��1BR_C4+�A ���~8zJ+R�^�#�KL]
�� _'N1��Gh���"8
xh���"��N=PAG�%b�_d�/:�W�!d��G�0T����H1Z��D��G�)��/j
�%��sT6pb`���s��,���#
��J��Ft����}�!���0�2�}j�{b�
9e�0������.S{NH\�&U;��c:
j��Nk���$&	��^>nm�������7��Z�`����dF��SY�`t]RP�����=i0��c���/�!s����g]��J��&G��_qF��z~TD�`�>BtT���:�)��p��$���� ����=
���X
�������,{orF`S'��,i��=�"���D�q
 5tt��p�$�7|��$aF��+���_�
��
(�;~d�����F�� j�Lw6����(&ODl�c;:b�z�0)��M/pDpt���{��o�"0�0��k�0Z�����V�4��y��7�)�P`1!yFA���,���BptJZgC�QRDv"s�Cb��:H�D�.J$�8����]e4�$r;�x�7)�������.VQ#|]
���H#���^P�u-a�M��,��tU/��`! A�eN�����&ut��PA/�)�Y�$����D_8�����E��W�0��3\@B�WtI������Oj��KpQ�,�	�[��h��E�����3��f�-S��F:+Q)r�#����T����S�by�F��w����j�'}�da�_����`�w8nX����G������'y���	����O}�#2	?�*7��;����.�5����y�lp�Flk`
����c���>"�������=��D���`�/R�^hd���#M�L`Is� �FB"�������;I���=H_��E�J*1�	�Q��N	� 8�\7��_�D�Ae
�=�z���������J�U�{�PQ[\�[�C���'��1g��*D"�h���el��!d�j�X�GAsD�E_mp����mK�A��#F�D��C2F��G�4��"�`"Y)@�
9�)�� �i2G�2_�����.�e���
h�d�AP�H�C���o���/�.��Yp��dd�B������%$�!Bm8d��v����h���^ds��n�
���ao����"0Q�Z����M".��e&CB�����0���6u4@p�Y�$pA�C��s�g�W5peO���>+�Qzr��dudD�>d�>M���N��p��Rut�}�"�(J}#h���7]�if�D��20j�B�vl�a
�&S8�>:"�jk��#��D�r���vtD_��t)�0H��0�d�G�U�9L�����6| ����.D%. ���E���BL����1���"���|��K_!`6w����<��_�������m��@k�bR@IDATPvPJ}�.�3����r��������5��������R�T	(+��a���)��F;d�Q@���k��5�$I:��FS�r�C1������������5�������6a���W�]j�9�%!�������i�r���|����HqF�f�)t��N]�+:"H��V;b�$�"���Nc�h$3F/]���E��' �FmV������%���<am�8����!-#G��x�|���i������v/�s���\�+��L��_6AA���V�3.!sC���M����.E_�d��1N�Yt��=E�Hk�.�<��KP� �P
�NY����D�phx�l0.!�,gE/B�7�E�`�*��=���H9������M9]_��
��ptwe�C��;AP9�0x�l pPaRb����Lu����EOqt�)��C�U��#����K�R[),���NX�:���� �p��F�/�cRpt��w�z Q�PI�"{ b��|l��#�(}1���B���$zP����
?B_ �~����}�+������*c��D_���!j?X�Dy��1����Sf���J�6V��6l��2���:�����xM��h�=���(�/�&�lbC���|a��SJU�`u�`���bi��u��1����G���YL�[��P	�H���,9����1����z��	�P�]��%HL�����^rK0����j,//��������x\gXt�l2����M�T����q�Z��_
�2�_����4B;Q����y6'�X������gI�,��#�x�Y��=�Y��!I28�o`N����\o�2�g(,�)������ o���kQ0�Ep���<�6ac|
��*�c��<����fh~�,c�4�6���(+���@@�C��8�������H~U����f����8�l�����������81V"���#v�\��t��������i����lm&��W�?�� w�0���t�-��YL<�����kZt�����8�;�� ���`N���8[�����t�"�)���{�T*F�&;.lh7��C��E���j�J�����.�,�1� ���d���=-:��dZ,�E'	����|���/2db�L������A�|:���xM�Nl��8:f��w�.�i��!U�&����J��5�l��z�)D{�t�N�[��CS�����)�(�[�6�_������������-�N�B�?[ [ [ [ [ [ [ [ [`Dt������������>�h�4������>� C�8X�d�Z�����`���>��*��&����Y�d���W�Y��Z�����6�p�:lK-�b����n�eu�`�Y�Y���3�a�Qngdddddd��,p�J��v�V_^��*��/�J��Eh��`-�*P_U���tC�n���j5wI_�� ���N�UBP��%->)�d@�O��E�^zi���.N���S�������l+��)u����\�Z_�@C�g���A?��4>�R��h�������R��0�������&�H�5m<G�@@��(���>���.�I�v�@�@�@�@�@�@�@�@�]3������?� ������A}�k��F�
A���$Y�f�DAf�C3��?��-Ti���|Um{2������Y�U����}t�(�0E����j��066���/L@bB��p��k[�W
�8L����G3��Vv+(������0}���RA���u��2a�m��0�M6�C�D�%�b^Yi�a@9�a�?D)]�;0��S���}-�>V��x�xhW5��@�3��*xqM�b���,�)8"�����Gy;t�����/�1����Ll���o�@�@�@�@�@�@��������m��R��!k���W�����a�V5��U��6�zQ��L���~�C-u�w�wCV��z�US�kq�:U��F�c�8��zV%��Jg��1U�:I���P%+�m��R��B�i��^�RE*"v�r)u$��5Q���W_�.��)�����$�1V��
�K�m��B�G��&MI��|@�Km�9�r�u�.(�I6
�3:�`�}&U�:D�3��$DH�����~I�����jn����G�v~��\='G�F�@�@�@�@�@�@�@�&)�QQc)1�yJ� ��3��(�V��*M��,S�A0QjU
��PC�G/s��Q%�J�\��2�aS��8�D�^&V�:����H�����Q5���N�U��x�Db�kD�Q���� �DD_U�._@
�&���D3���f�1�Lx�T����h
��.�Ld	F*��)|m��3����p:��]p��pHBcW|�r��f���2���������x;[�W�l5������jk��_u����Bq�&S�����Cih:VM�S
��������L��Z)i����7��b6A�nCG�4T�����:U�cdbPE'����-���Hh�k���U��wU��T�d#�PP�;��N���&��R����TyJus@ G�����t��^*x�=���"4�ow+:�����L��=]$�I� |8�k��R4b:�p�,��<H���8�W����.��N��Aq	�G���d�D$7��������:,����O��J�z���/�:�������w���y`�G����c��[�]U��(�����(=��X���T��Y�����Ti����U|������p����l�T~�KD�U�f��B�_���b��K
M�&-T�(�T_F/��SD�W����eu�^�� ����_��b��.�@@G��,�*�U�J^�ONy���E �rp�T&|��
� 1��iq8:4�8���Yeu9I���(��Q�@0�C\��qXxN��^@#$R��-�-�-�-�-�-�-�-��5�]��l���V��jM��,���<9T���5Wj�����<���[m��#����D�.�_�a?�W��'V�q%�����
��2�Q�z�;���{2Q��E���P-�z�C��2�R{B
p�HY���!��������X@�6�Oy��UxQ���{��E����44K:���VG�����EB,T����U���4!l��P��`
�{�`+����<?��Lb�F�@�@�@�@�@�@�@����R="���-�-�-�-�-�-�-�-�-P���G���2+�-�-�-�-�-�-�-�-�-0m�z������������h��8v��Z�o��c�)[ [ [ [ [ [ [ [ [`j��������/��F8������������������Y�C�({\T�Y�l�l�l�l�l�l�l�l�l�Q-��k�G5Y����������`�\@�0������������Kukk�o{������*������[{���I����]���/~�i�����~ee}��X��S��I�����fk}�9@�s./�����k��~��m�6�zh�����'_����������������]��y�����T��_�q�|�@p�k��o�
a@��j��B�m�����j�����j�[.�N��#��
����A��y��t_[��7-��/��d��l�l�l�l�l�l�l�l�yX�w}���������3��F���v
*j�dc���0��� ��l�;`�����o�6�%���8t���8�I
�2�%ov�^�)�Q��8�������n�k�76Z���o�����_����_{���2A��e.�G������<s��~�T������������@�h�
,K8wn����#GVn�}Wt�x�q����=u��������^[3Qz���-�}������g�Y>qb��W_]3�y����w�63}���m��`�N�++�f{/���2�&0�[om�:�y�P������>}zm����GwYp��[��n�q���W_���w���3z�=��6/��_����w�:����������k?�����������-�-�-�-�-�-�-�m��4��_^�����s�]����������'~��W~��^��wV����:��?y������������8{����������k���������+g�h���Y?zt�g~����:�����o����iU�;�y�c��Gr�beHO�������?���o��}��������8��O�~������{��7��%E����w��JVs�����+�~����{�^%5
������?�����{/_n�������~��O��}Qd� ��������z�
5�������y��_���������?���?������������O~��{�.?���g������;��{��������.�������^�;�����+���_�kw����������Gg�������z\�����VK�>�~�m��i>F���������#�g��N����?��~��_����;v���Ot8��������c�������G�~�KW>�����w����N������O<�S�=w�c�+W��z��-�-�-�-�-�-�-���h��x��5����|��ye���X�����?��o^��Z0��q�{���?�G�+��xc�����������'rn���w�k�O�������!�uIl(a��B\���-`����j��������������]���o��������j"��J����?�����������~���K����������v�|����\���F�@�@�@�@�@�@�@�@O�.�^�����O�n������������|s��'��/=���~�W�d��������?x��f���_2W�{�w�����+����C?�S���~����������{Ux�V������,`���WV���w�?��������w��/��C7���������0������M�z~�k��9��=�Y^��'I�!7����������]@�-bzXM���k�_���'�<�;�/������7�Z\����#.l���}��������ZE�e?�#���p�o�������6{~��J+���\�E���Wn='���o�\��=�&\
�����;�(NbWn��_%[�Y������o�$���?��s���r���(���O���=�S���5���������C
��|����^��'�~�%W�a��7[ [ [ [ [ [ [`�z��\�����+
�����O}���^Z����||f9��?}�2�{��u��������k��k����
����������{}��P.��hSg[�����>8�wCT�1���7AzRNW�(�$Pqnl�"s�
'
�!I�%�X��o6{k�����|7�vq�,��-8����w����_�F��|�����_���_~��V���z�������?�'/(�Q��0 R�a,q���'?��e��R��?����Q���w/���]���_�[�.vK�!��������a��r���x�C�'h{���`<����|����'~����2]��������.\���������e��]���K�����������������q����+���X?��%!��4���}����]|�*���1�u����WE;�����}�y�������_�+�YTs��{���p�m�����O*`W�[�5��r������o��w�����m766j���_>f��E�g����g��J?-2<[ [ [ [ [ [ [�me������5�m:L���5J3�=��i������t\=�;���]Z@[�<��npK����e�s?�3<[ [ [ [ [ [ [ [`��*���s�v��vrw�gRa%����l�l�l�l�l�l�l�l�l��Z �35o�oll���[U����gG;2�2���u�������M�)r��E�	�������"+qP�.UR���K��]�L6�
x�2��U��\s��Y7�J$/�[�MWEN�@�\@W#�g��A�����������bW}MY�a��A�)��/�|�M�=.f��_$ee�L�OD��f��Fkc�����*�&��p�$7�fce��pPe
h��:���<��+�T�����%�2w#=���������p�������_����+++��w��n�k��]m��M3���1]��&�����KO<����g���s���k����}{�����c�2ev���;����>w�����3g��S<��L��<yr�(�%�������o�t�-�+3�a�4�������"�B�g<�������cVc��l��<+�'����cJe�������k���fW�l�6�A�Q����'u�����jaf�]e��#&P��6v��|��MB��t���������a���p���m4��#t��;���=����� w-�5C�{!N�������CS�5�,S��/4Z�`k���H:�MRC���k
vY�"��A[�
�P��"��7\S�����|��q��[�D���VF��@����#G���?Q��~b�Y<���a� a���D@�\{��
��qu0��V�t�����z�Y��q�5#�\�����*�4�����gs���������y�$B5���7kF�Q@���<�W)��l���g�������f�b��
�<9�������j&����\�T�y�Y��WJ�^��������n�1��z��V0�w^fRA�P��9p������cE����'�s���,������w�y���q�. ~|�*�r���g�����@Kn���u�I�^x�.w�qG5��M�j$7��w���w�>���O>Y�\m�X����������(���{G���>"|��7}�Q�|����h���W#o�n���n��N�z��G�5��v�^����h=r`�P��p��2��-�-�0C���&���G�v��l��D�(�~e^?��F�Q�2K�"z���4�Q�iu�6>����b��@5�OxG�-���ig�o��P���R�cUcF�"^~�?��� u|�$�*���!T#W��+��G�V#W�7�s
�jx�:^w;cyg��������w��a�8 ����NpI�-��u#������ (�Y���H���v���>wV8���� p���(�iJ_f�����:���L����Z�g�����a�:	n��/��|��}T�o���V����,z�fq:.�}�9����:	n%7���P�p?��o���x��!yX�:�pz�3����'~)�uLtF�w�}@?x��h!��oNq��H�;M����,��g�����t!I�o��$O��O`6�o����!�����l�Zt'��P���o���f���v�����"��t���oN�����1�+�
�Q����u������}b89O�>��`�H���A��HG�7��r�L� 	��~�<�3����;���L�s�cA���(�$8 �NH&
�2\����:ex� �[a�~���V���I'��u_�n����#h'*�5
>`v���+3"���3B�3��6�[�����<v&���=������m��Ck(�H�t$@�g
�2��KG�����R��`[D��G&x\�^&��A_C�r����'>�����I���H1H���gt���ij���{�ON�H"�/���;
z�uLp��0�����+���AgDx��?NC��7�8E�p#$���ox�[�Q��!���	��6K)�O
L!��Q�;�����`�����p�d.R=� �@$D
j��K�i:���I�Dd0�(������<\R
G��
�2~}i����j�~����K����t�_p:���0��45��!�<�t�ijt�A�WCS���A8�;��Z�h�0~���'�~�~|�R��ZRd\�P�'�n8�A=�,�����t�p����
�Ga@�x0>rh�g�&]4�|G���S��`A8u���^"���{��v"8"� ���2}��3"<����%c'lD��~���3EO�[���f�=�e���p/��a�:�q�����3�/QT�t�z��f����y�l�����w^��G���t������f��lS<��3f5�t1�a����y��1�1=#�<����H�}>��������M�Z�6v��Ti#�[l$Y�w>�;>)�F6��yG�UC�@�lQ�,v4
��:~�����F��
����F�9\�����`�;R��5�sS������q�5#�����27�t1T��n���ZL8��Y3�}�>��_����t���p�\��F�l�q���cY`���X��_b
mq�Ek���2����Lr�P�}��je�b��������#�-����W�~Z�c����Jg��C�,�X�I�U�77�*�4���������O����I �S��F���+U�T`\��E�c�f��}������'xO��o�MpZo�|���;����������u����`�=��
�[�������G!��?�Yp�����&�fA|�4y�')��?��m���F�z��?P_��2�Zx����O���J��+�;�S��f��
*���?��3�����~	����2PV�-Q��yq��@wJ�����>���,N��$�l��t�����������$&�}����Hk���+<����2>��\��2~1�T�}���F1v*3�DS��>����B3���f��eq��T����c���4�-�Z��R�TF��J��k��tZ�h����lze�a�	����L�W��I�����G��@�b�Vf����Ne
hc�k����H5;�����������*%7��
[e��p�����hA�����w��W^y�J���T��#��w���}�p���W���I
;K��
���^z��'v��Y�l�l��7[_8�Xk�������	k���4[ [ [�meu��]�h5��1��>O��v�c*3�D��������AGe��f
��VfV���3�s��bv�=��<yrigv*�)����PS�&'���$���F�����mK~������;Tu�*�qR�����L�f��UFyluz���NmX�r:s����#.6���T7u�Ru��n���������j�ing�(v���V�N�e���m>���F���ak�'����j���*�
x�Qu��T&��U�Z���.Nr�zJ�@�;��_�y�����{���XC)Ti_^�V�zV:;*�~�w���;�hu��)��S���@�����/�&~xlUJn���@OK��)8f�gN�����l=����M�z��'N�o"I��d�;�=�����f;�������@���� �t�z��M#^$�X��g����O�8;��6y�E��l���^X>y��0�����>��c��,�,`Aj�zv�,�fm��F�s�������}������2�l�l�l��0���#B���<�����
��7;��e��*-E���ff�m l�i��������hDc�d�l�5o���@�����f�&�9f.�\P�l��i��R�TF��J��k�>�s�21w�<�s����2��G}�����:�hW�W���]xb,7,,2uUZ-�y38�8YX���Ne
hc'�=�`� k��V�\����u�m��l �*��=��}�����N:�L���O?�Q%�b���/\��x�����nn�xK�B��@���A�W	9r_;����
?p�@���?.<������Q�/�������A�,�u�I������W�C7~7���'���D�'�:c���1�A��}�p+����[hv�3y�	B�S�	�%���������w����������?m7�}x
�:�!�(p�{�'8�3Z�a�}�	��8{�����pe�d�D'����`89�|�s���H�������k�hp�\���p�������F0.Hr��!+A+��������1���N_7���XZ_�{����b��:a�p�F����>R��W�� �C�1�S
�y���3Nc�����;(�8���t�]�?<�!6:"A��NO8���n�]�0�`��|�#,;�.�~��(�$O>8��$��N)����3�����'����d�e8�B�	����p����?�R�c<�@�C����.?�T������
�=�"�`��N���t����c�O�����2������#��:������x�y��)�(�/y�MC��/��Q��"/�X�O3��$s��Ng'��IO��'���gB�"9fg7F����,��$��z#A����V���Dg�pF�Px�����l7L�gIy�����6
}������(��������K��Z:M���S�
@���C�q�����g��f�K���S�V�/����f�u(���L�q�/��;������l�h�����di�D�i�H=1�/������\4��4��@r#�,��a����;���������GG���	q�r�R��G�-��i ��RGf�K����/�%�@�(���<��q27�3ed���1?S.s#.�<��������2��H�R�L���AN����8S.���7�j�E����x���l=ud�P�-L���:�-s�N�L��}'
�� ��I�5��j$7����j�#Q{'OkC�.>�.��g'�;\FO8�muR�y�2�s��w��� qx�};���Fq�vk���q�7��CBi��������&\M�*%7�T)��c�Rud��a�C0����"������m���Z��&�8�}1���f5,6]L�&���f����Sf�z�"�~��@��;�H��D���%QW&W����@�4��H\6P���"��n��3�<�� �lQ���l��[��8���Tz,yb	�Xg�9[��@�z�6���fa�k��W/6-�x�������T<[e����=-��pl�4�<��2����8�'�*=���d�U��8��;���"��������RQ�2�����BM����	�_7�,�:�X�:f��O��eZ���
x�2��U��\���^���[
/�����nm��6��-�.�yM�;�*�����w��>�v�����������7~�
nv`k�@W)�	6o�*�
���T����4
	d�T�;�@�zq1+�;�����cV��]��
���^z��'��Q�"[�mkK8�~�ye����+�w�%o�@��g�}-p���o��-�C]���F�e�};��,������s���fs�[��u�����[,�L[�������0�i�����5���)��'Ozf�!�9���5e��Q�-M6E)�I���M8CV�����*�
�w8�2�8�[e^�Q�����L�f���Du�9�y����	�����x��-��\y�=��0����}���)�����j*���nsx����lcW�m_-v�e���Yx+��;�Uf�A~��B%7y�U�6��^��Fi�"��A:���w(��
�����Lr�%����+�1�0s'���l6��^	puz�),u�#�L�'�0�*s�[�s0�|X��:*�~���������E�RM#��
�9�m>,�;���z���~���@�g L�E6pL�w{)�>�����f���������7A^7�q������}�gm�-�w��"���.��>����Id��t�M�{#����p>���]���g�w�y��^�>� ��}�������@o����/������g�}�]�z��=}������!���+m��t����{Y�j��������;,���:O�o#fU���f�?xm�{����g�yA��}?"����
�@����|�8��f'.E��D�������7����)�����hDc�2��P$��3n����2���	6��1Q���D��&�*�
����:�A�r5��}�!4�4{�4�N+����>�V�8q�������������M�l��T�2'ud1�����:�*�����Zw�,�kB$���L-To���8�i�-L=W,W�}�6�L6o���
���"��/���I�h,	��~���o������+��$�_���u��L��.4������<t���'/���@��_;�a��<;���fl���I~p
�x�
\_�u��*Ng��o�M~��s�p�$O7��p���I������">�z��No�B�x*�&|#<���H����t��.�eW6F!��|c\�; 8|��:�����<�{���M{�NG�����N�k��Dx�����&$��d,8s%|m���e�;��!']� �	�$������m�p����t����G��}����C���
?NN�(3:��W���:�����)>�=��������F�2��ne|���3��.5���|���V+��g��ex�)��a������v�%h4L��j[��T��j��#�fs�.\@Ged��q�������,�)���M�=�|9����t8�����
��5M��!�P��'��=�c�4�m�.a������~?����'zD���	�G��^�����!N�ap*�7\��3c���on��r����Q���'�Xt��N�|�`(��C���,���x�T��
8��Y�1��w���-�@6R���p2w�-��&:=��{��a��
��	���1�]�@~RE��u��677�����N��(�����U�	��I�~�Q�o�N�GkA����~OG)3�~%*
�'�e������!����+�'!����$�&>��1zu�Cf�	���L�������=�3��4�F��C�?���p	-�(c�/�u��:�5����/��a��p8��6�_��B���a��(�B:&y�j(�,?����p��K_
g����rn���[����9��e|���o�����W6%�t�q���?A��5����;�������pI�@���0�d��^��S�'�,�`x�:u������.5f�wFz�Y����D��f!�SwS/�9�:���Dat�.�W����Dpb��#�b"-���m�~����(A���7]
� ���o~:M�v|�[�~��_i�^��:��x���{�f���� I*
��o9W'v���{Z;���v��]�k�Q���v4:N��~�P6��q����ph2E���:���t���-��H;K�d�������Gc�<���qJ�q����rS*��N��(7&���`�to�~���{��<~��TZ���eu������a�����og�����}�{��v��gT��7[��������[���T@��B�@�@������:�����g�T@OLa�x�]"�9vOf�u[T��8�XT'��<0I�E��u���1/�HrM(�I���c���6u3����������+*��c�y8[�M��L���>����}��� ^zl�S�lI�3�<S�\m�X�e�vj��z���#���=/-2��a3��p<��#;C�,e�@�@\�h���<�^�	t���c�������W������G*1�Qbbt5���y'>�
0���Ww�%o<x�2Q�����:E|�S���Y�)�b��_����]G���H��c6=>AK���
x�^;Z�$�lP�\�5��@RpG7���t���EY�	���%����*�2�R��4��p�)���n�b�Vf����Ne
hc�k����H�3;��R=��'����*%7��
[e��p����St^6�Ne�#�}��s���3n��.�H$��
�NOO<����E���g�[o�7/m����?�?"���G�@��N��������,�P�Y\�s��s�������0�xh6���d ��������.�����2��8
����������/]h��9#����'=��"�6Z�W���q���DfA��f�X�)[�������$j�m4�E��^{�5���"�Yk~�|�\����a�w8h��L�A�
��2����������������Y���������x�}yu�.����9E���c���|)�����6/�9u��S���D�����c�mZ����i�jp����{]��-j��F��kM���6v�25�o�v�6j�^�2�����k-��#��(~�p��3B��#�_����3%��-6��.#w�7�[�^k������t�%j������mo;�����]�	��?�8�`�]��;��Sg�Y[�s��@�b{��C�d�������gu�q��w�����V�����*U�"�����NrII��8K������cz�PT����{j�}�E�^���><;�/�.��f�����(������@�*%7�(��k�K�,������sn8�~�`R��E6p,�$S������S!�D�9�S���Y�3��������
U���\�����&���Q�jc���1��^�z�2]R������6����~��N�;���=�tv���y-�8������*��g�[�tU���6`F�@��;������|���;�Y�`��}�G�s�f;q��f�8�>�=f�}����������9�f��e?�K@�;�~.��<x��:;NG��@{���AsagV���c����m&�9����4#������c����3Pxg���Z����6vR���l�Ud*�f7}����� �j������6��y��#G�tH��Oe��V�,����/Cvt������w�
J�~o -�W�3���T�o�8��8���2+��o��F�aa���9jn�{��;���"�N�9'�����z��s������V�x������<S�w$����`F��BbR��C��Qg��C�R�|��iSf�[������u��T�;SWg�%g� T)WsM�zF�2:Y��_������9����m�w�q�]w�.�d�F���+SqR�.<1�5�uUZ-�y38�8Y4�$y�cx�g
G���.��S0&�&m;����*���X�Z�)�~�
jv��-h.WW)��hhf�k�r�W1�{���k8H����b���L���>��k��>B�����{,�@��:���9|���B���c�Q����['jW&�}�����Q}�Hx	�iU=�����LB3��X,����HN���)r^��b��TI�$#�,����|}iiB���B�3��#Y=x�����'�R�����RC	=�j�J�aB��1��']����-�P��c���o"7Z���1`-q/�����Ow���T��0��Wqqp���a���CG��A����%���C5PN�6�����7W7��q+��C�.����={��!�S����:B�	�-�ln6��V�t�3�tv�����C�����R3���w�3
~��%��0
H�'|����p.��V����
:�uM_Z^���^�!��t�����9w���
9��Z_3lb�d>e�WV7.m4��������U��'�����j���]Yf����5C�'~��(���	�g�S�N�����@$��'���u�E\X�ta�e�7�����{�Et�^[o��+�5{����&��(��':[��}$t�nuJ��wssc}�!�776<�&84m�����NG��_�Xo)����{1��3k�������}���z��6���"_9|���Y�`��g����N����_�����3cO|�<}��l�sy������	^�/�^kn���Y)�I�0������������o��]�>�B���K��������{Lj--���:�rF�'�����
�:q>�8D�D���!K���67xcyEv�0�N��>*{���}�C�$g�U�>(��
�����-�t8I�����5�?���������n����W�~����k�W�4��i��gv��S*���':���H;Ex���]3������NS��q�������v�D14��
x�������7�R>��{~��G:M���,�o7~7qG�s��$0��2����o�ZX>��S��7�r����F�Q�AV��9���:B�h�[�L'�'4����2�>8���^�8M�2@�!I���	�
;$�S������m�o�IG��p)�
v*����vf]���1�����A�'<.���2��F�y���W/n�v��o��n|��7�����:m�(���x�r�o\� p�����~����<���4�!e�S�x��o(�*��6O_k~����W7�}��>`���/�yy�yec��L��S3�����Ld�m��fyi@IDAT� ``��v�.��������jB@G�< e;$�2�v���\k|���+W�>;�"�h����~�������������DM��}�$���������
OY)d��������M��w�C�������z���W7���������&~�v��j��k��S��������ex:M
W��ij��%�txGpi������n�[�IR�D$)��_���e|D��$�V�"�wB<��KG#N����F������i�{7������8��l���d���o�
�����W�/�!F��$'��p@Gt���G�'14�tF�c�����o���N<N�R�G�'��p4I��i��K�����"
^�on
6#(�?�I~}����)o���������[9�U��������77��[�H��;�2����iO�'�|rV<v>]���+�g/5~���[2OQ�����k�]k�]��������3�-?Jv���W�5���R1�>��w�6.m���v���#����@%�W�6�F����_�wC�n0?���}��BM]��c��~���J�N��-�����O����2��"�_�y}���������-���dv���*��K�}~���4��������{�����W�~������[�3J_s~��f������U�+��s��������zx���o^/]m>w���#�~�}u2N?��k����{��%S�4�G��_�uukx����W�_8N����A��@[��w�~Y��!��������e����v1���g������]|*4����n4jVj����e�EL�c	��z1Vm�,����������h��M�x��.�u�J�E�b��
	e���wF�Z�(y�cZ�)P������t���hY
�����SDW������/m;���B�q*FsK��L�a5'���\�t���9Sk���tvld���Z@y�V����g�����3�L)>;qh�qW�#��7�}�gj�n�^�X�-	���j1��3������
.�W���qT�K��6�{�L�
���9�,Ke�,]V/�j^9���<0���vq_M9���g�F[��9hTf����n�;����	tTL�)h�.��t)���6����4?zc`UI���4Z�=Xl�\�.��x������~�|����T���@{a�AH�����V;�h����}�7�Zy8l`�E�-2)v���}�=jz�0p���b�zc�U��V_o/d���c:�@�L���-������b�^����bM;�h����\���.���q����������LW#Q�(12�� �&��}��r;d9��X�5���J�=V��Z]��}�heh*�������j��,�L�� ��:�����)��%�J�__g�F<s?`h�D�Q��Vp��|����M�gG<�c6�GTT�G���r1�?��~\����sC���%�}����s�X�H2���cu��l��}��Zg^dZ3�\��V/�c	2�m�X�&D��|������T'��/;��]���&���o�8�cv����)�y38�8NW����s�8K�ye���;c�2��/T�-��2vF���S��~
�a[	D�Zgw���)�H�f��h����GlH�E���F���Et�u��y���Mn=����`�mw}�1<$q�m�}�Mr���*Y7���#��=+��I6��,r�P�����5+�F��&�}��i��������J��th�����>�H3=�Zp���3�a���3��NF�D^��HW_J��ea�}8���x�ZO�>���N�E�X#.��{{�����������X,4�>��kz|�i��W�Zn)p��lW��T�^S�����k�R��x<������OK&��!+����X��QE���3E�H�������{k�
��D����'N�(CFlc���#������l!5���;�����������~������,���O(�,]�>�[���	�/�/r;������n�(s+��~�'Ew�A��8�(pq���������8�1�M��A�����N^�;�9�����'��h����+�>7�V�X��P�E0�v�����zgb��K{�
T�U��2�-Xe=��u�1.����S�fD<���k� >����:C1������8%7����\�������X�����_{�7��q>�f}���Iaf�JN�C��C�]�z��5�:���l���Q��zm��?�m�����6u����s�U�*)��r����[�vw~�@�-�@�	�M��=��l��f���nx��k�=���l�|���6�zm���om~��Mi�$�-}���L��p�����5?<�g$7XN��1�4JF��_��|�J�������h��$����=�gV����� 60a������6-�|0mv�A���o��N������?��]���K���������=��u�u����]����>was�R����nov���E5V�*.~��4�Wtxk���������~���	������}C,������|�R�x�z�B�n��@������.n^��?qxKc�L��l�?g����o[6�Z��9�����w���H5v|�6�+�v�0�}������n���.���������������������l����������=p�]���|�Z�����1��kM��[��3�I�rr+���z���}Kl �XNc�kR��{O��y�Qx�����l{��G�y�����-��EQJP����Y�.�^�l��mR�I:��;W�/^m����}�Xk*t������^��2����,
������G�VZ^�j�v��$����K�� ����0`�b���������������t��c�G�����%����K��M'.I�(a��������n[YQD�"������i��G��n���k]jm|��]�6�����SGW9Pd��:���x�������KO^���J����������Gk�Ga�/�%>�����	��m-����^|��~K��.r�7/���H�[9�/�y9c����}'����j<����&8�����;=I^����g���p�� ��C���_a����N:�{�1�+�5�����'W�'����tv���Wy<���
�t��8�~��Z�����k���:���'/����[Na��������T]����n�.�kM5h��<B������l����L��]�����R������+����n�q!��Gw����������u|�r��%�1t
>��TK�G������RI@�����%N����>�R������6N^��+���1R-(��!�|���D���o�y���q��*�yXJ>�q���yz��a�Vn"t����~��nC{�R
�|��_�687��I;f��R/��@e�S���+3[��Ov���~m��g�nAM�&m��"uI��ze�(��?�3�b�Vs�����	���l�=���{%={�q�mCD*��q�5�m�G�-�����te����b~�x���<��S��q������T���s�,����m��+�}����td�x��O<<_��1'd0Q7E�{/���������}�f���������!��\���:�&P�����9y?8i!�����^��Q>m�xE���dm�>��wqw,R���H����E������<%{�
���������&����!d�x'K�����24��^��M�r
#����}{��d1�<7���UDT����g��h�`���������AE��v�w�%��=�<>QS�=�O��)&�n]in^������I�>�C}D�!��������f������[:�o�����:j�}����ss�~�[O"1((n"�������q��i�+�8WM�c��D�\#+9�k�]SV��2�sA��iT�������e1;�8�Yl���������Y�=�S��
;:�_A�-�Y�u3k[��H�c�BG3���fFV�7I���mx��#O��7Z�`I����������o�����WY��>�e��[IH�Gm�4����������:	]�h���1y�h���|.-{Q�z����
�m�����2��e�������F6���E�RI��^n����(I����C���Z0|v�>�E;3��^���I�'NX����/�+�n���C�^[w_�	�����;jY���[k��,,	�z�QN�!�QYl��l�E��������I��L)*����7���}�-u�5��,5�]�5���w�Q�QT^�;`�P\���_��/����d����Q�M�",���3�BA��������V�];t���m�2�l/~UB���������wD^�U�B�"���-Q�����{g������|����I�A�?���v�����V��$@��#������gFFU(�� Dz���������������Ph��6��W��5N�������3`��&Q�.�!��E���e	A�44�k�R���j|^���5"���]2cs���4�3�94A6���:�������?P�Y^�2D�@u[
�f��[���q�5��jER59���gx@[
h���{X]g�����N�%hZn����x���k�9�����N^�J2($cp���9�"�b��������u�O/����������eQb���E]�V�O��U������c!�V�D��76o�;?��������a,�v����,�'�������M@Q<::�B�wF����F��t��]l'�o��+'Km������S�NWt�����Em�����AT#	LF[�.j��+����/T���(,F_D�A4`|�m}Q��	D��G�v{�^�;����,�%
�����zj��*L4K����k�t	.o�e@�mz���Fl���� ]�6���G��KHu��*s�ZS�Ig���R!AhL����;�����i�U�s�����`����)�T����C?��e{4A�0(\������K����y�>��i�D)�G�"�v���_.�dGh:R�e7t�
X��#��:�v�;��f���9�����-us(��6�����x�ez��?H�������m���'���@�5�X?�Vp&��e�K���uW|xHi9�1m���{����w�}�4f������"�R�)�?�G���D���T���A���4�m��;�S���g|FJ%���m����;U�=��4�T��y�_8�"���g<~o��Cs�ib���>no��v��m��{}�8���2�����{!��&�cm�����/ '�Wt����z�y��`�>_B@V���"������d������H�v�,��i��4�KsA���S 5��LfG�`'ZLC��c��w{����g�:2�u����/�"��V��J�[����y����@k��>�W�����{_���~<1��Yp���?g�������8������h������
Y�C4��R���C����PP�����4@t.�������;�,�[��Fa�����"3������-���EAq�Y�NDV�����&���$�	5jE��O:
�WJ�M�:6�y������&��p)��K�s94�uex��f���sQY�#P�N���d(erC����Vvd���/K�spQC1Y��/U�ep��������<N8%�xXL�8��]�%������@�e:=��u�����o�F�@��1F�
���
=g������>�_��#<>>�s��E��~�@���_���t��.'�s|7Q�Ts��`�����

������������1����Fs^*46B(�(=_P����I�p1k_�u=z�r]���w����=a�s�(��$��s�3.�����hV����^�F\S{�����;bh�`c /�%���G��\;��?���JDuHsd��?�`��Ji9a������3Q��U�h ���&�������;�1��c��yL��e[h����8�J3@����T�-��"�he�]}�E3�@KW.uc�NF�4�CA��D!!�"���(����E]������������D��-\�v��F�a�l�M
��K3�i���Cn�ba�^�������~G"�s�we\��� /:T��_;�OJ����s@�����(�]V�"�����Fs�A��y����"
�k�>�{1!��|/R�����y�%�����*�ZA�}^��g3�bTy������M��V�g�����d�e�A�Flu�����@���!������~���l0>�pU8<���(����E���4c��`����/)�?A�I.�������`v�-�3��!���@B���h�0����l#�����G����G|Y#2ak�$�>|�K�:�����a�|���{�BA���!=4�;q��e/0W�t����Y!AFA��}= ����6���]X6f0t�a�c������T���zy$j	�)B��E�/�/ [�w�T��2d@�B_!D[N�v�h�����%�1t�!h'�O��
�9�@���@��H��^���w�U&���v���9;?gE�T�j�����$�F��OZJ�`+m&n���x���vR���Q#Ld���{-;hl��r����L+�E��c\�o0�Ze���l��s']�vx��
�c�F ���kd@�"�;jK3_��T����#���6d��E?�j�G��������b�����0�'O��������Kz�?�UA��!
'@��j�=�]��@���Z?����6�EC��y��G����?��������X��1�jUL?�<{+�PSQ>���������#L�Vm}����L�b�����"a@������=�n���}��}����x��6#�=�J�����7�F!"9g
��x�{q�s���u�t?�2�������z�Z������]�_����vN��r����hAk�+\O:������{6�r�Y��H����S;���`<����e?��}hfQ83���`r5]�q���I�����?��0���5
'��c��uD��^����A�N�}r2>7Z�t��9�`��k<i����b#��v]��5�O7�^�4��X��}�t@���[�Y�4s�;6!�s�O��t6�������d?>V��)�ON�V6��,bIZ������t���C���N/\�|�`�X���&_���d��c��p�
�Ga$3���e,�>9�R-�g�N�]�6��a�Mj����;�����_����x<
���g�/�$�����Q�G�����I�GQ��l���we|;���Gd	jt]�l�s���f���/@�iYw�����	���-�}f�S��F�iZ���C�s�|����<��cZ��lz��������]U���d��.�@�.]/�\�h�;�*n+7:��"���0��0
��|T^:�,/>?�>,��Y�$*�V����_5����lY'���F���y�f��i~��~:;lya��q����$>r�=�O������=���L����s���/O'gs���q�_m[��u��~<�-�������x:�tJi�B�AZ|��b���j��M�t4y����b8�=���it���ng�����t�X���Q0���J��t��
���8ll��$�P��s�d!���.=���q�2�C|��Y�M��������2���o�$+��m�i��WE^fi�C\����4���EG���8������4�g�����x�dC������������*�'�<�qc6�2����gO�����|��$�v��U6`�� ��8�����S��a����V���\�<M���y>
Y2���*��r�8�d�_
���v����g��4Je��d6��	S9e:�<Y�v�1H��+��I�xXM��m���g��nX�%�[��c�:��e 	�����?���	�x�� u�$��f)�����U�F���
=s2O#��t��$JhpX��0���0���;�H.�x�Ei/��Nx������B�P
I��t^���
��]���w��f<
|��8'y�s�PA~T������~~Y�U��������=�����[�{0���6�9�
�7lL���J���{�9O���2�;W��;���3���=9�<�N����Qd�y�u����������x�+7�<�%���41��zP�o��I^��4p�4K�%R�DK����x����0;�����B�M?o�.&�P������I��!���������1-�K��'F=do�gW����t���@_�8�EE:3�O_�O"�;�S��N&�����hc�M�q�
*�����$��<	_y�Ag��#����l�>M���z@���&a��(��l����C����A�bm3�z6xX�n�p�F��U���9j���~;�O*o2<L8?g�Q'����$?����������jZg:&=�u]�tG��p|���z]1�o�t0`����t�,)w�/�CL���R��zu:j�Y3�;������*M��ik<���$�&� #����o�\�{����g�����O�t�*tf��x�45b�<;;7��?|`C��C���F:�� ��I�g������{�\�1�O���Qlgq�_�;��V��Y�D �n�3�����2x8MP��
��w\���Y����,���'���V���a�?8='B6����A��A�}w(���YUr����7{��sZ��gP��U�WQ�^�;���������,d?����TC ��)��t>��f� 3OJJYG����V� s�9%���m�,3���'�<��[�l;7T�;\}!X`�v���j��Qa��W��a��D.��l��������wc3�����	�G�G��E����2\������d�?t�f��CgG�7�|������J����s��$b��������A���G�8��.�������d�<����mk��:���W�W�����8������q��H�J3.,�3��Nn���|�e>��[]��INT��(�n�3!T1�|�?�w�QQL�����������d��d���>����$3`�<BE��p>�V�k�i��-�qb��fj�7Z�0.
���r���f�B�`<��
��]�����?���v��X������=.�9�����Ofe��
��:Tl�joT�MD�E�<2yG��������O���}�"z�CDxo���2!>���aQ5xy���5��A-��*�����H6�l8�43�y2��q�G�k=�v�!�2@�w�R����X����l6���(7�:�Ti�IxX���@��Ag�>�!�a�N�������X�BX"�b[���3�1�������r�I�S�����o����w��yEl�Vj8D�����=:{�
b�����q��`����~�b�w'��(�����3�2��u��1<��|]%g�M��1d��-���(�fU��C���0�����x)�E8�R�2��/�1d�	�L<.w:��� k���DZ�nw�}O��i	M�n��p���Xi-���Gu�� tR�,'�����,�@f\k4,�� PX��*h�ia>�9�������A-5�i�Sft���q&|��F�=�|�<!�4J1���p~u27s3��^O����l��u�1X�a$��
���b�qM�
?Zd�#�a*��*�5���X��eu]�S��I�����un���2��F�����wCl�#�u@�t\�L�����Mb����!.yY��B���Yn�=���?t}�)�����{��i�(����Fj:L^�;�yy����A+0����p/����_�;B���+`�����f��0����'���j��l�=��e���N%������1gF�/d����G/��'�M���4n�����93��pnR��D��v��qf��yhx���r3�Z�w0!�q��1�r�Yf0H���0�l ����qN�C1*:�l������E��2}��K���:[�R��h�}��!��'�e�p{t�a�E�Sg�u��w��Y2�����g�'�6�F����yyx]�:�P]=�0�>��O����������2���������b�!g�uXm��5��1����'p0[��$�=���Jun����_��mao2H�����[�Xs�������o��/BTR���>N��=��������=7�|��Dm��i>�J�+��+��
��A�"*Q3*���S�������e���_��67r����1���}��,�������K�7����|B0�
x��G���E��%*�o Vt~��jbb ����#t��I��z���&�*�(p	���=�]47��Zx�X��7��f$3W�=��S���Z�^S��~-�l���p�l�C3`-x��'U7�jjKEm1U��o=8��>X������6)��4��?&O�o�"V�y[��Y"E�AO���z�����9�la�H��s�P������n���[�,��~�o+sd�v!t���F����y�������V�s��-](�\8����m����d�k�������8�,;���|�]C!p����z���#�o�s�7�������c��V��C����9t�^�*YX�X7����x���[7X��^��M�'_�Hf��y@w3��nl��I��iq��q��������%�b�JN���:]�����]�����U�������`�V��(�X
�� �\|��E~����}	�e{]����@~����^����O���h�lY;���������.�H|!����+��$I�j�W�9����H#�Q/,>������4>*3^��@����aIC]�������*���U�\Lq���EK����H����py|��������zd�+��O���fX�������=����]� �������-)�j�A��?����G>�h|P,�:6�W'�8o%���������o�%S8��R�fy�`���K^0�%���D�-1�`&����5[����1�]�u��*�������,*����xsB���%")�D�����t�qT�.���Jv,��%}������kZ�Kw�.�������m20YdrnP��e��0s�+�;�a�L*+*.}�]�3X��1�v���C������%���<�zn����fc�gd
)Ey��*��,�Xz�
cA<���`�J&q�+JX�����=5
@x���3\��&>_�W�C(�_��Z�$��{E�a~�i��}_6���S�WF3aC!���"/L��]�lR�47P��QE��A��jb��������|f�!�&D1�m{����!
j0�������`K�n&c7.r����<�(�m�Q�\�5�[��2�2L�O��0�{K���=���T�����IZ�������R���&|?+���^�L�c���m��D�p`�T��r����ikE�2+������^���� o����
�ot�)��f�$����������1�� Z���g��]#�Pb����'�1�0��c���z�\�b^����>�{Yyd�[�]�eYoM����Wt�u�������#"���5�n�m#������^k��=����K����g
%�R�Ge���*�����A>�m�3Y�y,.��������/=��/Q��J��A���SP����� 6��	��^�%�����|5���>���r�~�;�9�L'N3��l�y:��{�O5|�h�����?��M���7����N+����o��I��%�����/���<}V�{m��P!<�qq>!x�����U�e�sB!���?��7���6���o���r�u���\�J<lw��/
^�'xn���[���J���6�q`�@�+.����.s�_���Or�=��h4\�8�v�.�v��19�F��o���N�Vt����t��k`����H������7R�OTos9�w��d8m� F���I�����z#�(=��(���^����-�����t��o���WV��v���������V?�p���,	M&BS�7_~�����K�Xd��yRr���,�/~�����
��|���v�N��?2�w�T]����.e9j���f�@�6�%Hx;���	d�a����(1S��in�iI�U�_��Hf�������O�"��K�H�d4�th��������n�@vK�4�!�(��Wv��oq�PsQ.�{�U
$?��5�f���qG�Ri�����jUX<�9�"���\k?A�X�Gy�B��\����k�����X�������PBL��N2���B;&��'�I,d},Tj�#)��J�3(�R\�o~�$��\n&�w�E����oi���uT`Y��?~�s��w�v�d�����@@�T���T��]�4H�{�iB*��5�4�lB)�)PL8D(&���CG�P���R|� �(�X���	��86�2���A��@.��4\J
>����v���j���e|�@=L�����[���[w}�d����t�"2� ��QY�R�6xO����^�vOG:����:]������:x�:����8���#�O���P,���<5�7>�s��/�b�i>i~�
�����G�_y5�+)/�x*�V�o��9�|NC��	#��M��(B��?U;�p;C�t�~0�,��&��w��]9g�,)��3���R��,	u���@�?,�.����=�e �5�5+�����m�J�p��R������v������d�,��&}� �T��������������X%�[�e��������
����p��0+8�?���ggw2ew�/jm�C��O�`Y6�h�����v��'��P�CN&Y�{�{}/z_R���W-�i{-1��w��k|(#�W��y�Z���������Y��g���pu�&��o ���~�5GZ;�a�P-�s�"�q��j|x!'�����2<����l������5l��H���VF/W�s&5Kg�c��bd^�XO�/Jy�X�\�$B��JT��.C�nS�2��w#;���@sB���l$��z�C���YAa�����'�&��H�x���Zc��x��� ����`$4�]��[�������!2tf1�(�@�X�u#�c�	��n��X���m���?)�I��v��iC�p+��I��(����~QD��v"$�e�s�*8��9 �;2^���z����,�Y��l����.+$��7;�w4Z&i�
���F$i����!��x����_����>�*�>����r��QC5���:}
!�1&K$B�F�QK
��-Z3�
��7�����Uj�u-s!�8/�8�}$��E�cHV��~^J�U1���xN���}��:�>p�)��x���N���)�#s�5B����z58�����B�b@��DeVJ	��-��t]p�oFe�O.���E���(C�sL�,2o^����Q�/L�0$=�y\J�@����f[�.�Z��8$G�4��
.�	hz��V�P;���1C`�F�H��$Cj!���Ku>!�x��
2P��P���I�:��d�����_W�s�O@F�c�A{@����� 3Ar��g��:m�v�?���7Vn5(^�P��%~�Na�8��l���NC��%V�8PV�duV-�I��i����y�l������u��SM>�p�g�i�@w���!��09UA^`B:��pQ���
�nt�0�W�rL+����L�Xx��]�Xe�S�@���������IY�g��Zm!�F�M$�|�`��u�X�)Z��9t���}6+%(���p�P5�A����iZ�;k'$�(����&������z�U[ng�g(~u;A��c6G&������Fy����'Y��RMZ�b����&�Hf����@@\�1Cl-���cD0��"���7��a3M�$UC%�W��l��m���/:���$HN�J�C��W�P�[�h���774�����/����3e]�~X��:��gt��ChHc��<d�%�
�\f_��c4Q��Qd]^o�	�Q�k9�|e��o��fN���H&6����5�?�h���w����&&��������ht���Bjd����Y�_�P�+�8bl��� c��!+yD"=�N�0)q��8w�������
z�@/�-�
Ug�0�&����O�>�3�uE�@����e_�E4�JV�j%"$����E�s�SW��0��H������d%�l����2$���]���m���xt�"������&(�	g���N�%���-�5Jn��pw��8��H�!$2pHo��u��_�\�0Q�y��a�����~��(C�2tCz�?+!�(F�g19?�������
~b3���)D��G�����hFK�]@+�zh��]���	��Y^����d@��L��@���1M
�c�� Y$$0���%�{�EN��EA��*�0�a��v�HQ���N���e��.��������*��^�]�\��p�z0s�����D
Tq@���Y�?4gC��B�2����vU�4�t�*�#<�o �)t ����W@�X _�)D-��~��I��|��������qYL��
i�
�1�c�Zs q5abF��<MP�t=���f���n�����%�P�R�M�G�t
���S�����������Q-��t���
B�IY����L2���LU���]���sO�mnl���R!��������D��Sr�7�Y���������]�^8����9H��p�p����#��Q��Y���f����������}q�>`Q��-��	V���O�~��������Qu_5m�%�XXyDu~�
Q9����T�����i�[SV���1HY�A���������U%b%�R�65�y}N���aH�e �7^���	A����
z�L���g���`���YO�L�{�[*�H�����a:{�n�K��F�(i�XZ�U���M���M%M8���@&$��������o���
�}�`�{����������U`�Sdf1�f�c�Z������fX�6��p��q"�����w1E0�����{�.���2a���.��t�V����IS~��u��b�T�&-2N�7+h�jZOVe���H���2�8���]�%}D^�<Kv�N
`-_��X=EZ��1p�0&���mI�����M8J�����PLv��\5-p�I�*�+�����bX��24Y�\Yy�4NU�Q����E�n*����R1�k�,�E��������dHa���e�>���D�5�@j:?��w��V��@���i�>(3��2��R�����D��C] Sc	��t���l�t������.�At��)
u�VA�Qj�LN�W#���������*|�iT��Q���4�8��=�J�+��t��b��P��v!5��%�V�hj����,	Pd�
3��e��n�����Q�:`���N[�����~�c������5h>I�*�)�]�B]$2a������za��b��� &�����X���	aL�����_+8
H��SQ{�n�CS�U��t��vW��+�K0����(�
�����u�������Oa!T:�&@L(�0���q��V/�{����<�|��M1��x�.�el�n>)��+/��>�v����5(�
������T�����z�x���8����*�z�w�������fY��r�!������1m�.t�S�'�4#�j�&Jhc������N���>r}��J�X�
��Ly�5�%�*1�
�eRd@I3^m@A|5�Vp���T������E
�8kr���B����#|����~OoDb�W��
yN,|g��Q��%�#���F	22�j$�$H���\J��@���$�6�XC��oT�z���~�7�G�3J��bB��\��/LC����f���k�E�$��F:cCE�G�n�
�N�\��;uE���H��9/M����DK1+H�bTv+�n��h���S�J���N�(-��S�
A�0������4��w-s�O��Mc����`��JEJ"5�k�B�^i��Z�@j��J�Z|�S���X/!�a���=����yBI4�q�
����U��� �+�2�����r���YJ��-Gnb��$@)N����Y�-6��zU�A@��j�5�p���p��ZQ���j��mD�`5�T�����R�x2%��b>�~-�Y����{^�!��
fI6����U�;�>+@=�54DF��JY�V����@IDAT�����?��:���+�,�
%������#��9�viFZT��G������
�d�v���G�.	JwP�#�2�:�+�K[��L��N��4�0����N6F
�@�^� `��Ts�:S.{	n5�j�/�]��j���y���!�TCI����K#�>S3J]��0���L�^%@�H��J�"`��4aQ%�V�D#�������*J�Z���t��.q�#��~xB)�P
%j5�i�&QY�%T���>������
 M��k�����C�B��G� >
a��:b
a��v+6�����L�������2p5k6�@����	"�">�"�p#�E�Vq!c�	���
P|w!�$�����r�����2ARq�2��i�^M�'�(�����;\����qI���XM���y5���f��r�(���m���_$E���_�TD���p/}����)4,(#�2k�w� �dQ����"a����S�R`f��7U��.���=Y(��\�(�;�s���L�x�G.���K��dB�B�\�.v%�)n{�t:������{��S��!�s�7q|W�_��(�u
�}Z�������([I4�D�
�5U//"����X&������^ ��C�k��v&�E|�p����AT���S��m�Q�0��~���D��^k�����Jt�l>��lroB�3B&l��4�Yjlp?��0�%�G�b T�(���o�����B�����pB������z"P�=�f���b�r3��*������j���n@������d��x�k��O��7��$�J��5r�(��L��G���t�K�����wIH�+�b����f�+-��1}�e�������B�t���+P=���VM	�i`R�k������U�nB��HQ�'�q�P@I"�5���*/���}	�"�D�R���B�!� E���L�a�W����=*A�D.�S�
T��EqL��q�%��{/b�V���g��s�S��3a3��2S
\�x����u���"� |=e��F�
b*�x!.�(�z>������AO)���a6yj��C��q^I�m����{+�J:�����2�!���	m�p��A���<������cvs�D�������Bg�^�b��>1
Bz�
p��B���jV&+ 
A*Vg��LrrH�I��L]z)������2�,�H����=K	�0oeg]l���F���������9`V��M�R+���|:��������haW@�ED����'����xY��|^��I��>��>���6����� �C�h��!��w���!<��o�	���S�M�#+�BY7��*;��Y��U��a��g,H�i�~�k�Y6G@3<�$���Lk�	��hP4���<�l��
�������������nz(��QL�rl�2�aD"��r��nE��m���Y4�	��o#�:�&�L'-��HZT"��*YQ�X�r�v���cG<���L�<&` \��Nm�< p���8�0�aC������,��	^>��U`���!� ��ODCQ�;���P�yv�|<xF}NF	�������`�t�J��'�y��������^��(e+%���iJdL\5V]d�������"H'K�T<.D5�n���N�C���3�6��$����l���[	�v<��D\�7���$�IU������S{�~CD���8G��1d���~ ��4��/�LE���4�B?f�m����Q
%�XmMD��B�@w�����-���	��
��%�.
��H���h~�����V�t%�T=�1+��� �����>�`y�+�����@�.����b^��FW�U=W����\#%`T0$wX�t���=�}7
�.Q��/
��s�G�����U�@:$�?���>�Bq�U���u���mLXzi�7�`"���V_iI]�)�jA���A�@��A�0T%P5x#���r�ri�G��9k$+��QW���!rM,W5���C��A��$|����Ds��"�H��;4L�����=:��>�����jO���x�J�������3��-�5�..�N����wQ�,
J��w"xB
��*�/Y��m��"1`QN&j�V��,��L�a�)��E���]���3�9�y�,����I���U�~���,d������iU����0����h}v�S�&,
$���4\���Y��?Q`�Y������N^�{���'����;6����p�of8H@�f�!���n��A��\u5�>?��d��G���W~�����SJ7�Id �U�x��=����O�c� ���T~�������������y=��P��^��h}�
y@�?�$�v����=jd�9�M��?���|}��iQ�����W��9W��r�������3���$?�����<K�������L�x�� �<T��� 4�+����2a���(���7�������@q���8�
L���������)"L�uwV�<#�+6���Mz��s����?�{o]������"h`M&��� >�(X�0�����2
����������y��J��$���i5+���J�D/���|2���LVS5hx\��B�E�5���q`��'�]��}�i�����+^_�a�C��O���{���&A6����~D��f|��g�;�����'	z�x��D=����	e?������
�o���9-9�F/�F�#�`y�d��]��oN��sE������������G�3�j��2�'������^�"P3�������_O�������[���+x���o���. �+0*/~(��_��J�:��H��f����:��:����]d�l�����qX��VF�p�����Y����i/c���:��U.��������"�]f{�cZ.�F���UO��#� !,#�����6���W��>��/���{������uU��Qa�������@ 7>�^g�ZhE�e7�����W��p�9��6�����'�H�J�w����:2�9�`Y����/���{�zo@m������4�����1r2L)s�d��fTk�w�N���N�|��7;W�_2J���f����g��G����d��X-x�O�2�S�}��jL��Ah[&B��,�<��*�}p�}D����������_������G��*���t�+���an�:F	�����������g�qk�����<|p��G��dUN���y>�}w������M	xr[:>���o����?����
�����o_���x���;m	B�t�=��i�5+E�aZ}�+��~T���Y�o��6�f?�����
Yp��mP���+F>��@��n����>��e%���_�&�G�?~�{��i�?����������$$�5e�b��Y���`N%H�?=�d����{�z��q������F!�����rP��K��i�m�|l������;�b�8���u3~i9�M�������C�}��'�rXq�D������Yy��Wi�Z����Ac���M��HHB��!)�J[����
����0�����g�T���;��`d��J�]�Qk��t��y�C���{�1Kh�3.:+��"���%p����Y�����y�v�	��8
�#�Hc�"���O7m�e���e���>9����>�n��1�����������`}W��x�+��%�
������+DU�we������O��zb�>x0����?��qb^�J�������G�7'y�g�3��dZ2���3O�[�@���1>��t���U'�����
�<��(R?��������(�g���i	K�����.�fn�4�����-��-,~`�����o���Q�����J�E�7�G�O2b�+{�?57Xb���no�0� ���.���a��zq�/��D�������%�@�x:$K�|�7����;����������_���l����'0�@U�x
����_���On�g&
:9*R�+Z>X}6%��x���FE���u�c�j2�w~=)������8�������DYb��=>���\N_}r�i�|q���W��F�����=A����	�XL�����w�w�?��{6B�0������z$�
u�%M���%u~fJ�#]q��C�F��S���w���������x��>��
������;��@��};�{�1�W��������^�v�~������x6~�����E������w$����`���	�O�N�C}�������|��d^W0��fX�.C����A�V"��8G��*t����cu_���!���z
��1��d���k~�4�v��k�?�����:tv����?=�?����SQt�.���[�@�O��_��\�g��?�q���"|l��P�}X�P�������T��Y"Z����"��^>�Nc�����4.���������}����~�Q$E	8L?8�vF"��P��WY�.�+a�*�$�28(N�k�)c��U�����n~�,�������s�T������a�7	���<�c��=�A����82�}�
�z���Fd#��4���|�<xs���dh�]cp�����}'�����n��:���[�&9f��`�Y�0��vu���8��q�6��e�b<X?��4����O��5_W�K�0�����P�H$�!���Z���<X0A�vkm�"�>\2R�@ 0�7��r�?:#���c���z���5������;����s�o��W�t� �I�$����[�T��>������>����������
5��,lP�8���z�_pi�������a����R|�%�"�^�s��@_��A_k%��nch����{��5U�2@"J���b5z�E��5}����Z�V��rQ#���S�v��s�y�{e����-�=�?%z1N�lD+������xo=��I*�����o�p?��U�r�����������q�m��m�0���|-�!�&�����N�	%�a���q���!J�{�������G�����>����c.�N�:�k��i{������������6@�n��8�}px�#�	#������a���.Y!cE�h2�� ��X�������k�9��=���Q��c��T��4�~��3���_}��
�m�������*@�Uy��y�L�D��Q�����|��5���v��x�X��$����5��~��G5�Xo�j�/�B�����-�J,��Y���>:d���1����-��j3
���!!E�+PXIq53
�iR~s�`��+��f/0� ��]tJ]9�W]�	i�	L0�dn�E;�����z�������$�d��S�_���J����jMjf��%c�j��>�:J��)EO�N;8�pl�~R������1������ �(�'��#��o�2�w>�;��z���o��+��V������g��,zN��,�M�^8����o��F�HFm�p��/�)�����w|����=���}�y4���w>�����5��^�+k@j���R\/���a����
�y��S���(������L�l���BgB
,&t��{���7�G����??�����lF�����%J���L��;HF7��^��?��)��a��{0�'V7�]FKVUC������Q1fW�F�p���|��a�r�F��8x������5��,��~r��Q����gY�I�(�k6���{����W�g�|��Suq^�y�w���L���@�G�2����.����K������7�yw�����'�g���\|�f�n���s[,5��IWt�(O���

��nwrkY���s��t��l�:���x��0&R��F������q]��
�1�XI#���]��$���������J"���`��R�Q���Nw�i���}���Q��dn>|��pN�������w�������
�S!�2���������Ne
	����@u�	�^~��z����3>�����e0s�EV+]X���ij�uq��b�Q��H��E��U�q��Y0���^!��G5��V��\A<�������I����l
��0W`2�\�:�uB������ ���=����@�����l�����"��R���&/�@9���)�����/yh��){!��,�!���N)�Q�;b�I��ew&���*��-���@�*t3��E8��������D��5�����/w���!��^�h�����g�%��2>e-L��>�������%,�R���h9����Bk6�������\C�52/�p-��iu��S��B�X�v�v��a��� �!�7wJp�J�M	(�+��eZe�X��u <��2�
����w="����f�	z����v�`�������9���4sV'.�c8�����+=��2�����V3��OJ%�[vc��A�z!��!����,�^H�ZA�~N�� 
�Vph>H����;��pg���"�`�xn�������t%v�	XM��uw���w��i���>VVLG��V�������xa�E��
��j-sz!��^o�C�r'����8%j�m�b��k
��A��h��yz5�@S��y�~���|Eb�y���&��\���;h���� 0e��$������)�����mzx�3;�m2�p�\���1O&�M��h�����7~�����0E�����UtL
&]}�
8t��`/S���Q �-����n���?F�A@�a�V�?P���������
�)��gp�a���9dIL`�0E�.��L�^���=��0���2��X7e�u��bo��zg��{��%��\dg��v5U�u;nY\��9���K4����K�,t&~����q�[�d��ppT���p�����s��M4k��}#�%9�O���OyA��V�>��4��]V��Z�������aY�Q^�;�I�<�fW0Cm=e�-jx%8���:9m�n�������(������mA���Xe�����:A/���?�o���%0�2F]�s����6H�g�	�
<�u�%��I�4kN��3*'1���R6=��/��}H*��.y��d}|�����5�v�
042���cES����$U@�0!17 �?��W��2�tY5����]��!��	K����A���w���k�U�?�mC!����P�������2=�eesQ�]PCc�1���
W#/p�)���u�=#-b����)��������kkf�IG\��$<���WZ�a�C�����E�1]��\	z\eqly����|�)���A�Ue��I<X�D��g�egN��H�t���G����b��&n�-+ 4���A^JC"����cw3+KH���u����T� ����bG`#���Uq�Ed#:%|o6���Ez����*(V�M��_��p�hza�����w�%�	
�wfe1����jK�������=M�h���l.��Y�2�ygi���BA�	�o���Z�HCM
Q�	nX�Ai{�������Y��}!��h���sp��-�
w�%M�$��P����^��s�d83"�������Y<oRP�(�
�Mx�����["���j�C��!�/V��?�p}$��,�%�	�����O��Lf��{6�����%\��h�����g����3)'����	��b��l}��a�������F��r����Vz8����N�+�-�8���~�w�\h��##���M�@U�X�ah��D����X��~&����*u�u��E����������egH�����tFO-3���4{�K!��H�(	M(����U"����*s������)�G��k>N�p�:���@e������Q�& �1S+�����7��@h�M^A��4�.�3���e�����:��(5lY��C��g4>0��xzYfRI�ot�P�E����N�15md��yQ�:����:x%\�@�`KL�`�R���8�u�l�o���S=���%Yh':
2��Ey�����e���}����G����"��fa��������FlQ������"���"�m���B����~�"-�YbQ�/��c�AW�c��#�����6dg)�[�r�ck���vS��v$�v�� '��F�=�F\7�����Qry��/[�q���;��p-'@Qkf`@ zj��
�c]X��>�Op��6�,�AF-`D�q�~G�VOx`�wC�����������k=�$i;�|RK|�����]/zn �����,t;O�Mh;g3�0��a�O=���@d�?�N+��aqT;X	Ro�B
�����N���	E�\��$a�Yw���JD�:��Sb�	��4���^�����q�;�M*�C��	������.x��i�p#p`�3�,�i��}t����QG�.�#��a�D��=�6���u��:���i~��`���gq��uQ�/a�"���=+�d�8
��P�N�������VX�n{�F� �X��(����M��H�C��w��t���c-���c���U4U��w�u��1E��!k7���9
b	����u!��p�h���7����'~��e�x��zE.��R����]�
�������g
�(f�����A�A+��'���n^u1�c�`1�D�Zn�(�����'[��*��tEt����7�����p��"�_%������8G�1��
��b��Eq��-.@O���F����7��P�!_���'���H�?�����2\�hu6���\���w\��/�5������eI��B
��Y����,�;6����ak�;�b�\r��)�d��L_C����q��8<��F c���v�"��j[�7�9|�D�;��i{����)�f1����E���0	�I�^A��n��HV>1:t�5��������PFt���Cs`W�n?Lj��1l;U���}d���!�`��z
��e?�V|!���cDw�Y��#u� �l���}��@:eVXK�����HGY���z�n@EQr�������T(�Kj����X� ��N�8��!i��� ������r���SF��/u��/�;k�\������QD6+<x����f<c43/C���V�k�(�� 9�r�M�|�'�A�V�M>Q�&	9�t1�
��&�w�V�`���E�"��j%�S�-.����5�������AK��/gq]
�p������b����^9/O����JHN��
�E_(��.�e)���}��Z�+�S!jua�0�Sxa�-������BS��I�htC��p>��A��*"8����������0��2���A����
\���>����X)o91��i��C��s�T�,��+|�G�Gl���8e^L|�E��	[�b�����'�s��i(u�������T�S�i��7��e8(Y l�\��� �s}x4���p�S�I\�z�.�u��h��,l�te}�6BF���(�	u��o��x��d�
7��7-����f4���o��F���E� ����+)4����d�JH+�I~Eh:��Z, ��5i�[���M|gqH������F�'F3������F�X�*����a��i���6p$�iRN��E�NS���\B~8���W���M�F�
�d��*+C�&*%��>�0K��+�Y-S�U������`��6^�!	�	{w�	;��"�XfbD�:���(�}%+X���<ew^9r����5d,��D��[[��/�`�a���������r�'<�����M���\�v8�d9�uQ~��z��<�@+X�ct���`�V�O��E-_�+|�/8�(F"-x��Bj8W9�. �D�f�1���V����RV����� k=u�z��[R���ud���+c�1��6�n��x[�Z���/��%��c����X�9�G��B���Z�8�%��3f+�T��*�o���+���z��ne��h�����&@T*��M0��S1,8O�"Y0hW�
AM1R��2�n2�&P���������r�v������!>��-��!�z�cEB����}��5���n'z�<#�+�bP����o���}"�������M,Zv�(�z�r��8%�M�L<+����q��{�x���x��)�A!��1�m�G,w��w�����}�0x��Z��e��=�
h��w��3��7����2��Hm�4�@�+�#o��Av�C_{�5�q�8n���,�Pf04S���$&q
�����f���F��7�:�h���p�����J��V�i�&���b�K���@�yPV�*���B�ra0oZp�P!/��4��6���#4?�l=�B~��a�&�^:�Z�����hG�eq��,����s�q�/�G�*��0� Vjy)��E����s� /����YRK����+{�4��K<����z��8���9��~�yx6	9���V�e�P�w���W���2�����,1Y)-�^��������\uIh��Scw��l������Y:(
� ��F.�\����86�YH�3�<^���|�����H�a�:z�m&���2I5�E`����{IQ���A�ml��y��l+���PQi�%�W�U|Z��$�2�bf���Zth�#�P�p"g���8)X
..����@?~���?Q)Z��J�(:*�i�B>c'�a�"\4+7
qj��pU����1 6l���h!���
4����aJ�6�\��F�T<R�VB0h�?4E?����X����I���%�W=�Rw����(��C�tE
��]������C����9��Vo?(GJ���9y8�)gd��&��@o���`����&���������t������i�$;%���WBjh�|U��3r�?U�Y��;g:����8�����"j��-��9����b-�
YNUE����%���d�����
���lq:���-Sb|]�@Cw��MCdO�A��*vs2��x[0OS���P!/��	QK��,�PRY��^������/�z�r,2�pa�4[���Dy��A�"�R�������I`�/[�b|��� �UJ�!�l�,&�d,����=
�:q	�-x!����G�y���O2��w����#����v��������j��tI��q-���b��h/i��W_i��E����e����7����|� �/�S+35�$�r���)2�l$rnL[l�E�t��=�q0yN'p�1�;R	��J���;
�V��������B��t:����L@be{��V�$>1���?g���uL�/|�wpI��!~����pF�H�K�?�"�u�#��;��!>/��'mX� ?i�����8W��������8��L����;"��^9����c��Gr���-&]��j�N-�'yY�dpz�����M��tG�EH-e��Ga�1��J�4LGU_-a�`O�9zK��j4���%�2�9�=��f�S���W���cIA�}c)!��8��|������q����c��FU�1a�:-3;~��^�5	M��Y6��O/.rDqB����)%Lk���i�^�a�q�!���"��,�a�����Z�J�r�3�T�<����*Zi��^$�0����I��a�"�B
���K���m����'H�H�^&���z6+�63���	��(��#��S36.N����K�-��|��2�X.��YN`:x���0x�y��������$�oZ��DK�y��	gl�L���,Jim����#�Um�zy��8G�����(�����0����|K~�
.K*<=��!��"��O�g]��FXsKFU�Hq^3�_~�������d:c��,<w
�����;R���������>�#1(R�����5�	�PYlc���|2D]����q�+�������h��~Q�]�W���������x&��N.q�����C=.�e����!�
@�6���O�|�QzgQ�!B�D�l1~���X��Y5��-��$4y��u�T�=���1:��f�N>���$����>�Tru��OS�|g�n�\�C�����,�Z��.�p��Br��VT�`$4����t%Q���b�*y�0�J��F�	�r0��Af�G=\]��O���r�{v�����Z��������Q`���IM�(�'|��N�p���"�,qR��G������r+��'��'�_%���/�+0"�'�V��ah$�������z���HY:�1�x�p�	�vU8����P�&�X�F�;w�/�(�C�4�)C��K��3��dh�P�i���T�I=�Y���/�J6���3�(��}�� Bw�>918�0�U3�����|F�m��&�"���le�U��N��L'-����Z�SX�8>�O�y��{x�V6�)$��r ������|6����h�}u�K�{�����;�p#��rM(I���ou����$\VBHOG"N�p���F��W�����?�{UJ�5$�b;��s�e��_ �%�4�����a�O3���OK&�KB"�rc6���rc�H�$��I��kl�������8�cV�����*�0�4Ofn	Xhu�eX�H����0_� 6�,.)V�@u!���[8�oPA�e�,��*g�&�j:vrht>�|=������7���:�{��K�XL�1w,���c�I('�XB��ZS2�fr^�#	��c�p���+qIrr����s2<g7��;�qR�q������LB�j���&
E|!�b��&�ey��+��Z	_��an�������L�"��J�E����^o��%��g��GD��L����2������iX8���aOb6Z
#���y�$�u��u�}����������\b�%�2)Q�%�����a�$�l��������`�A�'[�E����a�L���O2)~������������z����������E�������:���r#���z��]�����H\	N�7Y��OB����
k�)�r�=lK_-&�0���x�6?�&�T�����B3(�k�R!�����8����d����*�Bi��<���%	�9��Zf��1���8�����_���*��\n}��l��W4�YD���-D������w���.��/��3���pd\���Su������R&�,�R�sCp�d�X)���Si�1���6��s�v�T��>����]���&M	��"�U"O��v��;���f���!�q���5�BQ�N�M��^M���I��'������O���%�������a�'�*��&�������J���T�
�p��T��X���V�%�D��=�+�G���Z������qr^7�����gK�y^�sR�dnb2��SG�J�����'���������������pH%_^�d6�Ar������Q��mUx�r�|
����9Q��/%f%z����$����������������J~=�7?1�8�����X���,��[�
/R�w��$�D�]jW
�����r2�;��������x��>����y�����N	�Xf�]�maM8]r��l�;3}�P.>.m-M��d��d*����d�������.$��&p�,/�<.�9R1�Qo��RzQ��v|m�B(b2W,�W^�p1�;��C����c��db�eh����������s�XAGK�,P8��(�<��	8����'3si�P5vu����tn"�"���l�U����#<���4�N�5��Y�Y|�q)]�Rm)��#�������*W����	�b4�5���������b\�ZY�C���� �<r6��V�O���x#���V��������Z��@��v9�]*������y�Qak,���������l�o����M���wa��4�{���V���P�g6���y���+�@��]��yTp���_N��'x��u���p��t}d�����U>��h�H�������f�JZ����B}�=�Z����M����m������|��E��S��istq��~��U�_�[������:���t�N����\�U�R%G$�W�����4��h��i�������X��32I���H�J�R���|���I��
q	URe���O����
B�IM�Y[�F�_��R)%;^b�@XV�g���<f���vI�PGM[���2K��@������n����(�%7J�j�W�d^,�%���@��T�:��Qt������D�+�od�\�f�����b-����� �"R�)B���m�+�8�X�v	G�I&���vv�#8��'f�����"7h8_*���'f����6/���
���0�|���k3�L�����X�F��q��uHm��'���bJ�q%�Y_I�J]dx�j5T�T����s��l&�U�Q�H���+1AXVl�qV�Ff�Z���g�l��5+�3Lq������31�������6lAA��se���F����Y�U����T�8�
d��
������������Be?��Nef8�/��?���3��C�M��c�~��u����
�B��x]�wh��E��ApJ�q
@c�dZ�������t���{|���9oJ)R?�)@�7�
�TfI�$��kl���0���l ����O�����i������IP[��
�t��_p�Z
^h�g�	��$�!7_3�Xy�u�p�"�F9���[I��y6~�����.�L��g�[�l���N��2��,o��kE��#�����q�'X0�tW�/R�����e�^�9��f���l��[�����&���$�
��=��Mg��I7�������~�!'�V	���o����OOMg��5��<]_M���P�n��O0�`?����)5N������$Gb�T!��f�@g���a�#��E^�8e��v�R����)��M����Jw_�~�b�w@���xQ�����Fa3�$�r��[!��d�a����,)+�#���"��h��N�;p����JL%8��5j����29�R���
�.#�:4�U�������S��{�uNr�N�j�4�$�#N����	��y�"��fu�C�/�c����Y+�/�<&�8=2�=��`q�o�x�?:8����_���!�;�'���CR|���W��c����${y��.���It�QI�2���r*��8���T��\E���s���KVKy��Q_8s����fL�pV;�[JV���$��K�����,�)���B��{�PAR��cZ%�yw)�jI�����(p�.m2����Z���0���5=���JS;�/�V8������������0��j��ju�zI������C<��b5N��PV�.�{���0���8�����*y 5[p�:�C*T�W�apU
�4�AVK}�(��q*��<t��u����YP��4
���T�R�]�S����

d�����dC�j����K�R�4����Y��^[�;1�2E��4�tW�)�4��T�B���9�3��y��,8�y,G�K�R�)Z�] �'RBV�s)�;�xxQQ�T7l��7���Y7��
��%EO���{�9��tlF(b�&�i�q����*&;�����Ty>��x�-77�� w��FyQ�<�f���
�H�������[�< x��O�i�>�F�@���(��uZqjz<u��RiC�� �\�����PqNY�P<*�)(bQH�4�w=l��-��A��������2D��T�CN[�M%F������E���<�����T�
��#����BeH������55L(�*�d��|H*�;�M+�d"��H�N�a����z�E�=�a$���E�bJ�H�����Z�*�A�6������g;��ha�Q� I"D�!�h7��B~�fT=���@'0~u����������.��E;�a�����H���UHAwF�:5�;�@U!�����C��t�������<�?�+_�X�"���@����o�{}x�����G
-7�"z�,4h��e/�i��c��@�u<���i�:PB}��m��m�^��6C�W�T����Ra�w��i�(���G�������Q�7��M�*7��:e{����������<y��.���8����C�"��Y�[r�H�M������2f�i������D�*V���>K8Hc�-	��e$`$`$`$`$`$`$`$`$`$���O���O�����Y��W�[��e�z��J�T��|���C$�@����L	;�e����,������Dhp��OnQA���4@l"s�a
�\nv�y9��@IDAT]Z�,w���/@2�B�pP��|B<��	�M�7
hG/���#DB?J�h�M3��]��.?�$�� �"�v4�� ��/��I���4=$n")����(D�#w��0��,}G�f3s��W���1�	M���E����w����e#�}�i�I��	p�:����v O�����
�C��{Ws��hD��v�����(kG���E{q��pD�X�Ve�:R�������^��s��������d�WWWYo}��	�.������FH�u�����m��z
���!�G�}��[[[�Co����os�swss���[�>���{w�8 
>�� ��7oB6����w�}���(�\�~�3z��n������)	��=�;8)��2}����,X@#T@�������A(J�B��z���������u8*���Ga��BW�;lo�&;L���<�H<+�(s���M�H�[\<��
�Y��5��B����P��#�Fw���������B}l �`�/�B<�x����00<�0N�~�5��B���&P
�C$}�a
u@���.�]zp}�sX�ej����tp��T���2F���-�q`_�:X��]���q�'��SYzD"pz
�G��Q�����,�������hu��z0'�#����vP4�g�w��y�� |X�� |$�&���/@pX�&
���.`������?��2��P���"8�&'��]'���	/��D�~���%��w�y�N�:����g��������G�ZZZ�^����D���O>�w����O��1/�eF~�1��[g��E
������!�|B���x� FG��������.P�
�
1}<���.0-��S,��h����T�Y���^�B�&43�`r�_��!������.��>O��>E��2�C(���Fg�
A?�`��A�_FO�A�}`�
X#�K��x4��l(�jX&����N��@�
(���_G�a�x�r��� h�KO�+�Y�?�p��He!g��AWmt.��f�?bs�S��^�!}��� ��������J�i�:8���3n���l8]	fA(Y�Q���\]6f5���yt7� ��F�x\�5T�ea.����1�����7X�����ElM��R�_M����;DS��b��0:�R��$����@T������\�rI�"���	D�dB!
�a~�`Q������J��)/a���#F��J�����0�������5�H�����y�����
�]�:���!��I�.M��W@��p�
���KT��0����Q���C�F��e��)�G5�p�2|�#��]z~g������
j�1F3�8c]p�p�G�8��f���2�����^���lR |���b|�)XC���s�*P�\:�����vPF��Dw(��'Wg�#���.n�cH2R��par������=�>r�VC4�1�I����x�*@q�B<$���uF���b<��,
s��G(8}�0�S
�a��S�����GrE��
^(`r\��&��t%�8u��j�GpAcC��d�Lg�Tz
�`Q��\��w��^�D0�D)$
�s�%����Lo����P�g�wTC.|�b$��Q"NN�BA����.^P�Dnt+���s���������K$D��u������_�
�5p�R���
-K:<�!JZE^8\���/<���>���P�����+�
�C�\0�&:��`����Q�,�	��k�.^��&�{��K�.q+|�9�E���c(D��#�,� �LO��D}�����K�:y��j�]�3Y�!����I3��]��C��x�Q����U#4��`�x9�Qi���S���z�hj�5G��S0X���paRf_x��!�����M	�
���`�-\�'�G5�n�2N��p\��x"R�*.eC�����;�� �O��u�^�����0"\h2��	�4a����C�3���fA�o��/Oi�*(�8��w ��CpC��@M������>��g�y����'0�F����`H����Q��a�W��BY��O�g#���P;��z��7ep_���'*���K�H_�u��L4)�d@�0�F��~��W�584\��?�q�o��LIl��G�A���`p!r{����#�>�����e�*}kdT�)_�����#S:9D���z8�%:`\�@����Kb e8����1!V,v1���y������_&��PF�;�$I�#(���F�cP?1 :<j���;���as�g|�k�@T�$j�F �����;�l{��CY��G��qb0�������JA���(�}`�����4BE�6
;H�)L�a��\P&�BM�?)�/w)SS�`|�H��0$:;�#�
K#��bf8
�a���z(�B���I��C���(���I�a��������V�����$A?4��I�	��8��S@}@��j��p�v�
�#���;��1!X���P��.����`���:!��MC$��e�6Qz�/�Dwt1?4*�� L9��=a(�U����+��u��e�gj��v ���?I�1A�2��*�.��P"���8'��X`��� ����.��Q
�`����pt2���5���@c����dE��=�7��cR���a��d�"���"�f(�H�����C��yq������I����v!d��!�pXX�����t!��m�s��s���L�B�x��O��'c��v�F0'����@ ��[1K�d.`�R�"�"��.|�5.��{��q��}DX�$	����X��j�5P���c�w �05�B4�C$����`Z13��r�SDA�G�,"Jq�;��O��2#x�#�;�p��z�fU�C�~��2=��P�:��:,���Lp���N4�3$G	�h�)��2*���t"�I e����2���VB<<��������K<9�BGtnH�������rt�M�����e`�C;t(� ��d�C?�C$��2�k�I?�l ��p�t��<��Z��&,@0�&A)�4��b�v����Cn�(�l"���JD��!�H�H�H�H�H�H�H�H�H :`^'R�_�B
%FFFFFFFFF���	�#�C����������������@�%`��k��g$`$`$`$`$`$`$`$)	�:R�0�								D]&����}FFFFFFFFQ��>�#�)*P�
FFFFFFFFF����qAg��9�/������������""�d2�A��b!�FFFFFFFFF���Y}
��������"$@GH�########��K �7	mK��6��������������������@	���8��b�����[FFFFFFFFFFH�n4&''��SSSF"FFFFFFFFFF$��������B�tI�[FFFFFFFFF"�DB���8j5���&C����s�u��<����M�z�-y�:��yT����P��[pA[4��tj�xD������������������`q�hX�W��+I$�/��e���&�>�6�MM�:D���U(�;D��lrz��"���z�����~iW�yC(����pa�
+l$`$`$`$`$`$`$`$�F@�".�e��)��dg��#&�lw���s�2��<�Z�M�YM���
��hX��>t]��m��00000000G�R��P0�V:���n��70000000��|h��_����������R�����>(���y$d	���^�{�����5�							��|h�lm�X��+c<�����,/W��d�G%����/���;��'��40000000�_�������p��Ww?�����<u*CT������o����~�'����,����������
6���-���t�7~c����/��C0d������[�zu�����'Nd~�7�76*���u������N�E���iB���H��l�����_?��]�������s'>����^���o���O�}��Ij���7����o�U������������]�4��Y���}��p{v6�����~v�w~�������Uy���?����-�����������������@;	�d�����{�������������_Y%V�w���������/]�6��/���W��~{�K_Z%t&��_[���{�#���K?����d��SS��}nie��3?s�(ym���Z]]�o�����z���2!�h��	�����}��~ieq1C�q������������`���;w��d66����14��CLu������g��}vD�W�N�8��re����g���T1000000��K�?��b��Ws���\q��o}k�`��7��e~�s'K���J��~o�s�SIh"����Oz�������3��,�u�����-R�����$���R���w�(��s���B��v�����$�����_�k����:��+���n_�6�`��f!��x��������0=�f&��;���O������N����������/]����'�._6G������������H�?�f]2��D�Z�9��c�HgNN�.]���������}�����WO��������r����YX�"FOO'~�'����>���x��o��3����}@6:��3�������������%m�'��������3g2�[�����,�����?=���������fgy�`

r�_������M��N'^|q�5h��0e########����yFV*S ��"L������VH<{����$����O�����_�Z��r6� 2cQ����S���W���=������v��z���b�j,�%c*���z�:?�]Z�pq����s����h7u:�'��7���l���?xP~���{V��6��4,��������eq1������O1��~�Df2��)S000000008V�4���Z��Dl'OfX�L�K���o���O��ys����?�������������v������w_zi���?���\.�����^pf�c���?=�����p�}K�	;T���`.��D:�HJ�[t:|��j�'���v��B}g�E�a#�����D"���������7\����~�������_���w���}��c?vj���)�8
���g���-��nnV����?�����9���7�?�Y���2e########�v�	�	��[v��Z{X���_�����?>d� �����O���/��������B�'���Bzi)��?���/�]�0�����_���l4�c����d{����W�L�����d�v!,PM��[�p*���r���V�.�;�D��\�CM���U_�ff�4����)o��F����������O���N��?x�]��d8��������������8>���l7����'���������{,�`1�_�+�l;��O�~�+�����?~���������������������@"��OOO���vI������������d�%z#}�a�$��-O��poO�q�z���s��3���4��2;���Bi@�<��t&��@CC�^h���
�+��������}�$4�����`$`$`$`$`$`$`$�����v��2������z��$�Y2���	�:D��H��������:�
<�������i$`$`$`$`$`$`$`$�*���������u
�cM�Z3							|8%�@��������Y]]���c������2?Y�p��Y$u���^x!������.*8�����Vk��>�v��y��+���>D�V��*��D&�i�:�w�P�	9��}SC�{���[�^z��!�J,��gOk,���j5455���ah�P������G`A7�v�(�N���q���%4<;�v�����I>��g��S�N��~���\���NM$�au����d2������w*�
�H8��A�}Ue�y��w^|��x�j�������\��N��z��1��'&z�,��h���&����� }���K���7@}��UbJ����������wP���c���{"awX-���p��G�=��S�1�			|�%�A���r/�f�z=~�ebx7;	tZM����q���g�y�De�<0���d�2�8#$|��*N�7M9�z�&�d��L&�i���N�j��$�6ZTX2
��N�%���4H��v����9�^��0Q�GVC��8�0��R7��N����v�Tv�0�aoay6����Ze;>;�;�:��F��q��W��wwwp�Kj��>�@;�`�v�Wv|�:B!����5�}_�~�nI6��7o�����5(���b�D�O�#@���X����{" ����U,�E;Blx1���66'�!�;8f�'O��G��);��������4�"�4��X!����}��}���16*��#����$
Ro������A�=�Yxa}�����#_S&��H�Z�����,���	���Y�e%4�ht��
R���
��J]��;w��rkP\�y###��>��������,��C�C�I���Zz	G��W^�${����cm8"����`��:u��
8�4�:�*Rz���vp�)�/�����L2�������/4\����/zZ�L��34�����������z|�<��E���<�3B8z�u�(�M�:[�LLy�K8r�x�!��$P7?��)����B���������6[��J������w���.����Z_����z���8���i�_c�=4`t|���d��S��>�A���A�������
�]~���N[���T�Al�8��>�"�V<�pB��]�.Cez7�p�E��[�n~u}�vG��+�� ?�P��{8���hcc#I���p�v�o��8�j8x�~gx�T���I���h��Si��\�3~�e���M��S�O������"��� �q���� ����_���]i���e5��p)��
��b���[��_�4���:��4���#zz �����I�x:��89� ��\_�G5��A !���/�bH�h���0"a��(|������T�o-����.�'��	v. �W�r�]��&���q#�ew����V�e-B������N��=�O)�-1A7;��HY������vp���'p8��MOO�5�<�+��
i�zEH}��A����j������p,�SA���V��o�2]���
���O}���
�;��-]3e�S�E�S�3qy*�O��]_)�����PvwaC��'�v�D*a1��/�n'
��n8�������p]�.2�?u��[��.H+��.��)x��v�G������.������HA�u�3\?��������vwu����H+�h�W����o�+�p�-]��@`i�x�i������}��?���1�3K8>�f`�70\��~����f3�����##��H��o�%��wcH���&J� o����?�q�yT��yr��$�vy/��!�r�m�Hx��a�05rJ!���lY��@��	���
L���@��tl|5N���+++�)���I|w��j}W`�A;�qntb�������|�����jl|5f�\�]t�~��qd3�Rz��d�{���2�s��Q��g##�@%ps���'`.���@*W��H T	D(
�LbXh���3�8M�U�k��)�cpc�h'6�}'69'!e��#��M

v�%N���e�Zh��a��bW�vBc�W;�m�A�|5���'������lzl�A�}�3�%���y��Lx��k����.x1����3������^����� N�|u����������p�9!O9zx�	M;�f?�)q��(%6C�g���W�%��5�����������G��C�������H%����un���s5K8F�����@`R�M��h�cb�s�&���6�B.Nz����0	���&�A�����9J
i�����2s�&���@;x�8�la�6�
i"'���Cv���
�1v�|�����Bc�I�C�A��S�v��sl|5f�r����������wC���P�q�#���J0�Q��qa"of�|�r��=���`�S�csL
}�o��Q���v=�G�16���������`la*��vc��TF�����&6����9��C��2�p+af���a�����h���x)L������3Wl� )�8�(�pQ���������JqX��L;�'�;���};����� ?�W;A���s����#��t"�vw��;�|���I��s����j�UF�v�
����P��;hst`�si�?q�x4�X`�9�������JB�s�GcI���rstw�M-s�h��V�9������H�H 	�V���/����b������!��4a$)	����&B��i5qZ��658���$������8��vb���wbs���s���Y<�`l87.|L��t����
8��t��1���;!(o'_�j�9�!�M�M�v���k�_�Aog[wl"N��4��#� �p�i
4^��)sC�1�@��2�:N�-�s���w"�$1��y�������G�vz�i�k+�����s�C�s�M����m{���:�<s���V���tff�#�)_�p���}3f�����Q	��k$`$	��������~b!����sfb����@�8f	Gc�������O���NOO��������0���:��	stg��.�%.s�U��i�r�s�;�h�w�Y�8�la��`�"
�iF�p��&1�n��%�-st��8*��9:p��0�s�9������!�-|
)g��W�\!�z�����lrzePG�v8�&6o�D���h�`��6����9BTr*GHC�M�w�9��3pTq:(
'�9����N�<,w*#il��^b��8����G
!�A��&�����'wB����>}�����������t�`#*st�F,*��5�q+�b�?�)���s�GhN�����i:�����9�j
��V�����
`o�5F��T��9���F{��e���+b&8!���bh�b�`'�%�211� gl�Et��QP���5E���i�=�9zp1	�9zH�
-�
G_M�(�s��@@[����e�|���#����s��-�3A�MW\]]�v����D�����K4��mrx�/_^XX�L��	�s���G������%P�o?,�?3�+��S��Rb�60D*��������T^o�z|��'��9Cc����_��A(p?+GW���	�v�/�)M
{��un#�����x����v�W<��h���M4�Hv369��ci!m�H4�Dz�K8������v06.��q���d���1y����xhG���z�N��W^�,Af�5��H=��O6�S8�2hF8<)p��|�HM����vp��u�>K��nh'�j���`�`��V���a���@�_��S�r��.��X8�����? M	=<G�.��w��(7zp��=p������/p�
q!0c��{@,��zok}
g,�]$BVrG�/�=�����~�p�������1�����5�_�����/(�9������� ~���}�����7�	��S�Eo�>%>��AD�Z�3��R�
G���;�����n<@���Y�w�=Bsj�~������!�i��h_�=~7=��a
	��o�c��&���`�v����t}�][[�����?��;�v1?i�/xb{�Q�zX���������17~
oG��7�h��|�Zh�wp8v=�9Mhz�p��
�.�O5�	v%������G��h�����Cu��/p�s����A��C��G�n8�@!��q������������q���#� �������1L�~��k�8r�]�-��1�@$�H8&����>Z���n����	�i�B(Q�
���S���~+\W��� ���������=\���Bpi��K��3��4~w}O��4�p���q��7��������<l���sn�t��f�]�3\j�����'��R�T�p
���F�8s~
;w���S�Aw}7��&?�h�'8��k��/����:����Zp��.f�S��#w}���	w���GniF���.O��w��@.\h�t�3\���Z�pi�O�pa�<����I��"���S�Z�>�J7~-^_<�\O�DV��X�&��rg�)5�i�uA����
w&�"H%?��;O�����_�u����	�����w���y��r���8�iH�RA��(P_�����{�8\��ij���;�4-��]�^��a�-�^��v��K�Tc���sq��=�v�[�v����=�0��p^�������$����R�U�]�&��GWv[��g����Ns�n��|�����P8�I�� �����x+$%�B�y����1
���[�E�fb8�����;<Di��x�xi��0�p�T��T_���q.qb1��tb:pv@��F;[��~N��c#��������\����W�
H�2���`5���d9����:�Y�A=��z0�&B��=!��^s�BW��13���5�v������1^""��3
��BF�^$�r��k���ex����'�s�m���S����(}'6��i@���F�����M�N�S�H���R�@���GD�&�3��"Ng�����do2��������s�#�#�-N�M��MV�s�ipX��8Mo��+D
�)��9z�"{�	�v�z�O��dY���E�#�d)�,<�]��H3��Qz��h��()���A_�~�m.M����h^���r�D8�
G_�����&l+|�,��_Mj�tb:��r�D8�<_}�U�&�����666�"5�x	�h/n���*��=����
�FF���~��^�&I���gs�������'��6��H�H�;	�5���@C0�N���1���9N�2$N�i����>��
G0B��M�	FH�����vb�B�x�;�kY��7Pk��/�or�fcy�*�42\�	��h��}�;������m��7�q������@�����������`g�4j`gw��Lx��k���5�x1����3������^����� N�|u�������A#a�&���$�N���AAx��������]2d�!��NX��������?N�O��f�A��;����owc}m��
��;�����q�D���8uN�z��6�q/��x��'�����_�r%<#�M$v�9�#�fYL�
�#��v�
���T$p���>��H�t�8��D$���`"��f���&���6���'/F�����j����:o��M�V����2I��ZjCh���-����*����>|(��Q�����w�=�_�@3����87:N�r��s�����j���v�a�;��@s�QZ.,�&`��Sl\�H,*����fN������|�
B6��A��h���"@/pc�>�tPz	�h�K��"aPt�	2���������q$_������889(��>�}� b3^�R�����Hp:s���2��s$�F�x�8�4�1qZ�3��N���@�W�3�4�3�gW:N��S�Xr���O�����O'�-�^�����'�H��s�{����UF��p��=�9z8�
+���9��q8(�K���k8�����0����Z#�V��r����M���#�D��rst��rDQ�@w���.%r"�� e�����������GLG���"��c9j��hf�}L4�p%����8�6B���g�}6�����YB}D)�������k���zHv5__���:�-�����������\c��!���/������������4�l�`���WWE���V< ������{����s�=������y���mN�!P���'���#N�R�2ueM�P	�� Y,8�C#��f��x�){"'&&��}D;8�x�|��E����������i���n^?-�]���Fp�������b��q�lS#]`��x!����
�������^��Y��\8���;H�h�M�|�����a���r���K�.QJ/4��n�

�h��U����T����5�x1f�vP"-�����T��stP�|u��[��@������qI�w����m)��
`'6����9:��O#i����d������#��3�M�&�I-?���+�}(���-g��:���#�!����GvS���"L4�@�f#�?��id�B=z0��[�a�fr�����
�#�h����o����Q|^�9�QT�!M}�%��@��C^�I��d!my�"��� 4�@j0r�b\q�b�	����gst���!A�~ �t�!�����&ICRp4��*N �s�&��s������ivE���x4�h������]�+u#t��H(�-��9:��	�h�����>���e�3e��n%!>��"'�vZl�31w�!�v�m���D��zz*��a��n���rJ�����z���������:z���EA�`�;4e�[��2�F���B���X�=�jZ�[��\���e�N'f���:N������t�{��g	U��$Y����?�����@}��m�CVE���<6���N��C�|D�RqZ�I�����q�i�31[�'�`lqrn�`&(�����7����(D���o��*X�P�w9���4}������@�8��g	�1��Y�{��9�8������)sIG��R)^S���G��!o�e�u�x��|�F<��������a�:�o�[���~;9w���/�r�N�@��Bs������G�S�W ����0�C��N�d���N�C��7����A��%?E��0�o p�V�	�Sz��
W�s��S��_��8�#?uAn���08Ms�������4���[�1?�	���<��R�7E'vA�C0	d�ItQ��n�4k5�$�M��M&k�vP
������H�Q��<K��S�����p�DN`�����Tn9�o@��m�zEg��v�����J������"���#��w8��_ 2
�(V������#f��W�p�h=�]���k}��i��&Z/��OHU�Me����K�����
\��2�~+��0#�S3�K}��L���~�p��o���!O����~_8���`���yl}*��i��W�.j��
�B:7~���=�nW�!�M����8�����)S���9N��[�3�y�L45~����v����O�@0��c�R����p��?a��=p��]}������=:p����n��v��A*v4��p������<x�p�S�!d�w�	n�������N5*�� �LA��p~v�v[�������]w}8EM}�QxP������T�y��a���q
������
G8�A��^������Dw�_�V������oW_�!�����e��(�L�9���������h�O+\�I�)�@��^�-��(xM���_��}"�<�����[V�������~�p,���1����b�Z���wv�D��� �?�W�!��p��8�
O���p^��������'`�� <T���}$phhm�898Y�	[�w���
.d��Q��v;��Bq����l���z���q�����	1#����A��G�4o�'P������
��^�H����'7�t�Tp��������=r=���qL��_p;�4t1���x�;h�Z�p�pZ�������/�N�r#�,��@���-
z�����y*�����67*
�@�-�������G���9Q�P�7��Q
����??4�������6�+����'r��x��������o������U
��o~3������O��k��v�Jz��T��c��-��g��M�����w�&	�b��M�:E'�,iH�u�=�p��n�w���8���L��S�(J�D�a���J���q�,Q��k t��~�D?V�6T�W8p�
�����.��e�}O�a���������E��q}A���V&��ZW�� �^���������H��=�������i�EOx`5`[D~���f����<C�����i%�vi�K��s@8�!���ar��������
F��4gk�	Pn�]_���.t�_��{�k�hR
��������;��u:z}���R�������3n���^��lk����`�p����o��{�m��S�S;8��Sw�G�����H6�V�!�p���[�C�On�9���OW�z�y���w��.���O]��;*8x����������%�����>���VB��\�������q�����9���!��n.@~�<�O�����.t���j��a����V��7�o+��������Ah��
�s�=F��,��I�C N�����A�a����#w��3�_�re�>���lVy�>�lI�;I�:_l��j�%�m�8YNh�)�	������m��o��U�^�9�QS������v#v�4�����V�aGVM��VM0dr��b!�|��W0��Fr�t�4�h<�6�9��&���z��
�F�x�m��`�<�Q`�	��9���LY��S8���"?2�((��?��4��:[:��N4
��M�1�@/��0�z���4h�x#8Q��&I�\��8�i���:� �N��O�CB]�;�=�wx'�W���	6���,�_�����m\�w����&�|@�YR�]������4{$
��'���FQMl�K�9���2��,G��������R�N��^��������-g���=y�q�i�_qZ�3��N���@w��F[�o�5�I�-��%�������B�&A���s����7�j�9�?�;��(+PV?�D��1v==?xe���"���6r�����$��S �4b-*��mnn��� +R8*56�x���r��h�$����ekW G��������	��qcee5�V����v�T:������MDs�_�V80�����m7�y�1@;�U����Cl0���?��ptl|5f�\6Iw��X���
��O}���`k�#�b�8����8��f���D3��FVcqq1���Jp�fS�OE�>��YB}�R��Z��k��[-"H-VA��k-�d-�V��%�&T=��rjr0��:�Jh�=��7�j����t8N���_n�����>KKK�Gw{��X���}��>
QLbz]���Jd@���4-C�d�"#�A	����
G0B�	 �4�\�yFH�����vb�B�x�;�kY�6��N4��zb����2�����3���N��<�d���&�,A�`4������V��8��b|.T��������������vF@���q2�%6�i�W��@��x3�n��vb@�wx-{C/��8e��qrn+���
a������V�3����:��Y-ts��jP���/Y}��r��_{�o��@�
b�~W��
`�O;v:1E�@m��?�9�q������q�W_=�%���[��o����7S���c���q���E,2�@G�w���>����=���
���-�9�5����/�7&*�U.s	L/D�F@IDAT;�Bp����.b��]��Z�p�>���'�/�d|k�HB���I���Z�Hd����&����Isl�
1dr�z�(�������_V��C��E������9���B3�@GV;�2
�Y
{"'�s��V]�a�mM�����@�
��q��t������N��4!����o�QdS�q�@��9������9z�p�IRp�.l,�Npd��I��M��
|��PN����Q�K0}���+��;(-���{4����p�1RI�3���\�XMM�o�c��
��Jc�1}'@��/�N�5����V��G�������q�@��������� 0���D�%�=�������%^Z)���+uL�n1���Bg���@q�/��=I��SL#~&b2����iv���`'�CEh1��'w={w/���I[�sV�9cN2�D��:0W �a�~���\��<7G��*�
���6���j-?^k��;��]���T�]�~<���?��
���t�����O����[���#n�m�����{������^E�M}����n5�:t��l��G3�@+������<�E����'�`��
���<:���h���!}��K�l�D����-�6�z
�h����'�ue������������
�;*{��x��7�Q�:���=����6G����9�'W��$�,�:r�|���g�!�&�>{�l��GC}�����k��#(��;\qZ�,����"��d5�9�����N�vH���@��?Jv3�s�I�>�&N��$#����0w��:����|�UhX��kMNX�N�oe�����'d�B&XugO�|h7��zSQE���1�N�n9�Y�`!^�����[���A�������s����=��������G�1�@�d�I	0���u�.�����_a�HlvAa�
��b�A���*4���y���p#�����D��9z`)��s�V������O�Tv��dY��,�h�����|�z�@e��"�+���������$o�j�,��,���������o�}i�v�m@&h"`O��F��e��!G�����W����r�&~�R���w�r��L�t����FUN���F�bz
�s����v|h2�Ld/]�D�YA����F�2Q���D��/hbP�D�y����h��7�����1h'64}�����O�:N�-�s���k�
?}���w-�����|��d3���>u�P�Y���[������%���W�%�'�M�bA{��2�m�.� p'��&����dt�P�����W����&s��������/0���h�Y�X������42���{FJ�d�#i��\�w��@�Pv��y���bD�.\�V�
�1{����I3;�t4������$�V��Bb�H�w_����"~ N��x��9��Z#K@LM
Y>��5M��	7����P��	g��g����s�[�g�F;�=$�S���������@C�us����x.Z%�D#�`I�?�����	/}����ve25S������0M��oO����N�I%r!/s�c-�OM�����{������h����',��kW9V��� ��x���\XB4E�Ud�Q����x<j��{&#����6���Cx��0��&)�]5.����x,��W�wb�Hm�*b�a���mV�&����G�D����$��h2��SV>o��������YFR���)v��&�����6!�sH2�e=��>���y\��v[:
i�a���MeM^��x�5�����"�����%��	v8�����=�jG_�Tr���E�c�+�II�t'�nk=*��D�K�����n�	��`l=i'��+�xr8}��`\���H��#2 ,r�P��7�u	�0 9yr����S��Sv���?=�x�#M��G���h �_�|��S����	��v!����'8���C3x�i<p��K8xD ���@0�AL����!�A��C���C?Z���%�g��V<�p��2�;�="X�K��F��H�{��P��Z�=��}��w��~7p$���M}���N0p��)#�/��E�b~B��+�Vz���
<�b��5���y\
���'��p<�� .����\�{������K����t���:�����H�5���s�tf���
�|���n��jj�Z}�\:�xXH�/�r�~�3�
A��<�a���D����x�
ka��%�}�}(K�r}5�����lz��\�J���Y[��(H�A��+�_�WV\�'O&gf��;�N���_���I��`��������?T���n�K�b���K-���h?L7�-;�� ��������?�N�|�8R}�w��� ��M��>� X�,P(���wg������Y�%p���~Pp�����p�A�B����\��������f6�S��\��~��[�G���0�8�z$����u}���JM��i����A
���,
%�-
� �����=��y
���'x "�b\���8u|�k����� ��V<B0=�J}����.ry�����M�G�"����`+�k��O�V�����m|�wG�2d)�=<.?��]��^�����5�P���A����M�x.dK�|�i�Oe�����~��;�v�@�"O��
��.��W$ NX� 1�J5\?��r����������v[��^h]������]��
�A~"n�����n�T����]����4.�F�z4\
��[�nz�����1K�8R�'��p��	���E��W��l���4$��=RM�A�����D�l�;��/�2+������N��I�\Y^�,�O�KS�r���07[Og��������K�Z���|5�@��S(0� &�"7�s����F�X(�k�<��P��>�#� A}'d')�H��G�9�OO$�''���j*17�������/��j0E`�����~!_�VXS�gEx������j<"�x0$�9$�nW�������XX�;x��B�~�T�De�QX�aw�G\��4��S:���iW�P�@�n8���5���L���N�������6�k��������B&�'L�k�|���>\R��Z�d1b��
"e���`G:|<v�v������/�fCm���+G;�Cm(����5�d��itx��w�}q���>��
���1��'O��ix�|u<�0<�������4��{�N���rr�����K'2�y�rdW��n--Y�[�.Y��
�����O[���������7���]+������vRO\�VZ��c�!Q����N�s������b���m=��u����;�l�^�$g�.��.�-�?K�i� ��rEmX����m�!���U��&�pQ��������'/zV�txT�"�"���$�)pb����s��r����o�e�Q������o3������R��S��_�|�t������������FHI���)�W�����J��_b`{.T�����n��:v��2��������;�G�)��h'$����z�#���cP�@3�����6r��D����q��N<���A�����y4/�'S�F��C*D������v�oO��od4[	�ho��I��g�����k����S1.5��,�AG^W�-��U�������5����H�]Q�a�c�h!����[7>���<.�������`��:�l�vVK�.&u����//��r�T���h7��H]�8�Z�w�N(��v�����	��$a)���N��`$�zv����rc��vb���wxGy,�cQF�9�����s��,�=;�V&/�7 f�r�K9v����K��}����Tdx*^��>����KE�0�+���8c��X�O�
����0�dE�K"J�YQ��]���1���lnN��LhK�;|��_����
�i��� ��g�1�
���a�WY������9�=7��Y�ls�F���
�n���`j��;��Qk�bq����V��#v�c��x_��b� ���;v@�����c���������B;��o��R��^i��W_{�_���U&$�-���GZ��\��gf�t.��fb,��zU��k�O���Kw���*$�9����'�<�|���
�:�������A9c�w�cml�6�t*��
|S�k}T�������E����Td<��d:�:���Fx������=
�s~��n���G��7�p�*F�^3��?����r��p��K���:R��3~K8�������cmxT��X�,d	����r�����L���ffrO�+��zy*�,/&�%����rP4@��S�}���ei`"5A��/�@�p�8�Y^Vq3��s9��X�f��T������)�����(��7���}	�i�5('j'�e5v�����0�F�{����/LzS��-���\���s;��~_�����8��#�C��c����V��d��gQ{���m���q���z�����Hd����&���c�L��7�E�6C&W�B���{<]d�e;��U��	�O����rFvsyy��j���'���@�R�8j�[OB�leR�>�����8�@1�99!��6cU��S�z���dr{���=�:K<;�>�N@M��;��Q//���B.G���64�$�����������4%�����7TP���]��p�K�K����?���~�q����9���G8K�)�����
5Ip������@�0F�~������j�;�^G�!3c�]���F�.�@�����jc�y�p,��+��N$2����7��w��TN�����B@D��=�$�ha��&�����S��"�����.6�<����0�`w�����{"�Q.�87m��De:��-W�:x%����b��eU����/�9{r'e������K���x>u�`����5��j`H&3|����:S��_v1r$��@���"K;����5w}/*w?B��,JQ��d������,kX,[�wxf,�Nz9y�d�����rR}t=r,�}I�a�����9��d�K�,J�_<G����FQ�gx�8b�kF@Cjl�K;��k�G�"~�+6��D�Q�{����������"%f���897�	�P�g�0��>`�sS4$�)�&;	[���{!���L�j�B���S��X��BBY-ts��nU8�9��h�6���o~8���ECk�Lb`KD~�������%U+��1�c(�A�#n�#���?
�S�\���mE��zd0�Nk64a��d2#���0���<>�y���:uj��i�y��{��L�������������O\���C-�U�L���%��4�q����IW���X��=[��^��m�dE
��c�H��O��_��6����Z06�pn8���j���7VVVP��
��ToT�D�R����~1�/!����].gw���|�C�QfN�$h�~B�Ri'����j���`�:�BsD����bbv�J���Z�{�b����DZe@7��0�Es��&x����S�mhF|Bhg���H;T(T�C�V����Y"�DE�_��������jLYY����Gh ���W����d����o[m^D��V������Fl ���b�^0������{]�6�\)�>�n���P�k�i�
�p�i
4��>&���P/���X�//��Td�����%�CK��`����h2�eu�o��C����!�����/���wf���c���+�=#&j����7���C�	1�Y����[�����������Y4�Zo��bV2�<"�os�m��%.TMEZ�@z�#�v��[���@-\�2'�L(����R�)8���]�B��'��3�������=��i6��p@c1	���,�wm �t}t����,�+L�.�����a��������8�&1Y��������+�'�[�L;�8�`�M��}J���������Y�e#h{8M�y�`����
G0B��MBF�9�#��5��������Z�C6��i!x�o��v�Q��2�"bo�Y	K_�KJ6��P%��'���f�A ��1���k��Ut�������h� ��\�]w�9��5�`�3�.�g>vHN�J+�%lu����V��re� ��QA5h ����
�4�]O,�� e���F/R��r���V��Jr�S��~+�}CPN�@��X_�:2�X7������CN�����l�l��N��%����hl�{�S�:��s�X���'��jv��W��]NN,$��W7GT��t�e�4j m��v����4�+,�����5�x1st�V�}s�st��
�&�:N�-�s��u;��J��|v&�Jf�$�����"�+�d���� ~u��H���D�A���R/5�<��j}���|ir�� h�
���f���Iz4��!f_��km]m$�����xB���D�N�K��������_����tv@�BUV�/1.e.���)��A���P����SP�J�W��$DSO�85�!P��LG�@s 	{:KU'��T�b�t;���9�v�D.�7���&�0��\�n���������k��f�j�v���R�n���[����70��qN����/�`�@��r�s��3��1�s���ip�9���2xL��8�Oc���+W�����=�����lf2U���d����z����"f���8������E�r�Q�Q��LB����QG��$�|��u��+�O�PX�%����w��)���I�Efc:�,���zV��vc#�&k
Y_|�����������I*���i;�� ���V������J<�y�����d��y�io0�^���u�� �e���h8e��&9<\}X��|�2�.��U
}sf���	$����6.K�	+�G�D��R�J�:i?^������]m�F�	m~�a�����6�������+j��Z�Lo����M�����TfV���"�>��g�I�������!��yLlr����96���
�x��&�{����_�#=��Y}�<[�R������{"'�9��zc"e�j�S�]��w���zi���'����y����5nW���\9X����W��o�KV����+�q1�qx�A+��P.����O����D��8����7���g�����b����9�F�x\�����@�P��DK>o����r�1[���&��j��i��S�hXBpb)n��$V	
[��N������d���[��7���I�i������@#�G��g
O����S8�T�tPv9����@�����w��`�����bsJn��o����NtA�����Qb�����Z�������e�{2���N�����g������.��!dyus(�N��<�|h"�[�n���4	>j�y ���g�����`^b����YA�zB��l"DM�" �va����`��
�mj�9�����Q���i����Wcl!x�pdSv�Z�w�S3���bq���J�������`�h�\��I�wuvg:%wem��Y�=:���L����Df>Y+���s�Ro��A����������>����k�tc��W���,#�u"U�7����^=1�`]��(���3	����m����v��>8��������	�U���"!M�N��\D��Z�\#ebA�E����$��/���o[������Sv+���������Z��E+�/�773�:kL��6�����i��Dy�J���@#%.�!q3����?T�V_��[�OF*)��������5�(�w�r���E���Dq�������R��0�*�v`vz�L���004������#�V����/�NM�����1O�s���<���g���z.��<Y�1�l����!������A��e��o����-%
�:`��z;���+����;w��f����x��l2c:s���F+gCf��*���&D�t����vb3��x�;��X��4��D��nL�9�Tk���{c����������|�Qymsc��zz��J~=_��s��w�����n��Y���r���e��������xou5���p��u6�--e��n�������[���5���M,/��p�Qcf�>{��0��r5����s�������7��%�@����m�"`�!,�'vwmFOM[��U*X�	eY�����n[o�e���u��53k�=g��@Ef�n�V@�Y�/�\�.^�v�Mc�Nhugo������|Sp"gm����or255����z�^~e�VR1��D#�����Z-���&�7t|�Y���U�,�Z�>����s��8~G,a�vy�(8#�������O�������Y�`��yP��o|�z��z�O��|W�w�wO	�x�0�������j��2�$��_{CM9�J�=�]%������?�������Y�JU���pQa#^��j]G�l�|�-��Gdy��ndc�D�*wS*+S�Nd���3I�P��eesjA�'���������E��	�o6��$S.��#�Dz��`�O�������t��9@�Y���sOk����������N�/�������%&}x�s���S����g�b5��r@	����^0����L[P?�vB�M�������FHM�&T(�4�X\�G�M
6��-����d:c��>��}�0���Xvvk���-;'9�c������#	���{8�l,|5��7o��6lo�R�V+7���Y{*1S/���Q�����&�{����7v�dO��"S�����Y^����pe���'g��y�����Zz�zt�����la�d*��x���'s������^/������?{�cYr����r��{������K�A�R�����C���g���6d�[0L��aC��K�a�~P�DY��\.7��N���_�����nu�y�iR�t��^{���{���9Uu����t����z���F��W�+������v��Y����B��T�X��;!���u��m���Z0���f��|e#0	�+/���;�Q�������t uN'�ZC,����5���0/^�7�K�@u(�_���l9�I��>�x*N,�__o
&���/W�ry�Qn�F4�����w��3���{�����%#�D')��]����J�%R��f�Nn�n.8+Vp�����~�T�R��zP��V�(7��pX���*�=V���s17�sH	�MEY�n�[y�0����hA_��/�����\Y�5�Z�Fy1yu��h��%��Z`��>��{����[�:��}���+�T�������g��`am���}5����;�X�Qk����\U�����p[q7�up�o���.+�|��~D2���Fv��
����������K��K���z���pc���-�]��?��1���f����W7�J��9��)�@�f5��}?;�tUkm�^���B�6`z<����[�J��Z@����hU�U�T.��>t)�2�a��]���F04�.,v�k��/Y*�����Z�n���o������J|]��+#U3gV������
m�f��R�/��rKWf�w67�A=y�P��)��[��k�����F.h���Ju�c��n�a���c���^8Z�42�_2}	'i��P*^�)F���|+�8=�
�A���Oc���K����}�+��'���z�;^z�v��n�}h�e�Y�,�����v1���<9�����K�M��{�8^z��9;5�3�0���|�f��?aI�gOo���U_���i�V�;�����_e��Y��|��	�?~�y�� ���,��s"�8�L��{�������>��N����]�8q����X|�C�v:�g�d���k�~0Hsa���c������e-['�=d�����4�LG�J�c�=?��l5����md�C����W[�o"<3~q�p]|�����F���Y�����8?��N��
���O��E5ifnD������r9����y��o��@x��pp|��hC�x�����sy�|�����or�������7�{����������ns�T�YN�����m9��
J��0�4�����|y��Jv����+�|!_X����55]��y/���[7�*�L��������������Y�\YT��^K/�Z�V�
F���H����kv1�1o+��]	,��\|}�}����&�S�W�v|m�N5�����N732����B�9�Z����Zn��Xt�T'�77�w�_�f~m��u����o�*����-Vn���j�m.WV_�0��+�WW�j��,U�!}��EW���\������������>�������t�F�����������?X��+[������7W���6�Q�YV�+�+���U���M����"��v��o�g����nj�����l�,f����hUW�h��R���v���������������7��F.�_��j��U+�Z�74��}[����y7�-������[w���3���Hr�q���f���o���f6{����n�����f�Z!�"���;���Vf��+�iL�l,\/5�%+����������%'mV��*~����������s���_������B�����l����|qEm�{ib�6z8T)_q���|1_�l�����;�,��X���n�ZlB���eG��s�z�:�|sn����Npy��KW��F���-|�rei�����zu�Lj�����*k�V1�*�0p~*1�Z���g�-���z�:_]]��W�����Vm��}��E��L�inllE�q�bw�r�j��/�����
�����{�Vtp�[��W;�Z'1��cs��M|�6������Y��!������N���S���&�OF� V��bW<����.z11sR�9����5t������G��+�����c:V���f����-Se9��8�7x2T�.5���[:t����; �������${����:��Z�R�:�^+��e�Hl��D��y	R�]���	�&�����F������]�T5��e�a9���ySZ�<w-(w�v�����:MNm��{�$2w�l�^i��s~^6�P��)��B�^i*�����M[�t�t���6	QU��*�y��x�a��W)?�xO����4m��v�������#��v'���4����\�� ^5�+UY#�,�M�4a��J�����^���
��S�TrOt����'IyWa��L/+D��Z�W�z��o�����a" �k�Q9�vQCt5��������������]%��nI��C��t_��	}��>wS*v���0�����]����Ee��Z�&���;�a����w�R�Q	?���i�uJ:Q�OE�����t?��R����#�Me�%T2X#��bH���G"�j�YBfE
�����\����oh�O��O��Aq{lq�H�����[��K�N�kE|zX�$����u}�������s�fo�l,��/��q��1	��O�9)���|��^��8�b7���D�np	�I�I�v5�.�PU�O��tU����V0r�Eu��s�������d�f:(4��(��1		�4��&c��.b)?��7����j���T����O��`���Y����e�;�����K��/����������/�Gf�_SK�+��):Z���
�K��l2qQ����s���/x!6:���o���R����R<�
��
>?T�#���kN�^Y,6��R�Y������P���oJM�>:U��N��DrJ��j6k^_(r�3w�������
���z���3/�^�h�N��������j������l��o%��M��wjwn��
'93�,6���s������R�}�[������e3c����l<Q����+����b�f����i�������������P,a���W��(���tT��t8_Y{�[��o�6���\f�l�����P~�;Y�����(o\����K��o����.%o�����O�V�J�0�o�;o}e�����E����h7gW��`��hj�����sK���������o������j��
������
#0f=���^�<Slm�����Xl�5��O��nq����/.����������#��>�e���m������=Wo;���b~�����oF�L��E�l�?�C������z�����������g:kwo�J��X�*Kc�K�\���C�:�]�v������{5�6Fb��V���'�L��^���������}�v����w������h|��jt�o����3_�h�VS��@�6���v7���������T�\��������-����"	����/|$<v1�97:����tg�%89�	��Pze=�.��03u�������LM8��x)5u��K�WTs�8�����u�;�J���|m���|"��%�������|n�e��;�TIM�}�T|�6"��u&2��n�������WF&^��]�����j��D&}w�������a���p(3����9=�\a�8��GcC����h�qn���|k0h]>?�����B�h�7���{��<#��l�Dj
����Mg��p��C�z�Yc���CD_���=����Z������p#�n�n�����1#��[m� �X@
tj��E=�Sr&,v���Z�U
h:���U�Bu8��C����g��$�S&�K".j����P���`_D8�~���E��R���Xo���t7m;�1�l_DxK�
�2�2�s��$�^���"�&�IPs6��������h�$��/�;��i�6���n+�MN���c�u�BTc�\g�'��[1���Qw�c*x�����������BT�ocx��#��d���8d�����B��]�L`]'}�r��T'���J����c{�O\A��q��7bB���&���C�I���o��
5q��2�(
q�����'���x��u��%daC�
���*��c��}n��z���!*V����"Pl$����jL��>5`w7J5=�]l?�}��2�xH�D��R8j�G�����W������
���m<����MuC[�[aC���.4����:g":�f�J�rD��6�7�_*b��A�I�z��A5�=f`���ye���;�dG���/*�?�Xm�w8B|W��I�����Z��:1�H�����%����H@����q#������*��<0����|x��Cb
��j.Usw+����Lt�f��~
c���%,��Exc$�~������u�?�a�YSg�:T���`���T�	)m��=*p;�C!&$��9��e���3*(C~����l�10z�*sb�������!�.T��%.�����V*}�%�!���2-���P7e]p����D�������-GXx��,���m����H����G��}�(fG�����T=��,�m���U�Z���1B���%�K���&�?�)�v�v�wX��K]�(��������

�����A������#����_l�ST'd�����B���0"�,��G�4��)�HP���z[�������Lc�/�*��=��t�-�MR����N-�61Sag�0�/�mX�xb�<�&L��{�s�#����b!'�a���D#I�A�<V��90LRQ�k�����[K��$f�S5G���E�X��0fy��0{����m�����8MNL?D-�<�OET�*)�m������A]_����������|����"���}���--��� 3�����U�]+%�w���G�/�.]�nV;�
����S������>�+����6"7���/��H����@0`�����'j���
�S�P�j�5�q������>���k���@�7P����U���M-h��bc��|����r>�
�5���HS+���$A=a���e;�b����3�?�v�]nY�I�WJ�����#�`��Y�F[
g��W�_�����l6Ka���?n���w|�?��e#g�@��Rq��rq.f�^87�e(l�����Txb�RY�|�[�L<d����gn^�4+��J+|���"?�h����L������3�N����g�������������o��K�:7����-��������~\1�ca����p�O���aM��j�
uh<��w����gP���p���O|L�|3�#s�,]��D{�B��#[k����dc�2
�J1���F���#���v`*�A��\������BX-V�����nl]�Qg��8���?�������5�l|�6�1y��a��Om��y���LGg^���zq%W�.�M�H��y%>��N�����=Sy�{%���T��/�5p�g�V������{|�eyE����7����-[�dP�G��n�Z���p;��W�^[hk����?��o5��V�|����l�����/��h�����������PY�.B��;:RY0"������5�H�#3����cXz���\�TLWS�Z4���g���+�A�r���R���V�������q+�����l��~M��^;wY��%�?<Q�*X�Z%M6+A��/���V�U��p���d, ��
���i���}���9�o���U/~�N��?\�~�����Z�c���r���������V����_����KE���@��f�������NL�����V�BX�5$1�L��Q��:+g��D`��!b�����n��r���P���	GMY��Yr�������X[M��:!@��>���F�;�7�5��i����J8d%�#��A�b)7���ND|�g��5��io6�(���c��L\�������n�.��7�J]��������vg�X��r�dbf���J������o��ZR;�k�)#niI�1�)�G>\��F�UG���jV�����f{y<<|95�vXMe��&�P�7�����j���22��c3�nT�[�$
5��	�Y�RC������K�J��1Z��p�}�DP������t�s!y��i��C����#�!��j����C���~ `��������E89"	5�ku���)u��8I�f��~��m����c�N��\f-�X������li|�������5c8z~6l0h,=/Bq=������;^ �	�3��Gm��u4�N�0���O0��~���f7*+C������*-P���Zu�l|l$2��[���m��[���BcC���E�����Y9���������7�
���D�T�
���Y6,�Uf���R���6��F��A���P�(�0
�*�n������h1]��Y�J��E@�Qb��MwA5�D�u4:	��v���j����
G������J�9?pn"	�	��tTS�,>
-X�V��;fT�&)�X`����F�������F�mw2�~�H��4�
vn���y=i
�#�@���k��R"���������s��V��n��e�{8F����/$��,]i��������H'�[�[MGgJ�
���m4G#3��p��!�m
��r�t+�R�
��M�m�q(��Q^i��D0�$��n�?8�fZU��gZ�J��+������g
K+�v��&t_R������t;X�F�vj<�%9��G���e�����r5��j��;A3�0��T�]���@b �K�q"yB�������^i���`4�E02�!��(X7-��B�������,2����m��p�-+��i��i�A=`��J�L�p���`�Wkf3�������C��nl:�h`x,�p��Fm����h�Qe��`w`�X���,�j2T�{2K���1��V�]nm�����p(�k���.�F���N��Lg[E\�s��Tp0h�1:��BG
������*{��"3���kl�V)4����}��T����*
Gx|���-5UBV�l<����N�	�;|�")��z��&�KN�)9�X���������1�dkP�/Y�`����r�S����D�G��e;�n�����f��g�3�:�`fz���W�v���8+3�e�T�V������+�
�t�Sg|��$g�-��tM�
��n�N�f
���[o�>F(�
��vOCbt�c����*
K������U/��S��q�Qa
7�@k9f>��L�����+�%5�a�����Umt���a���a�3���Z�o��~"k������/J��������b,~e��A�j��I�f�lW�����U���������|\�o2�L�K��8��u��tZ+��}�@W E���)7[��jw�8����m�_,�a�������nv�t��l9����$8�]v����Hhh�	�+�V	N�k�x#w�*����L����O]`��G��x'���U�0U��y���o����Xb
�6+�zV97�������Y;��y�\nN�F��zU���&t������z�����Q�qP���z�����X���W@IDAT������O���6*����f�����ng��V�JE��?������@��U�k����U}��PW�P)]i��`A�e�����OF��J+�R����}*q7xUW�ar(�t��Y7���W+j�b{�X[�T���d5��M����K��-�7j�Q95�]�&k�r@?���8��v���n ����H0_P��d�k���V��z&9<r�hF����c�p�J/����Xm]K���s����4������l!��ns����G�CNBs�fk�2�%cDm7���E�"�����{��J�1o��^s&���
�nC�*��\;t&d�Zy�m�9�]�X�������Z�@f��lW���3Kd�#����t-�����c
=(V-F�e�G�C�������V
����h����F5����;���
��f��*����n�.k7��(�j=q�g���K�H]
b��U7{} �\�H�j��
�bj!�J�lS��]����.
�C:+�Yl38���Z�w��M;�4��q~�V��5���h��L�����#i���+��L���M�&?���������@�l�Z^Zb���K�4M"Ht%"�����S�x)���N�.Y�r��j_�exV����)CI��t�>e�OH�n��|GM��/�B�k�z)C-�<�/�����A���^�� �K>�2�7Q�4��H���Dv���g���W.���pW>+��zY�i;�w��K�@I��xv��'��z�)e��]� ��]�{�n�h����^�.}�%-��������zI����v0!��G�M���t�?F�g`�|��j��h<P��4�$F�YS$���n���,/�1ea����Q^8��.y;��g�%�%^[���#��gq��D8�-�;�RF���^]���7\6B�.��9�"4��O��o�2-e�4{<K�{4�
���������+���'#8H��Y�Q�o����S�
:�a���KG���A�6,��[���v��<����=�����Qb���D��|^�S�g.�9<#�v��;6����m@�h'����Cy�X���%o��������y�Yi�B�.?������dK,Y��A��g.���"���Y�3��"�/`�����y( �6i��@��%���4�����e�P�E.`�3��R7��������<|R�����>+�����*�0���>I����kk;���S~zi�$�
���.�m����=�<��<����'MA�/~��'�����y�eS�,�����K�)��G�Dzu��LK~o����\���d�T8�"*�����i�g��3�Q]YH3���1�R�E����g�BF�mM�z�\���}V�:B�Bu�I��.���@���A`��,e�Se��%������^].?�5�����h����E��`����by��l?�m�r	��]���+0���[�
��l��6>b^�1R��k�b��91��^�WQ��"_,nsFa��n�D���O���/�Kg x`T�������V��>�p�o��z�n�����@�N�t1�+x��4R���.����^�+����%��	l
tKD�?��"<
�7�3�!)�\���~��/"0��e!�X�)��p���XG%h�^W��������d��+F�[����H����������B^q�sCAS�����R��t>�n����>oVI�E��!:=�y�������������8B��������aCd��Bp��b���z.��m������kv���R0�LMMM��;�?�S�����������������������=z���x���������������������C"��1v����g��rkkk�g����X(8�R�%�����y�������E��$�q��gP�|zii	&��(Lr����&����>����p����t>�G�][6��YgW���R��y�����FP�A�w�C�=��i4ub������s������!�bP_���FdAw|qskk�G��d�"�!��<<���aio(�h���&�*C��Oi	����`�E`Q(�4�cQ��4�)b����d����<q���0)EC;p�%���:��.��F���G�������� McA4
�
���tq�Ek��j����7����4��0x����������W#%Q��B�l��:7�0���@�X�KcxB���$Z������\��0���M#��d�~@��^�4���>���9&�t��N�C��R�)��Qq�7�E<RE��0"�z`���|p.{c)we�����!��;�'�+4:jx&��y�i���Nvw��K ;]"���{K8��s���Vh$w���]�\�y��u����1n�B`e$�I��U�r�*�Qr�KOB�F��g��m����<����"�L�O�R�$`HS�f�$�>�ga�G��w�VP�<��4���A/�,�9�E���;;'�S����U� 8�/��D����[���]�
��������������aC���Js�19�9�9D�.��_,a��*}zO�����0�!��i�F"Z�������Q�#��c��)��q��+�A�E�a�"����H�����Q�����)=�vh0I��OF#!hG���D��H���{b;79
b9(����_��i���������_Z�LS�'�sC#�tL��������E��y��!
B5�q�@c���_�6|���zc���<j���tkX&M����������Ut�����d�@2Q
��|@&�0s�w��	��^�19V8�2^��#�;D�'�Q%���(s2g8�40�m\2����C;w��A\�P�)o�v�����F#��9����i��k�&z(,
�"��~(�KM�v��Er�%O�EK��.��������F������t�$0#z:2p2<��<��?�o���O?n����s���A�����������N���1����8FA\0��O{�t������(m/���?��91s�=����	��b�F��A"�����gQJ<�_��m�=��1�|" ��E ]0�"z$�f���#'P;��X��-��]�0�c����EKA#���15E�h�b�I
V�yrr&qY�3`W$��B#����ISd�A��&"���0��v�^0'8���g�F���[�ub������P�':���/Z��3g03���(�BA@�8'M;�����g8gb�_T@M���?R#mA�Q�I�~��<w�����09:�:��-���8�;H�O��9�u%|0g�a��� �D��������1�I
aiY'�7�����^h�4�����������#����,����zi$f0,e`at�������cL�
������=Z|�	�������(�	|J�I=FF=��v�8\�
{���0���������[J�R&@��h���9���X%���1�21�� �l<�$�^�����tO�3=����I#����$�'����+��$�����]0�������i,f��k#!�L�N����%u�9�@��h���0�$�.�� :BRd�a2�{2���M�$���8�r��h��q�K_�-�e�EAX&-���v!�d	�10Z
�8��9��� &��g �?��A
�)���@a��7�-`%��#7�
��.�Ap����+���"`&q��)x�o��2��*��yr����0&G�`�a@!Ah�������������KO�������D��c	��.�/J�yzc,���K����9�>d��~���gF���"��op��m�/����(�wH��h>=���~F3�g�L` ��c���/�K.�}�������h
���8>!?i0I�� ���h���"���D�.�����.6��#��rh���h��_C:�	qw�����"u~�3�c?0���v.M��%?I�,��0L����� |�l	E�&�&��/RH����������0��`QH$�'��4�BZ
B�q!)w�K�xa<�GrN��Ud��AL^��f(E��D;��J|;���G�qP� ����4B �D�+<3�cB��8�w��#����>����2!�4��fot�h-�	�	)��<�!�� KZ���d6xC
d��Hcl���1���F�s��#�&'�:i��ml	Yp�H�D���8��C���@�������&���AV��������3*�AqK�@�,I�!����7|}�"/8�[)i���9d" R�����m"��`N�X�A��$X�
!g(C.� �AA��e� ��1_�d�7�Db������]iG!2">�(��1�}P�p�E�-�@Y0��!
�5���#i�db?�+�E��.���NLq�������5�kc�<���08��q������3C
D��fn�e
����42Q"�A	�qq�o�tUHD�����!#�@�?�8$���B.���K�x3[���#��'F�(���#�4�"� ��r�o��C�A;�G���}T�h� �!�g���4��`�8X���7)h�R#�"���F�������� �tz2}�9VJ����Ic].��\��e|����8�o'�sdF0���#��2L}�9����B�	S�i�9�#)iFUz�AL�3����=�.(IC�e�����[;��h&=��II�0�D>�2�H JD"�=�=��0,b?0���#�M�-�����J�$F���w41�z���E�3�si�����%t��%��H�E�4r�����#'�p.�8����%MBF7�������#$�"`^2�c�8GFd�#P#9�.�G������4�9�Hq�����v�<!58����4m)d�!��4)�������%��d�'JA:.d�pq����a���.~"G���#�&�~�d�I��!�%���q��2p��`&����4}W��H�{aB�����hy8Zj�L���v�.���i�>�#i���=q�N6��)
���Bz��z"@��a�
$�d"
���>�#)�#�dn{���pye,�F�>B<��LJq��]u�1sWit���y@d�C*��xi���9�����=������������xf�=�=<<<<<<<<N^�t����C�C�C�C�C�C�C�C�!�9��h������&DD�a<)<<<<<<<<<�����n��lrZ�S��#�!�!�!�!�!�!�!�!�!p:�{&��9wF8$}:������������xzh�8(��~�����Q���������x�M�O����������������������������C�C�C�C�C�C�C�C�I0�������P�����������8�h����
����S/�'�������������������� �1v�F�3�q��@ �$�����=�ZU �<���B�Sx��P>����j��C����������8Rp�[��p����#�A�T�\�{�	���H
�G�
��9�� �x0Ru�@'�g[���u��;�qj�t�R
�S���;�)(���gFG��������!�!�!�!�!�!�!�!p��:K���@w�N�f$������h��?��Y��|��c�<��F�:��bj0���0����m�2��q�|��}hMS���m���!�!�!�!�!�!�!�48f�d���,��8���8\�0�y�[�����/@�C
pK�;�����/�C�C�C�C�C�C�C�C�H80tz$�="��}h����Q��?/<��D��\6�Y��cD��v66���������������xx�q�-����*���o><�^�R���_[�{����'�X������6X��]�#��h�_L���Vn�n�9��'��$<y�J������O�GF��,,4)�F�__�y�������}�?<�O$��}�\�t�����T>��i�Z�w��U����l"�e���zww!�>Bv(~�;�XL���EF������$���u�V-�}�A�J��v&��)tq�R��Wb�������f��_=����p�~zxxxxxx�#��M��������m�t��y�g~f��?�?����!����;��/�����������:���_����F��7o6[��yB����;w���|������_����x�����|9��������	?����]�g�}�+��~������\������R�?����/�%f&��M^�3��
��|���qG�_��%N����?�?��c/�Z^n���?�Q��O�{x������h|Y���o������X���)~�s���2?�����+S�r��_������U����7S���w6�q����WK��K�.��7V��R��O��v���z2i|��g8�����1�Ig2�7SS��%��;���h�w���������v������?�����dO|�@@C�����F��~k����oVP�o���D��������������O�����=�%<<<<<<<<�E`��cc���B<3�u����Y�!VbD�8���w��������?������&x�h]����g>��f3�'?����e����Y�X4e�Y�����g>������i��Ok�-��Cb���KG��t���?���_��X���p��b���Z�8CC>���57W_]m����{]�[,y����8���o��N�L��;�������p�py��H�l�I��&��/~��[oU���_����j����qY8P��&�x#���U�z�z�Z�����Z'�nC�����Q���`6+��|Y��%9<�K~�Y�9pMw���n�]p�����%e�=���e��e��K�|�p�E~(�}��)V���e��<�_�O��&���QP���?�SC�B�����5z�sJ^�C�C�C�C�C�C�C`�s��/��OaOL,�E�EVk��~�k�����|��{����_;��?�b_���p��@�r��R�E?�S����L��d�w����Wg�]Ih� ��_��7�����^�a����y�@Y�;��p��z�=`�O��pO��7���X�}�������\n���wl�K�	B�~��~��o����x�w�i�R/�������e
4����O��Y�����^�C�C�C�C�C�C�C�C`/�{K���!I �����_������5�5��=�;���jm��/���
����6��������w+��#��/�����Y���&�zB����me�!�A�]��� '�G���%��uH�]��z��w/px��=H�]l�?����+��N��|�K�LoX$����W�j�w7�����~�7���:z�<��x3��O�����W�����
V������5V�_�Z�O�i�_��D�D�w�����������#��j�H$��2s����G�yz:�����x
��s�B��X�\,Z�A	<�9��9++M�����;wD�����Q^h�L�;������D�q./�}�^D���D�s`�<�z���wy�R��������h��/8n1�+L0��i�e����mnv�q
'���2��@:6&�6��:�b�G��Z��4K����cw�L��!�
u��,�aE����x9*l�.��>��������'t�����!<3
zyxxxxxx|H�9�O���	���6t�M���r8��Jemmm}}��l������F�Z��!���������1l��>qa�^�v�"�~��n��`r���H���&B�qX��8�V�t�C'�XV,OMo�h4P����C�F#:��8w��95}5f�sxj���C��W�j��a4K����i,�m��v``��lZ.#>����p��?`�3e����f��{�@�Pv�;�)��K�}dA�Ar��w�<T���=N��k���1?�
X����{��"������?j:J-g/��TR�:j�8c�b1$:r��B� ��160d��� �4*E/�iR�A(�����)U�,;��*#��� �j-��8f�Hzj������@�4��U�C�����������\2����8=��_QV~.��c/X��Y����)&��	�8��9����>y|���z%?����S���� |��`�p�����/��_����"�TJ[�QulX�����C�C�C�C����e��P��_��]������rt�ad�YN� �L����R��|�0��&:�~(�����n0�a��lVc�p�U%�J!��ZV��o4D���W*�]�������x<j��F�����o���������+��+�u}>�T��b�������k���@�08����[o�V+G"�j���4I�|���<n�k�o�A>XL&��"��\����~,��.td��f�8��td��V��t �+��`�w(���L�m�������C'�_�������l!�j��{������V�&�9_���s�������S����\{�c��=~�V���v�z>/d�Xv�`���G�W~o>e�}���\��+u
�W/��m�*�P ��<w�!dE]2~z���6[���?��4�v�-����6���h0�5���x����	�@:`+��"l�!��"`��AY�����$K8jW>w)�+X�=��	���?$zr��yP>��x,�DM$��74����i�S��=|?�J�lZ]�rz���Q��a�*z���y�|(�����^��"�����d$1�����H:B�L&�b����/���d��^�������#������<����O���|X���������a{�B�h�Q+���p����T�-��W�+���O�O��o���T�]������{��wP>D`���[����soyn���������\�<��L����O���9$���4��~@�Ky�q���+d>���g�O,�8�����|�t�����<�����t�;��'M�(rD�.:�c>��w?�,���z�����y%�����v4������5��|���|��ruu����:����$}�^�}z�T��=T/l����r����|z�<��o;��;���u!�C�)��������&�j��o�>�&����9������K��EG����AE�����Q���������~R�~����?t���@���?9��'��8H1%{�-���u�4�O����?��������jmX.�$T��i�q�K}I����H��"�l���tgI�����C�#������Y�.~2����]��|�g~b9R��������Q�rT��=tNNyi�{�y�|��n	r���7<i�{�?I>z��d��y�l/=�{��0�{����	�.���c�$C@@BZ�������FB[[[.�����F�s4��l�V���^v�X��b~�%�����*�Nq�V\q����l�������D���m����Ohg���:[w�oL���Z����*�������~��2�|����0��e��9���Q�R��!�����<]FN!c�5���~iP=�$��N;�,`hH�n�������a%4����Q';�7x�����"��g\���c�BA�C;t�����$�������$��v>�����W$�/��<{�?���}�� ��i"
z�U?���p�h���(��}���l��*
{�>�[0�=�bV`:&��������+��������'Zw
�4�e�6�#��w��e;]� t_��?��4�bK��x��������T���4H�X
�z�Z���3����':M���j$����:�h� ��������V#�Z*8KL/��4�h��e�������tr�A��#�a������h��
�r����za�]�������#�����{�)���j��e<�U<K����gY�3��t$P�6���NK���	�-C%����c������U�[�]������{�`+��=�i]Q�	���[*�k���q���>�Vje{������^��Yr���c2!1�@��4U7�l��
�g�O���s�����p��k]��SB�H(�q/i;u�	�lKq\S���6V�����G���q��N(�_����aZ������tJy{)�h��;��.�������rP��`����A�/*���%E?����r������tz8�'�.���g���g�z?��D��Q��������aW�#��b�#�y��
������Y^}����y��h>Gx�1
������C&v|Hr�Q��2����9=F�������e�O�.�L����xP���PBQ��KA%�HqASi��c�(�T~I�^]�������>a$���y3LV�-�`���kx�
�UG��E��r��;�Xs[�-b����������q�{k�b�]���b�bV�L��)�����h�$
�����z��r�of���Z�+�����W9f������Xq�i9b3��;����|{�-��l(���wD���/�b�f]1��?l��b�Io�������?u"���ryK���Z����q'R{�>�!���9���)=�|{[j)����wk���&dKop�b����������g���F�����?c
��'���<�8�rj�����������/y$��w�i�+���
iI�y��M��b�x��D��{������^�B�[�C@]�������:w�6�;��u8.�R;a5���]4]Th�����M��d|~R{�l���O���kxi�j�o�wQ:��8����F%hG��#��p��_��bHM~n9��!��b������[���������~x�_�q2)�
������=��������2��S
�	S�}	�(�����q�^�%��I���z<�}�J��'o�M�Jx���G�
]5X�s��/Pr�$���g�C_���1�D�]���d�����jo1�/�+�;�;��Qq�y�G�.�	>y���k�8ON��(� ]�q1p���6�;�h!=Zj8;[����0M�K����|������x!��u�:5��j�����W�?�/��9�8�$X��_��4�X��=����h8������:R����>�Tg����4d9R��
e���XZ�ng���V�#�@�i��� I���tv;�����)"�8��q%6�_VG�A������R�CY����R�G��8��{]���+R�m><����3 "����7�-���*���*��J<��u����I��=4(e��?!H�n]):��j7�m��i
�d�\R"�p�k�����u&a���c�}��Q�����H@GuT��Z��F���X��o��L&=��-;h��9H�jB���
�%d�l�Ex~��	��t�y����t�=�g�4�5�}���|eDb�}�^�pO<�^x�O����H�0���1���G�
�
N�8��5�f>�^�8O�8��c�s�4��8x���'��>!�������'�s�?5]������ =��SD���jxE,?�������E�J���s��.W�u���2\u6���6%�V�s���5������.�1>Y#+Rr�L��E�3��=3�� Z�+g|��u���@�0C(�+�[���O$� J��X��.�*�/�+am�C`��z�>��s4w����jH��;���9N��/#���-[��6�QN�����\N�U���-���9 ���J3�N����������
����2�h������L6�u�2��J��R����ku�4�o
��_��K��&��0+����`N,M����i��>�V�q]@��&"�������n=�������U+�V�Y�����o�W������2�+�$+g-�������F'p�������}]��R��g��gR�/��N�D��$`2��1����8���Hzh���9z���
�
���D���a������@�����������(����?��	f0��v�hL�)P��<M;9��4��f��u���?�F�.>�������$������4	�2�2���(9�M���wvy�T�8N6#}D�������f��/��,�PYV!����5�xB���CT#��g���z�:uGo���2�?����m���;��{�b�5�=D��?"��eqkD�'n�]|"��*��D��N[s|�Q�n=>�C@���NE��Wu4�[*��{������O�����:������K�.����� �O	��:�L�c�e�����8�pe�]qF�~.
�i�(�j����l��
�zA��P��u��g&M�����T�

�9�|�mg�}�L�����:a(APb�~�.�b>�e�H��A5.�%
9�y��������UQjvv�~�]� �m�G���u��f����t��EW�G;� N?f�_�zN����}�RS���`��������CJ���QmH������fD���r��i��)�#��/�"�4��]1���sw� ���|���L8g��M�O����5T�o�jx�?��S���I�p=�j�V�|E��7�xZ��9]�����3��)V��G�~o\�'��<��G]�}��9)f��iZ>D����"���@�2��8w������o�-�.3B3��Wz�_��;�N����y7z�Qm�9�����rq��708�Yk�Q�5���>'���sM`���\����|���b,/���&�1C���N�QH���6K/���K���\������G#,+�#�� ��
��b8�H������y��]�0f1X����3��k;"Z�����W����,v���Im���<KT�Z���C���,=j�8�"2~��0��,h�
�s����#�nRI�	��������j�rp�b����I0{��Rv6�_L�$��	��g���������#�?�P��;����Gz	�R"m�a*T�J!��W@&�\<������T8��91�B��������(L���q���������`�!�."Lf���^>���
��B/��DU��=d��|X�����{�+����w��+MN�����>��7�)��1��0���L���l�>5B�u�������]�?�9L����0���/���>J��Wg�U%���������M?5����g�h�Xv�d������Dd95�i��4���;�h]�34�
��d��3����	xC�

�w������E� �d1�����;z����tXJ��l(�S���T�W������o�c�(�CF1>BlRD�xQ�Qe*��9��-�+�����pq�X,���'�����F�F�~�c[$�`Vm��;yk�u�z[��u�`�k�'��zO�%��1�+�k_t��&��h��$f�{I
# @��U��)/���v�N&��4�p���b��.��qm�B��/dtw�	�
�P�������W8XN��G�����)I���{f!��]�+�
���K��@������R��v/^	��G�Z%��|D�����������1��>L:I��/���4�Jd2��H|KZ� ��$�Y9�Ae1u��P7]Xx��F��
�~����._��kkw��s��M������J�San�3c�B��|��`-�{�h1Z��:f@����J���h��w�����%��ao�!>s������w����w`R�f'k�� ��q��!-�A����d����;X��Y��Gd��hJ�����D7����'!x��� N�v���'����i:3;Mg��\��G���:�]�>�����s��:I0��|Z.v�p�+
c'����BZ���6�S���s���s�����U	��g�D�,SR�*������u>o�p��r��d	N`�����D;v�����?c���d�i\�p�f,�XA�*�r�zU���C���� l������6�
g��#�x]�e%1���{�,z���;.K�N�&6-<k^��]_����	��7`��uL��3���b���s3gY�S8�L'�*�Ry���o�jvzX��F$�<���*g4����?!���I+X�� ?�Q����e\w��(L�Dl�}��*���]f/�qs��D�l�~�AkM;�!1E!�	\r�9"���kcA5�����[��",�7X��5}������=w4�%C@
v�>K�"���d�w��oB�b!/v������}>�>��t��1D?��:6�%��������@��2Tm�t-
��W�����2�]FLQ��w.p���})&�Wy��s������b��=
�J�����G.��;���v^�"���g��BqB���v�g��Zv��K#��w	���i"����ON��]�i�  �p�G]1�x�@5�GI�1���4��S�dd�L��({|�2�NS/F��s��3�=�d��������{��z�#)R�4��]�O�A5�g������+
�v��M{��X�[��E�]�����0�o;�m������8p����lVc�aR����Ja���6mYN�V�t��-�~ �'��OxRfJz{Y�#~�1`&"`�����r�gn.�1���^Z�wX������g�$�)��%�"z����zp%��]�iwV�W���_ca�IJ:�|����w��H�]7�)��@(��
�j���k��������A�9:K7p�T�n���S��1A�U�/�EI6n+1|��R6������@@��,^w4m�g������Ano,����XM���0�n�dI��}����!RW��{:������.��znI&��9��r1�s�<Q;�Ez�S)��e��
v����mZtn�&�5�D�K����T���������=56������MP���I/v|�AH;m_g����J��56��$��/���	���������0�����U�da����$�$��?
nP�u�������:���Rt�����q��;���&dK@�4�8�;zo�<99�9���<�N\����q������Rb�*�����b��=;�c9�����K�E �F�
G����T�&&�	��@���$�<��P�v
W&���6�_�:���I�������2C������5��,���Mh���?��]���N��^�?�c�L@�=KH�n�O]����rwE5�8��+7R�-H�+�#�@5����'45����vt|18d�	���O8)�0�[!����=���{n�	�{���V���zQ/��3��g�����[{����VO���Z�ZI��}���'"��"3 R0�P�{�F�8q"���8q�7aFT�����0kw���������A<�����}�P;������V\<65m���.�2���E1\-��b�
$J��,u&>�,	�������;���/���3�r�l��j����M]P��$CV��J������_��P�V*�������?�h�1=5=U��P��J��|��{��{���y�{���r��R���NZm[�z�23�h���+B���u�>��U��	q�]���_7�~tk�������	�-PH �d�7jS�)4=B/sK�:��w'����Z�0`z`�	��������wf_��b��kk�t�&�^y��F�h���R�0���S�g�C�����Z�)��?��af�4�J���B���V�e�>������t\��_w����Y��������CF=��i�c��E}(r���9�[n�����(��iFU��8J�������3/C0�F��0y�LK��<���,�������|]�_DxOv�����k�������D�4�pd����X�Lc�4tN&�QW�4�$l��9�>�6��c���,K����)C�
pI�P��(��R���n�*'���	mN��6�HA�l��Z��n4����c ����!T*��/�@+���A��3�FFIN����3��
�A.�b�L!h�Y��EG�W�/���SL�X�CB��C��*����8x��������A
@IDAT���lr��Q�m|7��
����:�j���jS�"0�mi2�%��N�����[��0����$��d�e���u.]��bJm�,�hH�!2�H)���5f���P��!8��_�PZWg�i�����d��6.��sq����6W=.M'+^l�6$��F���n�v���:���������*����5M�d��jSU�%�_=P5qH���%��T�j|F��=���}�i���p���@�r�������s>	6s�SV}A*�������@�MW��^@�Y
�E���J�j���uL+
{����\�����j�����8O/��-�S�6���EGQWL6��P=���-5k���m��L�C���d����N���7>h��������%@3[}�������i���>x1��z���	j6[_���kv`��k��w���|�20�k�nm����W��i)'��:��*E��^ay��(y:2_d�*/j������$`������h���?��O��u��V���@R=|{��+�)���d����"��*�e���n�UY���,	���
����bB-t��������sa&�5��Y��	�1���?�u��NZ.�J�zSO�
@j��w�O����+�����;0b�[]���\�tk1g�u���Lx�\{��.�1_;�����C�0��nU�n�����7��|~�����"c�M�H�	�
BRo�6�R5�T�i�l�|�e���P�le�i�6�!��%�t2x�3��������1�����?p1����8n
��k����v�4�w���T���E�������LtfOV�N����^��*7�L B�Yz���������H���^_���a�%��3=/32^���V� �WN���8���������3�x�����8�u-�6���?_kV;��1�;��PSdF�X����Yz�e� %n�}���^�A)}��IO/e�����T��f
���F�.��o/�+b���u�C�x4_5����H�������P?o���/�����������R��pS��J��_?d�*h�L�T��\�����A����*�0D7�P�7���+%6�N%�2�DY�|���HPg���oA�C�E�}��A��)�@K~�����g/��z�l�q@�.u�s�������r5hIj��N���eo�����n?��C����[^N��o��v�4�{���y
9�O�Q���:�Q�������eT����Z%�5�����`��f?p6�$���oJoxU4(I�6.	�ap���j�����p"���F�������������������n��o���������	���5�<I��U�N/��Rsxw��;27v�=7ek�q�E9�d(
����jC�����%-]�������JK���LN��uJ���>������7����F8S �(~0o	����bDX������w��z��T��!�b����������.$J,���0��_�����U��>z���1���7P������mYB}.������Q��Px�>�;Y����23��4M�)\_����o��0���v*����
:�U���S����K�m���E�4;�f�j��@���Qs���FLx�`�2I4����y�yg9
$�&H�^e@��}�\y����6���C��{g1�7��^�^�I �b�=y<�o���������z�W����g�:������0�M���i�o����?L�p�k��S6��Ykn�<uK�:� �aYc5&���}X��R��Rl�Uz��1�J/E����@����<JZ�1�[H���?��L�;+x�@��"D�,d�$�54��6���K;J��n�����+JD8j��
?�b����}D�x��<���Ga��2-���4�%�1�(����p!@�W�]�'����`��tfk'<�U�PJ���`TT���qZ�X�Hd����M-5U{�9�4�`�L�;6Wq���Hb���=�_��C.g.]�J��s�KsvLu*/�K�y��1��vU:�"�QDf�'�.'�u&	N�6���}!m�
QxZ�6�>�l������#| &�� ��VFhju��<k���*4��,X���MfH���E�f�M���H�F��?a����6Z$ne�h,g����Y:�=l<��=�"��vw�k�-B�oU��v���
|`C���a�-�3���gO�����R��Y'��>8	�A���g���DO�t��'k�����k��_����7Z!�J���p��>D�:���F)e\�^��\W-(�a"A2z�J��W�F���#��$�,=����a�Sy��K]����]p��=NbrS'/x jd����A��Qp�I�n�4J,��$O*������>M�H��\,�J�$��h�}O�]E�.���'���ED�~e����������\w�������)�����b<8
������O�53U����{�=*z����	����������s�#�8UG]������M�:�Q������m�N������F	�i
���R��[8�|�c�N�
|��U�
LSW[���	tHh�0<mt����3�L1'�q���Q���7�����P�V{�gk�����H+�����{_m=J��h�~< ��r�u������l���2�`��Sm�'������(�~J$+��G�5��S����j��m���{�<#0���w��*�[�;������������* K��Z���e��\}-���U	L��t�����cQ���<q��3�D��c�=g5��er~Egl
'%�!�,�@����[h��0�Xm���hz����Gh��2%_�3����-���GH�����"��;���	�S�R��NT0��p�_&E^2���h5I1L�Ki�!r���&A���k#��$}�Q���a����d,TV�'�Ya�e��n���s�������[t�����G��i��	_D�w5E>�
b}��$1{��=��-�����)�	3�GGj�0��
�bA�,�����7��0���X�I}s/����n�;S_�+�P	IUg���PY�Ma�o�@�F`�������zKN#q�9���{�lx/]������E���;����+J�.����5�o�@��!�6:�R��@a���<�����8`G�	iX�D�����8�#���dr�o�b�y�r\��c�<s{����(�hm��>$!0�\��c�z���������)��[����5�` ����=��D�-c���o�]��3�w `����I��O��0R�n���2�����
a���R7t�ruz9�
H�!N���I[���~�~:�X���/5���3S9�op"q��.p��S�P	�2������d��/��YQ����m2+�_$n�t�!���y���<|��-�L�x��K���4�0��pe����k�6���	&^k�V��i�Oi������+?�{T9F�F<��d�%��$���!��x��(�(�S�T�X��]�=?[{��IQ:)��%+	d�;�X�l%��l����U����$�������z9n��>�7%�Z
�v����z��[Of�}5J��aO�t���������Z�_X����oN�����a�[M�.�y�������f.bt�j_��v6� ]k����{k���8�sc7���W�CgN[3��o\��*�_�{�c�bc���x����� �0<J���������}$�[�	>�����5�(��hx�gH]gw���o4i�?2�J�4
�-#��+����D�Zi]n����d>O��i�=�o���,7!������@�R2��h�x^����N"4�PEIm�7rXf�b�$��*�qF�8��`+��Z�����-����������@���'�WQ(��6�O#��\?{��v�^z�f��1Y���H��C��_
�:�Tp�t�a_���u+����������N��������D�5v���a����)M*t�$S�H���m+UUHs�I����P��XAR�w���7{�f��f+'-;��~������=�)��x@��\g0��^����~�FZ5�>�F�����[`����6�h�:����KrJ_Y�f���&T�+�L&�:R���p@{����R*[��>X����W�:f$�]	S�Q��
K-�{B�~�����R��D�����[��9��T�)3�1-����g����F8~o�������F�[�f&�����$n��%�m!1�[����7�q����}�����
�V�V���x�r������
O�iVS�l9"
���x8K����{*"�~��q��/�9�k#)~u�����zp�)�}��>0���rh�U�������nQ�V���0������~����;#����������B��m#em��Zy����U0�|b<q�d�����c\��R�&d<~��/�+q���g9�>�����)��[��I<j���#�����B��������<��6^�g�
Lj��*nb�����3��"�x�-�;
�"^�+��Vk��PB�Yo�[�jw���=^����B��N��v�q^n��0�\����{��9
��z�Rd��fk�z�C���������x+����jm�����v��k��5q���N�5��vo��J{����gk�i)����E[�������Fo������5/-t��T{���U��X;��T7�?�A*7D�Y���T#���N}P��+����f{
�!`��kr ������{k+�zoz��hye�'����V�����.,��}��7������2�������[�v���h��A��]����������,}�$
�,�]�v;,b8�������,��4M���.��i�W	�\m�<^���}et��������:�
u�G�j��Z��gs���l�u�3yZ� �����v�����WN������-�l�:Z����P�vj����V�V��}���^��d���"[k�M����-���4�#[mN��&�m���x�nk�i�~���v���4{:k�$@'��j���Xj>Yi>�������@��V�������+���\���M'
��2���L������t�,%�QR����T��D�]Uf��]�I��8#�y����4��8m���+Wwk{[u�g��OW�,5c�����6��Zw���}��|H,6S����_�������zkNg_8� ��Ft�^�M�A���D���b,���F���'�piD����r	����>'����M=��Zn=�~�o���7�QH~���Jj#��G���cub�7��+����}z�������c������eI_��`@\��"^�,@�"�#����A���D�;���R�r����h�x�*��#�4��'�/��Xsd��x�E�R�r����4>�M�.2U�p�x�4���#��4��*��D��E�[�BNV���I<�EF�
��������=���R
�;�/��UzpS3d�������xR�s��.n��2�r��v)��0�',����)�v@�;�E�|�'���������UZ�m(Vw�$p�q"P7��mO�p@T���xtB���Xj���4����~�G��d���>�Y"�(�����T���mr��E��v����&E�h�#��-���"����+�qVF,��{�$�2�
>��v�w�/���sz����}��A�����!���|
��sT@���(!�@�q~[��n ��`���m����P��l�Y���kI���7v�H*�T������ W����h���6lHV��Z�������O�Cz��L��:� ��f�j���tja�?a�^������vx�����Q�b��b�b�j�H��L/��'�i���5.����?`$��(����@��Oe"����*�A�/�?����J�t���F@���_|�f��8�=@q����m(G{5��^��E��?)Gf�7:s�����n�I�5{L���e���=3��mV*c��M�����FO�.$�3
�nj8#��g�:u[J45��S?kk@������mU~��y�����h)7��m���R�df�����Hw�SbQ0?�����K�N\�`��&?�u�z��]�+�W&!���B1>"�&���������7��X�>&"
B���O�o�'d5���za|���>_��[�u�9Y�vb������rq��[�c�HV\d����h�2�#�$.�/t�h�0P��rG�K���G���6w�2�"~�^�d6F���T��������"^���]�{|Y�e������x��.���gN���P5��]e������9����<#?��Z�������������df��O�m��F��M;���������G�o/�~���������?)W�d����w7������l��Yy����@���q���~����������Wo�~������<��~�Ryp����+�����=c4�}������;�c�}��������-�����N�^."���k>�,I[��T���E����hx��7l��[���B�z}��k�7�3�8\�<z��	�����J�����5�3��~}����S���E�����?�����S�Nq��Xk�&8<V9��B[�x�\/�>a�������n��6����8/����Y�=:Y}�d�*���h����me��O�����;��)-�Wj�
�m��h�r�d��%�I%O���lg�s�Fa�fGx������uxA��K&���F��x���]�,����|�����?��o�>�yw����^=W��S�*�+�2�8S}�NJ����Z<	��m��u��(�$F����D�TuC��<�~���|�������F2S���������Tu����>\���g��A�}�v�e|f��������Om`��5Mjt�������{����}����_R���R�3����W�}�8a�A�-a���h��T��������x��s����?���8U=�]���Z�s/�������B��~�2�^�������[������H��
���{��S��)�)^�R�����������}P��af�n�hz���E�U���H>2~���?������
x�0�������o����v��`�~��I[������Q�^�:�vB��&�&�����4oa�zU��G����*�W �`�-��z�(�S���q��h�n�8BBH����J���R�����dw��l�v�kv���p�Q�P�������d�����8�c,0������1�z���B���OD���O�ek`8*��Khy����U�����&d�����6`���K�}����gj�e�d���i�!KASfO�]��i��vtX�'��4"C%�(5w\:�8~��1���Hb������x�H�������`�� ����������3�
<��(
W������l9�Hjt�a��L�ui9B�=��(nM3X�2�`�l�b�o�������I����v��<�Q���=��HDK��EY�!AK�$����]J��AFg�@ufX�S�����w�a�IUR�Gz
���mE+����������0���f�;�H-�KL��8��}��y����v����6�9]y�T��C+���������:NKQ�!��b�^��k�����N��Wx�����?���4���ig1�<�*U��g?���y���:�=��}� �:$�[��JB�%9�g��yu���:��h��a�tXe����J;�r���x���HMxe�F����-��gO���>��{j'/�:v��9�[k�a@1���M��1�,(c*����:�a�@�`M������83�9m�~#j�*���V�+�\�mD	�f##P���E��>�+H��s�d|.�:�����u�/"6xn��zT~}���O�1���(��h3�x��?\)G.����v����%�>X<��e�p��p��S�2<��
�����%��fA8��NP�H�q�9�lD�I5�1�$��a��U�\�����c;>F��gkZg��%`���ONTuo��W��"��G@���k�a|t0�����S�]���x/�7���������cp�������D�11�a5|k�$�{��$$KP�W�d�w��>��������P�/_H���rc�������s�8�N���o�f6��p:��4��z�F������%!V.jm��3�3�9�f�]�b?�sg#��$��h�L�V�:�^�d��7~�_J���rG���y9_�������vF�Gq���h�������:B��U<�o��b��&�'9���g���X���[��t<aq@���(q0ts�A��f����r�@W=�0@K��4:��27/��C��f��{�d>12��h�eL�[o&���}��UGz��!��vJ+������Oz��y��a�o$�#2"t���Er ��k��9�������&5�����6R#�F�B�&f*�ut�@S6��1���o1���!���v ���il�S&]~�}���u'�%E���1�M|���&|I���4Lv3��RE��>�R^6��g�4�B����3�bI���I���{���7����S>��F(
n��B��1��	�'�W���x����H�&Nb2f��E��x������%;����R��=A��B�(���X��Y�;���nE���- 0 qg�*���v�gq��X�Vq������a	[��e�v�Z��:[��uP.]_����>\F��4��7~��G�C��S�V����_�����4>�G�\8Du���r��T��O��	�0�
i���9���	��sm�/���4c����f��/f��Y�������Rq����s�
��j������V�G�
;:�b������9����������L�R�VOR��I
�lT�����-�w~a����kE�l\[�5m�po����Q}���@W���tkm������4v�s}���t��bgd���F�)����Zp����(�������M]#�y��_�d�F.h�U*�ji��J����'��)����EF����LjX�B����r�V��A�S�s�*_�����m$��@�:�a�����w�~�9)}�������cu����J5�65C0��cib\7xY�,�9?c��m=o��Xu��:�������p�\���������}������/fkQh<�0�M����P?���������s,I
�}Qn��.��'��e�C(���P�7~�H��Bv�@�+;'b�dh{4��T'/
mp�F��>Im�9q�M��"L��r�&��1�d��5����Fh��-����Q�#TP`az�J��'�5}{�������NO���&�0�7��E�m/���s��N{	;ra�r�L��m�N~���d���@�+��+���H^��5
h�:�(A���=���WC[�E`��V�'Y��P.f&E)=�����r�!�q���k�>n�h���\/o�2���G���@������<�ka�<�>s��}r���\����k�����-������7l����,��������pm�����Mk���a���YGe+�ZB���Lf����l�����N�Wr����p>Y<ea�m.������v��W������1�av��(�*~�B/���Uep��rI^y/%t�>��p+2�o$�:o�@��(����Q�me�v|���l"���-��?�Iz�5������bU�����:e����ZcL�7��-���<�#�1���2_
���cN���|/���C� =[]��8.�
hI�I����gb�}7!����1-�]��B�M��<��`�zmx��H��o�;��l,T�\���}/�
|dUc��Lu��h��Y]o���i�<)�d3���Iqav�6��\+���r.��<N�����k�M���-�-*5�D���E�#n���z}�A�|��
�/���6�t��v���������z�7����O�����;u���X�qs��}���bR�G;���,�P���H6���������<��q��\m�~��B�����P��^s�B���&�0��{~f��������G�g�3��o��I�T��M�"�V�����Wcb1/��#i���(�k�<�;^����3���c4��8�k�P73U;2�!�=T��h|o���u��)s^��&}���:�h�@�o�����p�<��_9�	c95[�JJ�i��I��n��rIOZ��	�:_�d��F��M&d�/i;�;�$��R����aL�
%�3�d>�%��>E �t��7�}>�����!�+��z'�K*C�E{M��<x�<���h�q����I��`���We�Pt�rj}r�q�^�-	�H�n���/��/��`��.=[��0�6Ga=��m��17:Y};�6�kf����X��*�	�oJ��Z��^���^l�]�����
nV�z��5\�]��h����l����c+`[7��A{�P�._��Y�6�����������U�m�x��^JPt��93���K%�S����:��~5D|
�WS��������`dHz_����������:;��\�(k�>}�O9�R�2�i]�?�C+�
Z��*�:���������Z�_7O<�wm'Z��y�����E����
G�&���Nu����-T���������)���)O�<Q�r���D��v�|�I��Y���9X����/�(Q����{��^�Z!��4�z��7a���g�3/����7n��>*�pl��j���PNo��eA�*���l�Z6(���k������__o8oR0
��/N��&N�/����~R�������M��g9
�����+���HB7����z����N��J�D�zuv�Q��f��@�Y��~��C1�t@�w��������x����/��u�i�3W��<�_�}�
N�������S�����g�z�V�8�e������Fo~�~�?�����������$~���
Ms1���_�?�;������{q���u&~���}/��x����+!���_�����V�f_\�n�����Pan�������[~\Ji���b����KP�5��N���
�Y�6M[����]G�
�bK�R���������i�d��������CB����HbZ
g��D��FMF`�N2n��o�m!�:�m�L��9P��� ��	(�����tS<�4����bS�&�;�	;���8��E�i��B}@w�z�����,5��^YV��)��A�[li�WN<v�y�q�c��6E*���W�36�>mOS���0��)9����9����q���,�X=��!Nz�)q�
��/��
Kp2{����o[gMO+����g����y�la��p������j�_[|^�?���p	4�����7W����.|@�gn��5v��06h,��[��B�;c��q��@�{�k������������f�]ft�������$f��C���"b�|��e���Q	V<���5����7�U�[��[���=5����`�35����uS��nuN�N�����'�c�f�+o}��pkc��[�*R������<��&d	h��s�;b�:���E����
�������������M����!h+'c6pl����n��N���`����y�\k��������V��w�"��/�O������=F�����:�!8���neg�x������S����:[g�v��� ���RC����_3����i-�{����q�2^��B{y��P�k�>��v�F|�����)�:�u��m_�m��������i����I����6��u@�mE��Nm~dg|�������_�x_1+�[�'���������L�-���d>QN��k��I(��v�����n�m^��j�O��t'����3�M�vb��"�;���i��
\#oJ@������������h�Q�@��������j-��|�	!�������a��}e����7\��w��B��&_�Vo�

;7{��4�g���1�/|��$���	u���/w^c^j���������n��7K���������:�0J�S_k�~�'���-?_j��x7���J����O/�~�a���|ss������h
�^/`�O�����l����E����?��4^��7~�_}�@JGi�)4��Q	vn��0���qD�F��E�����'j>�7��
�k���p���8�D#�gc����Z���;��U���w������~�'�e����.�Kp���mj�	1J�L0�zt�r�f��[��,�+K+�{��U'��V4���Q��:?�������m�[P�;��s���T����1���3$�_[����=^x���Lot��d>�5�M��<��T���w���������w.�8k��i��`��r��l�r�c�k"�i�@{���{��������*�5T��/�g.8Aj�iea����rQ��u�L�f�5^!�[������"�_j{�%�0��<��������"����_Y�*j�c�<�m�U1���2�������f�>l-{��y��:��n������jS��of��?��q��&������8w�����������&A�����s�y��m�p�In6�����U7��w4Fs��������)���*[~��=��oN>���r�����JMxS��z�y���g�����3_8�����s����n�27XP���������=�v5�j�,m�a�1�@��u_a���c�&Z[���R�T��~���vo��B�t;��g�^&���^���?����7�����g�L����+��GwB�9��J'�g�6�n����������M����zq|�v���:W��/��������n����T���P�	;f��B��;w�O>���Z���'�|�+�#��?�po[��{|��W�?�S�Qr;2����?�����M�6j��O#Ve�Z��Z��������W�~c����'�D�����T����+�n����k����g�[_W���2����^��n�q�3c|;�/���L����zBy�4����6=>V=�,x���M����_�������_oCR���hg�X���������F��L��P�zee��\&%�0��h����C�;xm�g';:I�!(�ao�V�/T:������	K���d��s���Z��.�G�{Z�W��V��:S�v:0�RN!=����\�������Ue�t���������6�e��B��]����x\Y�����<Wy����Cw{�l���di�A�f���;"��Dy$�o;���%���^>n�[M?@�?��e��v�6q���c{��g�q�q��-�����7����W�^��]������_g�O��k?)�O2N�Gf}@������X>���h��n,��g��]��������z�W�$/���@k�~� �B	@{%G1��2�bqC>��}��+i�_�n+�O��Oe��z�
��a�6�q��`"Pb7���7��2���	���V�k�T�	��;Y�����6��������8a�k����R"�=���I��.7�G7hU��>?l��L=N��d��:���g��?��:Wy��
%qu����"�d��V�-����V�����+�gC{�w�����o\����������!�.g��t|�Nteqn���!���'h����pO�pgd�-$V h
y���9��U-��{y��O�^�:�<��a�t(exw���>I���m�smEq�W��x�3�l������o��~�7��E���� �������U&1p�����l]w+?�����i��*|�����^��|��S��NGmY���a EamK����yA�R�t�O�/5wm����Y]���/�A��@W*��W����_T��sh���sLr��8��M�����<R������#��n5��&(����|���np��Vi��[	�$�����.��v�,�n���#D�-j!!�jt ?e�rT�T�Itb#6��jU��d��Mz����%znz��H19��-��Ol�_6���iy&�q����m�9^��h�z����'*�k�N�h�����T}a��nR5���O\�|��=���V|�d�������ao��0�*�Xc:�a"���UE_Hz	������=�?��.���o~�Y����/_�|�����9�+��S�����l�w'�CL
k���#%h��=L4����_y���X[]�9��������y}<��y����>�e�M���d�Z�l�;�Z+���PU���.WTkR�����������>-�~�K�
?�>5�J-��L`�r�r&M���G�!	�A��2�
b����������e0�����am9kv>m=��s��P�m�����83��L3��
���*���R�3ahbB� r����A�a��� M{�x�R�TA*N�U����|
F�@o<���=]���vm�i�iW���z�iQua��C&��hI`�.�b��j�*��������|wa�(���������G�+7�[�9�]����\�N�NV����*�)�'������
��\����nn���}4���������gbo�@��@������f����S���S9���2��w��
_O�������=UI)G�=���I�i�<kzM��%[V<���j��.I�(y�;���z����=?�[��	�Q��J��q���U�4@���g�����o��%��e��H@
80�`������LK����p��{�vYl���$i�'�
��`A�;El�;.�-��b�`���wf���A&�@v�D������T��+��_nt3_6��$(k
�o�"Qx�KL��(8��nS*��u�f��af�Xev!&f9��7)���/R��^����1��@9����:���:hql�N�x���������_`���O����|��s���9R��T4����<U����;��d�q*�j1��o$[t�~�������/:�lzN%i���+���e��NBt�J4�I��0��S�����p�{z�;�V�=�|��|
��V�J��T����=I��2�������6���3�5[����*�g
OO|���K�.QB(��w���i�w����������Su�eM\^m�TG8J6�:�^��{b����^���c�q�nG��|eyl<�r�9���0@��Tc����
�X��t!�	�+����P���Y?{�_bPk@�7EH(��@����f?��T!��!�����j4��#*�u�V�1���2?�<��^0'��-j-�Mr�JAN\���6J���,Rnz:��|
6!�`Os����2F�L��g�N��N&��f��?�V��Z���(�@���H5vI�7 ��)����V��X'	�����HBO��x������aBx���{S'f>����+%��/��*��,O�;��&�Rd�NZ��&0�
#��������fz�����5��d7(�,f��a=[�[Lh��h�4����_��`���__-=Mu��V�Z�v]��
������i�Ft���#�d���jr'h�l�����G?�x�������U�E�k!oV�����O-r_�U<D�����&�����"#�B�x������l���mW�?=����6r���r@S�E��]��\<�C�yB�I���OuD�?�j��T�pA&�����r|$H��9)�����w�����J�2@B)�T��x�C�#��X�>���B����������w�l4�s��|�~e������fw%�
:�M�NY�����z�8�����r>�wj�Woto����R�s�����rY����<%�U��P3��q	��m���.��������������{�� ~(^���'�j�v��[�u�����s�QR.n}��iw�S�;7z�}�s�������_$6���v�V�.].W't�������i%��1�d:��
�g�5"����(/f)�������������	GW���������e��w�]s:��%��x	�W��!�rz�����v`���s��s�z�Zu�MI�������OYr�����:�����UD�z
�+��8���Qi/*��t�JF�Rs\J
�S��u�,ob^X�^��E~e���WE�|!�w��k��~������i�'�t�_{��|��s��vs��_I�&`:N�t�p��V��>����n�V�or��|�w��M�s��y$EsWtBI>
*���������$`f{~�h"e��%���*���U�h��?/)���d�V���z����v@IDAT�e��{��/�H;��_�l�
@[�W��0@��Zh����<��r+^L�wMX6��5M������/�J�d���J���>��_�r�V�woz4����c����^|���x�K^�Q���`"��x���#}�����}���-���x��3_�[�c���H�����'O=A7�Z2���0>����������w�*�K���,-=�u������~"?�������������kk�����O:�q�k�:�������F$�l��vf��+����n-��L��nw��R��o�/.���v:\ju���VBS��m[��>�>o7��������W�R�~"}n�����kK�v��v;�Q��V�d`i��zm�__�tTs|���F�u�����OM����H��iozv��Xt������j�[_YJ#����r��]���������n�4��F�b��r����l�^�^b	�k���e��w����T\���YY�E�����p�or���F����?����"~m����f�|��=kK����~mj���W��Te:����o~E>�|?>s|������A��8�O�-�4������z��=�b��nU�k�h�][����nr�s����:��^������|N��L�$?\���t����:��e>3��o}�Y�n��2*w��Y�sL�[}�0����-�-{�����N��j���*��w:+S����v�����T���R�L�&PM{��v�-^so�O��v���bPRUw���K�^F�^[Y��mX�V[����kQZ�����n�����zgfN�[�c���,��(N+�+y���o4�O���n�����=Z�{�M���Rc�
,Q�=�����D���������n��9��6�|��k��c����ATS}#Y���/r�'����0��������d^�/����N�R�����n��51����Bu�9��g��,O�����o����k�yx�S��0���oO�>k<���G0�������$��j��"O�<�d����I��9^]�`����g6������n�����bzy�CUeL[�d�l�o�D�vo��#2N���������">�7������/���N~���F��!<����x���������#��*~^�\�}������)��u�<{�/�|w�77W���D})�������������j���9kL�y��0hW)�!��p����Ok��E����_V/��{����+����������
y�,������2����o�����:���WK���'�v���:;����E|����o���������l�3(����?����*����\_�~�{���O��27x�K�K����OA��a����{�n����g}��������n��������}�o���{�����T������v����s��}�	�Uh� ��{����������+��W�V�_�6���0��	��o��z���[� ��y�\�a��~e�i�_|'���K�����wt�\_�fp�t�����
�_�^z;�`���v������>6TA���[_���_y�{����B��{�d��\��R�'"W>��s�Fl}�p5���7�@�w��������
�����^:���sv��F���!]��<��:���]x?$�a�(�����u<wYG������!@����9����������w������E��j��w�XNa����,5m��Ps�9�Zm��x�rw�rj�z�A�Kd�V9}�g��
��
!P�+�1R�w������O����Wgfz�/�ff���/�n�����cMV��
l]k�������>/.����S�M����G��,��?IAP�������?���OV����/Y��V��.��?q����������v-��J_������v����X�����gO���Eez�[�������9)���i���`�rm�����[<�;�������;I�"���������Tn�#��������Z�h��|'^gS�<�f6vX.Vs�I��E?)��D�;nG�CN/�����O��&y,.R���s�����:E|f�HP�o�~�����n�,_Fn�F�}%��t��(�u�gD�����g���zA1���i5�m!��^N�v�O��i���+��kVfX�|����S��[�O���N��`��]_y��$OI������J���*�R]Hq�0R�;��t��ir�/B�7����� �J���*�qF|�Ye.�X�f�d�bWb���	��8������<}���'�T&�5H�dz����c������PW\����R}_>s5���_p'�-�Pe��=B�������Uh�Vs���������C8Q�"��7�4��@$�Y��)�������H���r�����+���8�9m��t"�<y8E�k���*s����o��
��fP�!��|��YdBiq����TJ�KT�jk#�t��GS���\��?��r)E�x��H�9��aP\�+������������x�
�����������y
���Agv�,WL�������S�F���� &��|mcZ1��Q� �<�m&�k��[�^�>&����>������G'N����������'�c.���D�yC\�hn;){�S���,o=��v��W��������nL���(������j����S[���9�����F�+K�/_����>���������
#�eA&?/Y.�Y����.Yyb������z�&O����+.���:��"r�b0��?8�X������J<�� NJ}�Z�!/:�!�{�Y6���U5��ib
�y�V~�&���4��ftoP�j�s�
0��'����4�@o<�Y��b��-�8r�Ip�3�L`h�tX�>��7�?�O)R`����SY�!�m�[��Sd������P�H�1%	����.{�p]��)������K���~��`<��hz��m���D�*�Gh��A�:��f��`dY`D��Sy�_p���@z*HU|��������5'����(M���6�:�����"�#�?��/@61(��H��m�L�:&<)q]+CCr�M�	�5�F��u�A���� ��"O�=���]�H�������o��gifx������W�g7���p�:�m})�����)����,-?������K��E�Kx�~���g`ZO��K��8u���4�hv���_��]����4M����x��R�i�?�5VY���]Aoj�[�����?���0D���F�:|�o�w���?n�V������:G"0u��/���@�t3F)��G�.�
���0%b"���a
|We����o�@�����w)�*"�F�D�E���[0����r��	���J���������`���k��e(jj6��1<��Q�����0�0W5���Be�9
wD"�E�u�>�oi�eC������Ie�q��
 �[��.����L�;R���3S_�:x��H1�������`BPT�T���{�5�O���F�"F���BZ�<B#p�r-hU�NJ�*@p����u.�cq�U�s���>�/L��$D�)k�0��	`�@�)�(���3���*"�
T}�n�����������V���w�o�G�(�Nw*gw��#<`T��bK�m=����?FC��d��Jl��P~3�^�8��=
c�Y�UY5�d��C�u-r��C<R�CU��0zK7z������M�h�w�����g���>� V�
s��<iGg���R�����n����d�@%�DH.V�|>������Nj��c�~���WO�Wx����O�����~�O�^=��gK_�W���r�?~�_����7�a���|�i3��4-#e���T��g�����\#�4�J
�9�w�BR�A$9HO������� E� �� +��?:�\(o��xZ+g��FqY�ZaH���%
4U�]f�c������������7���D�K55�c�"u^�KW�v9�v������d�������cg�OQ��|��������*Z<a�������,��(EY�K�X�Y�).��?�wf�A���^��3��g4� �����~%U����������o�G�Yx���:����Y��B��l�x����E�-B������	p^K`Y�I-��!��o�g�Q�e#}�������"drV(�9��5p��3�H>��,���d������B�(��%��A�"��@�X��r�sl3A�FOU��h&)*������^���+���x-%����Y?���#��1T�R�������o�
�f��$^������������7�wX��m����m?)���Fu�B��B�����[�
��k��&�'�+��+�nF�n<}��z	n�P�4(�D�/�U3��zd�����Y�Q���
��P����'�c���9hg�b�*��A��������R ����4$q�����A]|X[F��Y�d��p�/+8C�;8���,L����o�����q�@]I�8<���]�D�o4���h�
�@	����/�7����r�S^B������ �$P���6�[��2�������:��fb5i��^�Y<�Z^zx�[H��j�L,��h���T���&@B<�J��2v"�A*��m�
i��7�i��M���5��6�H�������]���]j��$�2y�E��+r��4i&���
tQ=��in���������1l�aF�:�p�n�	R��'��F�
�m��bPL�]�G�!Fj����r�6�T/�	���k�V\�����N�
�{�0G�k��_����zZ�!(�}��<�Y��O���Z����Cw4�B�{��p���hP��&��Q�L�!�v�
X�g�B��vih����6�L�l�I�
�FR�92�����W��vZ&��[M����N��t,&�v��%*-�9J�NYv*u�B<��� ,6��cH5��@Y�
�0V����f���_M0�r_`�V0�C	���Fh�-[��1��:>2���h��CLy
�%�X!�Fd���!���< �]����V��->�)A�?��	Gl����/�� �Z��Oobc�u��I����5�I��|��Ds�J�}���n���h4�p�gSi���8��_�05ln}����������x`�%���j4(#�#'�y��@a��w��0/'����L��(�F��Wq�������2�T#���~&�	3���>���t�~���/�B��\������4t��p�A�D��L���
R.�������!y��N���Wv"��y��A�����J%��6����8M!w�`,�\J�w��
����q{*v_y^��m��7�����-�.�p�y��fiw�6���Z
�<�[9w���g�����`$�WN_����r����
*'�8{�����i�@���>�zf�=���3�h�aq��
�|�L�f
��&������#m�q?�9�2�
��G�zP]��~]���|0�-��|iz���l�_
4��#��4���#_}w���Q���@�g��V�H��P��H01)"6�f�
P5'�����R���3�5���L��G�&���B
��0I����l��?[Pb���4�aZ�5A`�����}aP��F�#0G �2K�<����n���������pg*�&�eu2f)$�S�������d�;x��Qq3�P��@'+���)��*�C�l��4n�#u�7B���gN�������v�M-Kz����cL�r�����9^����"��c���W\9��J=h
A3N��<���)�N��d�v�V�
�3�
�u���S�b�=[9e�c:���@
���%-���$M#E,Fu�������G?I�y��u������X�����7z�����������(������rz��K$\����-�Gq�	�[�E���.�xK���ry]�}����5�,c��,�3�=��K�S����pf��n��D�{���7�ZS�)���\���5#���(�@IR��GfO����[��J�e��f\n������4|��K���eZ�u��:�rd��Ezd�U����a�4�[r0Y�{R)!�"�LF�!r���^�pl�?v2e�1���R��\Z�I
�H<��Q��q�R���Q+&'���Ng���plg�W�/[yzZ�I/�"�Ypv�����D�����jUNZ����<�8�@��`���s+�R���n�j��*��o��SeA
2)��z��x�,��(/�E�C���*y�'% � y��e���*F�������D�$G]F�'d;c�X�v��:���J
���������
M=��}�v���S�}F���������k��Q'N26���n�
���N,}�������������oO����%xK����
D�q�9I���G�����q��n�2�{�}I
y�1'}m��U������0L�\��y���	7'�
i`�������x�0vDt����4�.��LupX�&��:3�%r28=�x"9����TZ	A�����b�M���*�M1c!si��]���nux�P������&�!`h#�0���Y��5��N���O��1v}lS���%�������G�:����L_�-�{O���*�k����A�yPt}��#�>@L>�Zg|�I�r�@��F�wn)�d�k��y
X�����g.4OQRR��2f��)8
�dV�z<@`Fk�E0�T��9�a*�����zuj~�AC�tC��7*��e���SL��d	Z7��i��ZLTg�W�!�����U����l|<s)�D��\J5�g���bS��o_��������0t!�%�0����B��z���i[��
��H �,yr��Xi[�Xe��	?C���Z�D;[$k9�N����E�v���[�pn�.����#�U#�y#�M�k����Im/����" >3���$���Z�S�b�cf�V�:n]o
	1��)	��%��)��b��|����r O�T)����R���iS���H�a�Q
 �5��8�������>������g����qG�j���Y
���N�K�D-��&��5b������?bf��p���qH�7?������������k�����DK:���bC^�r�r�����Zs}��3b��4-�RR�@&wo���A���Q�m��v�%H	���o��v�D5
��#3���TG������=?���U	����J8�I���"��u�-�@C}���q���4Up���������N��}��u�Q�,@�U���e�.�ge�V�j�����B���mR�������&��iu�<{�\O��x���IE�����(�P�v<�k��E���Ll�mX��"�
+���$;?�[s���w�cNZa�|��_�p��$4x�R_JA�,,�v{_��O�'�&����@M�IALnwj�:\��fn	0��\���{��^���d"`SZ�t@���iSi<K�J�r�@Y�0�r@�f%.h����F���O�n��F[	PH5�R�������O#E
�e���dP.����=����1�R�{�h����6���NPj�����4��}��h��:qe.����|����<$�X"��,&h���L���j��H&�$�P��]GbAs�zN������i�A�*h+������5�c��>�&�$��ML���z%3C{��m��/����@�4e^�E���D�dI����GqH��p���:����~��&��|P���m-�w�x��y�z��������Wq�?�7~��_���k���#%h�LaR�&�N�Q��ot�M�
w
���l�
q���Nb�&����Z� o�0SB$#�#��
���`����u+�}D~���t��C��9�J�B����(c����>�����K�>�����?�i@���N�<h8��C�t�B�	7���HI������J��Sr������4jUN�������YX��D���*z�A-�n#|P��4J?�����I�%���!��4�aW����Z��Tbt�)0���1��s�E�l*dR
n���T.����F�~��k�l�P4=�H���@i�R�R������OC�":s�n<(e�K�q���
-F+�o��
�'�B���dA*	3?M\�,..V���:��r��WA[�$O���3C�����G�Qt�|�	�1T�X�H^��\�Z$�x�M)r�G�fR�&���I�c���	Q�����7���G}��\���Y�.�x�D������,O�6^���[|�%y@�E�H�:��|Py���(v�����Ga�;�7~��]��K���������vd��e�<�Q�_6+Zg�F	�8�#����r�
F_O�-��@	d@����h��}�X,�gy�W?���<����=���W>��(���������z�>�����V�rj,�[�3CkZ��F��T2`�4���;���9���c���y]z7����<Jeh��yb��K��h2((�����)E�<������En ����t3x�2S+
�9���y�O�G}_X
fR�����h���@D9�D-�@r�����B&�(�\�BH9 +eV�+H�B7�������^�#
#�_����!p��V�y�Q���8Q��^ c����p��|g�-��"��H&?r)Q���H%.j�{������ aq�����cux&p�q���
�=i�4��p3*,A\
���J��X�H~���KO����b&�+}�@c5��J�*[��g?�������;�
=���K��9����
����q�����gA7��_EW�0�*���	i{�p^n�Do�*����]F����A�{@����> ��Y��r����J&{��p��/������$w���p�l���m��I�	�Q���
|\
FG��#��:��[��I���?QMPA�P�1���/,H�b7`���c�5H������"`�q��p����sk��zc�N:��
"�.�rBaV�$
�(X|�3��o(|���w>J�+�n�������~]��J��P���0�d��"�`���t>y�f���|I�wSHp���+d-17Yzb�$=����Hp������d#Bn}
��t����0y ,(�����]���h��@��][n~��6O�VN]����h��8�wT�Yt���+�:���T�������I��e+FE4k���B�����"��E����|���}���w��>���r�\�kfd8�q�5���Q_�!�,b��9���-�&��^R�Tn ���j4-��w7z{$H��)e����������~���-��&9J�G�����=�N�P�*��[��$V�)�.h�7~�_��_P���?�/��+}���������~���r���������~�m��7nX��z����vx��?�;���J��^U��^�])�8�@�1������W����AsY���
8R���g�u��
>
JGpgX6^^cT���G����6�y���A�5��a��p��g��9��Y:�9��V�����?.
����W
���@REO�	)�`+���_������9]���4��F@���)�]�9,������]���p�gr�o0���f�I-d2 ������O�Mj=� ,a0Cw�������fCb��d9�p��F�/�`>�{�R�����AqY;��f���P�?a�������B������	����>�@r<��a�<4��C�Q<Ms9�x���7(B��u���*t�I�4�������|�������Z��N8
�9�}���}�#&cE`���U��$�P����j0���t��!#����f�����y:r+{���y�#�j#N��
j��{����
'oq���<�Nr�I�$��'��o�A�jS#�n�}�wG�z��|
�����W�7~�M�{(h~��c�������o~�^�|b��>�[�nQFB��;"7Y�m���;4G�h�*����q*�L�h4M��4�&������2�������	���`$>��`��������did
��.
0���I���L`i%Qd����[1w�7����^r�������z������7�WW�[�0�B���RKc�0@$�.`�	,�j`����	�fj�)N��#h���,�'*��m���IX��@4)�$e���/��[��}���c*q���9HO����3�M�D��������pp�����I�OVX���e�l��6B�-]���������:t�'"Rr%J��h���J��s,���)9G�b�=��l(���*'�m��6�`�F5GB8	�c%w�+&!��PZp�r2 ��*K��MjJ��h�������Yr`�s�����5|��x�*���F"P��R;jp����G�������8z��bg�?�j�o��&�E�t� ���r2�(x��B��{����������-I���L*h�D��1z��k�?��O~���?���9�%K��="w$v�����w������-�QK3#�G���o�=I2������dR[������Uuyy���	�{���`2����`�����p?�?��q\��9��z�L��&������*�e&E];�s3�Jb�����g�1|X�a��th��>/:C�whD0��7��\&���F��W��---1D�={6T��ni
���Z��A�h=�56�&��2M �L0��[�r*��1�`c�$d%����3�pb��aN�����y�����1DH5�����)1�_�V}@��^D����8��""p�c���ka�.~��-��r;��;�4U�*�d���h��E&���!����U��o@�c��3A��w���jtAx���l�H���Y�� i��Y.��e��w���8��w(4J5�s]/�+VsK)O�?������N�E������_��G/�!1]<
�/�� X����5�dt�Ae��j�t�.���h�J�81]��`���!�?���X�A�Am��������s$��y�&*�zp��X@V<���2�����*��
	�K��S�}]-�N��%VEd���><��
t�����8FtJ����� �_�L���)�D>t�X��Q�_*��D�U������I�s�J�=���}� ���G?�A�&��<�����@�25"I�|G�A�+��3�q���@eG�57��.��9����Q��ap^W������GN^%�����~�c���f���K��&��������.�'�u�r���c�M�@��p�;�b(P.��A!��S��M~����/a16��{��<���t��O������HH/��`�\�;�bC���z�"2�����h:U��OkL��&m�Q�w����:�=^+�b_c?iK�x���1�c�����u~o@�b�`rT��&b��tt�
T���"/�����r�����E��o��*ON)����fH� 6��V�w@R�=�"�l��������1F\�5z@�TB�!�^�qIpY^�6:�XU�wz�@����DFB�������e0�E��+��	���O��SqP]��
�g����gK�QSu��a �Sh}��E����1X��{�
��>8x�{�Xf��C]�N����Kv���y�au��Y%�;�P���� �$�j ��O� ��K��,�!���I���xE%7&(��6��"�]~77����Q��^>�����9���f�C����{B������dX��eU�L���9g������XU�\���7�D!8>VD�`XG�Ap��jN�$����)�a��z��#�u�����x9��H�`k�+[����Db���Q�<���������[����MU�8��N^�i��7�`�a��vx��[�����<�HU�r�� 0W�l��!fV_E3�~��'�a�F���Q��)��F�x�>q0��
T]��J*�8@��.�����V�����^$+�K�����X�$������I�`M����0�E�\p��OO��4���"g��z���2����c�u2�!�YVH��W�+�u��C�������l���p�&!-�\xP�p���r������L��8��z��E��'��$(��3���d��zz�'<%H��*�����Qh"|�!x`7Y����G�G����<�OW��C��_�
35��(����z@pb��������I���O���G?���v5�����$��:WScR�s���<�q{�����Dp��o�~��5��g�}FF���2������v���Q�>�v �M��:\7)�u���8PS���/��Y�����$��v��d9<_b�>���2�%��x��^$����D��~���,��E@��s�1��j���Y	��}t��s��r���e��4�U�H$ -��1Le������������3�z��[���cJ�xpv���2�_�����(?���!P-��~���qL
lbq���e�A%g��
����@L4����
G�)�����}��e�/���[:=���u$!?�t�������'f�,4l#����I�4��D~K�"��O�D��J�M
r�>�����w�N9������!�)��"�/�Z�8Yr��+��IQH�6��b^^w�9��G���|�s��7�����I�rXJ/�������a����'<3��7<�`$:� i�|��{IWA_��Fk�&1F�
p��V���\X���������8�c`�yE��)�D�A��83I���F�4`���>hLl2sE���o5��U6^�=�0��I���'�X�����+�����������xJt{�c��1���D��5��D��\���5p��&2�9���@,��3+>\j�('�H�[^�i��"ID	A�����;�y��:�>��H����H��r�h@z�q�'&�/��������V3h]���4uFg�,0���@#ix�h�����^9� :�����;��$Jz^��k~:���vvF����\0��\1���y��v��L��k�:[b9�����t��\����_�����Zs[,i����!�'Y�G��&��>�Iz�&�QF�����E��e;�,�>�lnnm���|P_�����^��h�#)�
�D��"��p�<E�}�C\�y��'��)	��vd9��K��w����r��'�vN)G�!'��j��e9r��- ������,����=ZP�\B�P��������"����c��j����;��6��zA����nvf�����C}��l@�����K�#�+�fu:.T:��p�r��}�A<n���w��=����[��Mkz�g��ygO���^����<N:��� �JU5W��uP�������J����l��Z|k�S������w:�8����I�����\����C�_Q~P��:�����^��Z�
x����~1���_a��j�n+�m���*~��
`S�!��U���P��|Y���C��>������3��b��l?2�=��Q����>5���a��M/x"�N�������#�12�1e�/�������N������H%�r��\�>M1"��R����vC�B��9�:W"�=������u���U���$���8U�e;���;�PN�%��A����R���[j��OG��7W��L��Z�z�P)�#�e�0��I�����R��U�D
�����B��FG��H7u����R
�O���c�]W���^������d+5����ZN�8*���� 2�?�wP>��P����4"�L��v����n��A�)�;�p�O/Gn��vh|������
�A!XP�%M�9�r���>��Bf^�}9� ���������I9��C�����9��G\����sR9�������r�aGUN��3N�F�{�}�t0�r�g�A������n	��	@R��R���"6\����;�P#����14��]�/l���cP��p9���?Z>�6��^D��Wn���������N��A���l�\����� A��rI���e��zq�sps�}��<d�
��sJ�aD���^.k��9���d	���C���~�!���S�#����A�{�x�=��u}�
�#�'���-}I�m�>o
^<���&�
W��s��s�lGb-��)�
�c 	���V(������Vy�\���\}gMGwO���8J6(���^,i�&��^(1�E�(�W���w������Y��������,`���w�����E�����Z�����<����m����i�������w�u���N��%�:��,�q����\A���>���j�ec�@���>J�:1��`���D���DzeJ�#~��� \����I��$�[*7*o�A���/U�'K��b,p{Gm
�#'�����������h;'�'���@H�)�8��Nu��T��w����m�Py�����Y���|�n���6�����3q���\����OYy��{�3�-��Z+��Q��������<k9�;�lZZe��	�0xWM����K9g�2�A�p�������h�0`�}J:���1����6�p�v$`�f�ohg��p����%��;ZY���p����_����/Kh�J�����A�!���\�s�_���;L�t��A�!8/\><�������9	/Y�$A��E�p�goG��,����v��I��`��<Z�����|q�>�B��50����t5xp�7���|����2z��-c�\F�W�&�!(��a?c���u��m`�94$�������nR����k��_��o������+2��"�(*�y��@�����_+?���i�����2Ol�;��9�������/gS���(��9k���t#I����.���N
.6�i���`}Yy�[�N���WcN��S��R�7tH�9��qB��p/��	U�������,�x��������8QDl{�M}��r���k����y��j�V�i`��,x�����y���6���c�5sS��%����-}�9�#�!J���LM��_���q�j���Rn#��jD��6L����R{��t4��`-3�t.�tW�8�r�P1�~�Bu4u��;F�|��~��vs��#O��
;������r�}\a�L-�a=���RK���/�x0F�T�!2�
y���-��|	�b��w��6���O?�!r��g��,qH�%�zT
�!�����t�Agn���l�;q/���9[E�q�����/2��a�q�8G�L���?�l�Z*�9��m".r�����ev9��2M����L��O��{#�d������Yta�F��`�I��g�����X_�
��Z�5��\o�ee���t44�1����9��vU��}�������!�~<�\$����hu|����A�;��:�^�{"���f�����CP0Y�i8�7������y�q��}�bw��g��gXfl
��(�g,u��>��_������;�Dc���\��q�9�-\y*�	��T�������|!�/���r��C6=��@�	o���Q��u�NB�gd�t�A�<o\������p^~��*��c���kl��T@;�9��J��|����Gz� �����( �IZ��p�]r��d����K����g
���.�'���U����~8��S���b4�}����H��+`��M! �2���W$�����|Tw�V����&H�w?�S����0:+���y�#M���(���A�����h����]��7���O���%N�y?�Qn(�O����b1G��(�M���O�����?N~l:�����@a��5I����y���.��Kj���mp���$��k�]�����?���U�C)C�j�[��P�(�d����j��?VJD0;z�%cu���uc���-^�����q.���X���!�;�Q��9��C��8���.b��o����#�������>�	��r�%p�|�O������5����3�V-P#����*�^�|��D��n��o\��%1�*}���e�@��R�Q��f���/���K�����Ki���9�W�N���,?�1V?6O�*�:����`�@IDAT����w�M�$���AX��}��x������N"���/'pHT�8
��n����A�� �������
������t8�Ex�Q���h=CN�a�\�7xt�V�4�X�K7��9���'.�K��M#l\'��j�A�@Q�uc��F������IRgq����W��%������Y�Ruc�i@��&�@��X��>$���H���Y�P����w�;����
��!���/��z�e�#o�U�Ys����q\FW�r3L
K�3����"/��89�l6�Qm����U�������7�a
�sA7����s���*��o��e��/���`�UO=����yu���p�+_�*�e�tn�v:��x�D���	�Mf�?����bq	7$=x����&��Y�����+z���!B�rb2�3_L�"��9�������Hp��W��:w.�����6������Up���o�������s��DB���E?����p�p���m�r�z��2er�$-F�}6G�bcQ�Q��-Nn����~���]�Bh�����uw�l��0���
t�o��Qg�OH�mhM1�t$���w��(���
v��'�t�'"�F4��|t.F�s����I1N�y�������)7���\��?L�g7&�	�@������Pq{i�����7 ��nF�&��i�R�d/�7��6j�����v��F/�'�P���wu=0v��v��U0�>����r����?�;�~�Zqj���?_c�\�9�b_��(��rX�|"%��.g�#or����6��t4b�Lzu{o����K.�����������Qs��E��6�G>��U�f��u��&<Lg�Q�J�i���4�o[���_J��(A�@k�bg~��qG�������4������oXB�M��������f�li��>��3�?���:#8T����otx���;w��$l �6�:7����M�y����"p{<��
]��`mv��L:�S��Gi�H��m���/�����^���`8�2��:i�WZ'U��r�������M��FR���E��H9|�h���`
�|�@_-~Q��"�(:'�w�z�����|iq
t����&�����p��&�p7���
$�\�9�D�UV!���=E�s�O!��?"%;���p
�9����ak^�N4u�De��gz�m���Y����5�h�S�M�eu�b���&
T��#��"��9��1y�X������n}�J�
��54�����"j�J��kq��k���$3�fqx�j|p���
Q��z��0�0)j^��a�DJ����v�s�/�C�����n�`k��$�P���p���?=d��� ��(�i�v4'��M���D�!�~�-���9���X���X�s�?Y(.����K$�(���9�G&�>��|���>��i5�����JwW	?i����C���N���^�}�D�	{$
V�Yf'�I���G�)O�:�����2
d�~���qA��������4�aX+J��������W{Q7��n��/:����7{|cW!*�%��
m�������78h�o�z���o�1F�Q0`
c�;���jA�7�Q��w�]�[��s�_I?Q�y}/�]3�pE�v��o��������kF�?6�i)J�e7���H6"�l[k� �J'�@>z����D�v��HJ�a��V������'b�i�!XT`$�U'~�N!j��I �cK���p����:��v~}�;�0cd t"�&M/�OF�,��c��J��z#�5��[���{��^;T���}��ABM��\2�N~7�w��Q���c�����j��OT�:���@�
�Io:���z�G�P���7(st�1��������/�={�GH�c��
l��$�3M"w�y����l|{l�#/p�#o�,
�������n,������r������uDn	���V�t��	be�K0�z1�$wm���������u0��R���s��VX�t����9m�PQ������W�t��,:v�������}o	�
ElJ��v�ygV����J�^�6�5
������<��n9����������/}�;~QR�mh2|�X��a����������x�������6�tg���F�oZ�w��b�Qg
���(�]+�}k��v��*k����Y;�2D�l�> !
")"-�*��V�v�v������~��1d������[7��m/�(=|�1����6��dS��k�.���.q������w���  �n�)2��U�!����/�'P=�&~�B�o����v����p��Fr��$�:�7���?��cOj���my	`���S#�v���"�'��+����hAH�Q���nt;���>�S�������q��h�;h��Ys�M��N&Ay`���|���{�8����?P_�jxD}y`� �A�{�_F����Z�cWr���d
^���W�L
:7�DC�e�@��2���sAx��� $���@����0��v�,2.o���?����N���k�U.�t��hf�V����mb�eR�F�F��\�:V����b/��Yu�;=�.H���|��������M���
���U��(��Z�E��n�������,x7���j�E]��l��k������)M#�m3.����:8rJ�T,�j=M��5��Z�bA�)�3�b���1c�2Mb��x�,K��|�FL.*`Ha��m�������F����Ha'�����C$�q1����g�]�r��y�b�}3Q���~U2v�x�Kf�S�K7�t�Q=�u��;1vm��UK!V��@����r�������O[8�������O[:F�������l��O�|�b��AL�D������������ta/B@����.�g��HD;�1��l
{��(8�"�������&��F.���a��L�7������}L���+���������x��4��#THeA�����`��&�q�0��?�"5E�O��P��=�B9�^�T
���QA���VS�J���IK��
���*����\�.�����G�����N��52�N�,�������
������������	�kQUf��b_nzI���U����;>:�=6�����'��0���������)��z�?y�]{���k`����.��d1��q�������������`��p.S�^ME�QEZ�dz�e��������0��8c��y�S���J�G�;	���*��/����+%�iSy��=	S�{3H�G-��������n���4�	��8��/Y�i�(!	��)���p~h�7�j����O���^1�q�>/+;8~
����O���$IQ�W5|T�`d(!xd�
�eKM���0*�w
�W�]��������|R?D�~8C�e_��=8ZIU��h�Xk���}1�]�[8�����$�o���q�9G����A��s�/c�$i�S6���{ju�wgDV��#7�������.�zQ��6r�rf���
����vG =S��BO���v��������x���=��o~$�X9��������I��-���;A�
���v/�~���+��������I����kw��Z�1 �3U+�0�IE'��$3�21����Z0[&&����&��uU{K���+����#$���>va��W{��s<�����co��,�T�~�j���6���5,���@�q�����tTP_������#�7;V�tZ�#�i^���cY�%7�c.����&6����%{�R6�Y�����4T
������V/�7%�0dU����?m%�*b�0
s���(����]���M�N���Ha�5O���j�������]�������0��_t"������7�1��*iD1��^������;S�u-�+yC}�&�(�@�y-�����VLa�	�� l���`���p(*�������K,8�F8E��=�O!�jso������NT��b�f����n`
������+�N^�p��,���!�7-�X�����=����#��^���	���<r��a�B�f��M�7�"��`��	�=���nx������0����5l��N $��x����Z�T1� ��	�c	�!�t���%�!j�����������B8���p0�Q<m������j_I�#�t�X����Ul\`�G�*i�)=b_>%i�1���	��1��������Z�������ZA EDx����j�o�8�*����Xj`aG�vTK�j��s�$�����ld��U14P����G��E��f|7�a�b"G��h)������2�\�RF��-:�W����}S���<��'8x���7S&��F�	$�	Gc�b� ���=������i����t����Ia	�	0�����k����>�~3������������R0r8���f����<x^t�1�VF;(����3i��>��&���Ik�&Jv�M%��h���.1�-�OJP�B+�>6������h{�
2M2�|S����V	'���� e��Q���=����B�|��Ho��������������M�o�V������v-�0
30
cPr�8�9�)�pK<;����V��^��&?v��6���|�`u���d����?�����G��1y�����p���;9k/��$����=��T��T2�.�����+����D�3kz�V�������;W�F���(�v������8C�%f���!viF���5?��4��$zM@k��$��`Sm�",�E�X���K0�,�H�������r�XD�H� ��@��e7�&��=u��1�A�9=�IWD�;X_UDkXWL�2�{��y[���0	�2/�D$���|��*��A\118��|�(8�+����N��;�NZ"�t�f�v'�\��1�J���u/��!*\4�"]a����cG��a$-���-���yI1�j��},����1�/�xn
Q|�&���b��wK&V������.c����=/4�������i��|j�?�?�E�$�@�nL3Jh�OX��L�|\��5k#8!�nD�K�F���B����EIx�'`SC=-��_�'�`�G(�{y��:f��oL"����1�--�y�	����Q��~��X���y�N���*/\e��|39�f [�"��Cb����[k�t���)���.���x��B����{I�R�C��s�
s�\
y�nN�D�SqQ���9����%�[�mE���K���8@�����a��M��W�Ih������]�����v4*c|�RS�mm>��g�T��Za7�������~R	��b������E�������������D���KI�ia�+b����H�`h`�
8����E��&T<��q�j�pi�;Z����-xzX��9d�C��=��0K
N��i<B\!4� �����	/��"�l�&@^[���4�a�J��-��,M�����N�M������c�;d�#��)��5���!Bx�r3��e��}����Gs4�2�
��O�G%�fJ���T���C/���u�Z^�������u�M��'�<SoQl��?���XW���������[��o	!��F3�[���=[��v�(���[�FK�����J�.-f_��q����m#���[moN:S�x~��P��V�!Sx:c�s3��-E�������Aw��J�����������-Rc��]��^�6��R�n�.��5�{9|b��']�a��J���j�f�*a��e�~I�	����8�
fn����������pp�E��Wt�\���C~��	K��|d�A���)�nL<��V��"�V�8���%��/�����H�v��A����W-�|����5Z��7�_�u�,�(��FZ/N���l6����o�no/j0�W&�^�������%"��� ��<�k��~�<8��In�S�P�s9�W����h�v��R�4p#V�x�=������v�Y���V��h��)��0 ��U��hs�jHpN���z�������*�D�E�����g���/"ILZx/pc�%�����z�/��m��<���\���:�hBoI�os��������z���r�A�"�+�]���k�%{����
a�����mu6������f�hqB<��b��_L�q\�u�r�/0S����|�L�7I�G����f���~��^�G�:��l`�'������P������;$�Lni��	��-�i4ka�sL?�SfB���/�������0�1��#����`N]pt�#p�0;0�(���k�X�3��Ai�'W5��)�'��G^}�
��t�f��-�l+d�}�h�i��V7���aU�����[��+s�ia��/Z�W����n��j�8���|���[9��������,_"f�����C�S$Sq��9J�!uip�#%7�|�����
>�Ac�
-A��m�n.?�������wL���ZS9F�
�L��OJ:��5[q�}Y)O��h��8][��ec��=1�%�Z��&���E���y����]BT�aD�!	*;{�����1���&"�T����#�f8HN'VJ��O��x%�M���)Lu��!n�����H���FD:����	��8%�I:Bh���,�����*�A��_�,4&�V���M	7�rl��o[�T�����8~p��5�V:{������{��������(�-y�v�0~\���Y~�,/+���bI�,'?S2R���h�����^���e�M���U���}�KeKq���V�������"*	��.oE����U�����g(��8x|��`��;8�p*vw�&��9��H����	q���M���2�����%��8�.�fW�<��b��zb����'46�@G%��*��;^�?��U�U��q�h.��v�r}�][�n�%�5�O��XXw�9��;��v�ln�z��/�u�`=��B�nW3����=���"�W����u����?���?����V������c�jgFM���8��4_�6&��U�a�x�W��d�2���a��jl�.��G��6�g��T+km>���t��O'�v���.�l���(���/��O��o^>�������[���;i�v��f����U7��qy����
v��4���R����������_���>�}�����^�����4�n�\\Ys����_����F���_kaj�*A�������0����w��wT�qy���o���m���?K��
������j>���S-��nPi'S����`m6���67?q�H����\P���KwcJ)�o���t�rK��i�z���o���_�����X1���?W_>�)�����-#��������m����)������E_�����P��}�N�->1���Z�}��PY����������	{N�5���m�������������f�~������V�_�}y�������I������	m������7[�+��|����o�u�&�roc����b1����	%�=^�s��;��{n�\���v=�4��	�^o��[���j��;��d��B\��W�'��M��n)�mu�t�p��1v��'�R�vY�/����5gMJ�4,�.���O��1��'����'�3
��s��k��
�z���I������Bq�mjqW�#7_�3��y�S�[M�Y;�E�����H/8��
X+��j;��I�X'������8�>9��7{�_;a�E���������������{5����=����{~���Vs��Y���M���nTKZ^��]��X����Er
��k�l�b��M6�5�?��f�_�'�
�����"oB��f�Ad��{���S�=�U�!�����6���G!{�:I��0�-�4��*����N�5V+��4�
;�f��b��-���6�p�����|q�mu�y�0}w�I�����/���A����l�/sz���W������e�����V��_*��+��]n7���-�G��n���c	�{��^���zQ+H������;�/[F��*���n��\[7+:��N�#�\������mw�Q��3u��b;m#_6�"b!gX�F�r�.
������j�-m��1
F�������3._X0�����9n���&_�)��(l�CT#+���mj8_�� 'n�������;X(���n(:9>�!������#����io�=d�Y�t�+q�j��d��r~e���Ef�>��5#	Y��
�67�R�D�
�0����;7#]'������\N3�����T��x�f�T[Iy�Mtcg�X,<.�/�^B�X��N.�#I�����4q���v�8��M&��
��J����?-�]��}��7=Q�o��;i�s?��]u��}��Q��z0]RK�l�����*|h�����4,�M�W� ��yc�(e�$�Z�R�v��%�fg����^���w~�Y�=�u�����V���iH�EM�x���\�v�����&��j���Vh~A�����;ITV�V�KF=��	����/����?��������c��F`�J�&{����I�^x����|u0��r���u�r����4��]�.RY7�f���b?����{��z/e/���y\k|���DTk�P�l�&
}�>;�zB��������;�Y(M�@,���� /�b�r)*�N�|���������b)����A������t���H��O�H�n�$VQ��;��0T�P��L��_�L��9q
��A���h���H�lx���H�bM�S��
���������L��0�=��������Y������F,d�� /Q�o��&����'d'�
/��j�bkS�����oh��- ��I�A�����^z!8�"T&a��6�������)��~����e����i�8N	�=v���imq�����+��O�!���I�G�@7��?��"��wW��5��mQy����*�p�wV�� \LL�F�4�#4��;������������Y�[��Z����T~��o6����?�����3F��4v������#{�:Ur����%���Z�,�o1�}�vs�G����smw-���[x��FN
��{��������%o�oi��:������W5����;�/�Q��N��uu�R6hk�������`�������^��<]��o�z=m����R�f�������������
7���t�����=wbn~j!�[Omk�S���v-�;7W
v���po���l�z�v:1U}���?���[�^����2����	���z�D~����~q������y����VCO{]w�_x|s�5-c�5����?�k����i���]��M}q/y��//��l������*�i;e&L�'4��`g/5�.���0���i�����x��Z��\.H{������z]�w��jh�$1v��al�;����6Y���&�V������u�������:g�GZ�����i��[���������;�f7:��~oF�'J��v%G�����Ng�z�R�����K��_��v!�����������j���V�?�L���R�=��R[�6��Dd�%����J��m�HG������S�s������A���@��-w��u��v3d1y�8l���U��m+��l���<�;��g���/��0���U�|+�"/wcW�7���\���J�>����4��V�r;W���r���(<k�����E��'�#h�V��������T����Qg��7
���_��������jKOw����^d��5�{s�����<;��������������o����V����Vcu�5_���R�W��N�Q��6;���V~b
�Fi����k�q�����Y�O=1;-�I��&7^�C��l�c�F3Mw5=U�j������6�K��]�� |Z�h���{�^PQ�B9��.<����+U�K=���{������Q���k��m�����j��Nc�q���vG��H4����t�gJUrV�oW��)�:�S�$�^��E{��z��us�R�&J�U����7�v���l]�j�������������=UE��Aowo�T���e��u=NT{#����m������;�����t��m�<�t�fP��J�\bL)ga"��'c���E�F����`�,���v�K+[F���}��$��y�q� K�[������X�(���/uX�0��^�6u�Nqn�8t������n�i$�)l`H69��Y������hY��j��R#���NZ�V������\i��po5m����V�*�����rq��J!�q����k�v���,��i,�S9;M����n������WM���|�W{���vv��E%U���Z���1��8�Z���P��-�u������3?UQ����"����iZ/5���[om`a.:�Js���}A�/��V�m��m����,��^��W�*v��Nvg���hw%q�Dl??��/G;j������i�%V4lUw������5+UAG�&�l��{���3zT��t~:���Fg���s��)�@@x�7�r��wu���A^������S)��dv�3X��d������8r;�U��NL��44�=���(t�;m���c�~�.q-g�"�T�u��p���E75��F^�F�mW��Bb�Z?�Y�?�\��8�6��Rd(�����EL���$2�
YQ��Zrc���#��`q$|�L�4����<�L$n���6�Vc
�(h��_�x^��'�vw�#�_��y3ur��z�'l�p>gu�v���r��2f����\�	K��l����B�����������{)��5�Gv�����S[-��<�\8�!�1�}�i��I0i�eD2�����W'wK������{��1������[��b`����"����I�M����a��0�q�t��cV'�
F�KX�P
����6)Y�n��Z���;�{M/���U�,;�A�\'�y�'�6��RF�mx�"I���9��]AY,h�d�r��!�
{�
���E��-lD�a�1�FZm�u/5J�%6�+��An['�D#\S����c�cp�-����0��h�%I�T*��:�[�v�m���4�s����O ��R�%�D��F/
K�S���,R
�b~��5�1b�>L��c�Q�8���lYn��EmZ,>����8�F,q��Z����:� �H�����Q�0�,�x�
:��^R���2�E�5�z�����^�m���H���.TM25!>L�����2����sy3
�n+$��!r�2o	u�5!g�20(�I��*��V��\/(E������R-N�B��H#���V�V]�1d��t�y�Dnk��5���GZG�1��������-��tLpB��L����1f8*j����_/��*iC�f@�m����Uhy����P�e�%��il�`�<�OE!S��K��4�+Dl]+O��N�y��EDl�
��c�B3!������X��ZvrY��z�S��H�]�j�������{���I���-)�#���H��/�+C/f��M�HYj�Y��>j$����p�D+DT|�C����ur����mb��Rq{$��9;�"[�q��c�hl���%#���J�-�IW�V�����*�k�Qs@wa���9B�4�*5 l�5_r�j�t��Fl&"�o�{�
������L�bQ0�z6��$��p	`��A���:4g���{��SC2EYhUu��Su��.�3c�.~�eMyA���I,��zR��������1�Ac�������x�"����)��PZDz�l����I��^�y�E����",ej*q/�J����I�n��S=$���+u"N���*�)sH��YW����/�@E�M����N�WPh���=v���jF>aV��������a���&�V��(�~�s������s0��H
�E���r�Qu"g��,X���b�F9!F��:2f�H)J�nt8E)�
��2��9k��#��zf�3�T~D�p*�%R{�vF��i��k����y��"��SH8k7b���'^���#a�T���yJ��LC��� "���#�	T}� �������
��$��Kt%�*]��f��m������s$I��F�D�e�^�3G�H��O�
��}�V6S�L���\gA�X���2�V������mEF�'�@_�:	:,{���_�
���|d�S����c����7�y����B�8"��gwI.aD+�L$�Ulj����B��C���E����1hxn�d�p�p�y�p>�[1�yj��`���Y���s���Y��#1�vZ@1�y��$��)�k�AF*&Z��w{(��f���%J*��W
?���tK>Y�CO��8�����k�:��I��R���
9�U�
\��x�Gn���A&���!`��un�C�A	�5��
f�c��"��_�Y�� d��bH���S[���]�b�b�sJ@�W�c��!��8LH9��=�:�rN��"�*��(�T���\CM��]�d�SR�zd�h����ub����.�E�XD��4V�.K!���V�5��@����[�#�K\�`,��I�)qz^����
i���
�l-���2	��E���>5 !x��3f:6S��SA}l�I�������R�C;�d|�`��'�.E]1���$`�0Nc���O��3���d�e�4�Md�
�i�
��B/S'@K�/ca��MCZ�(G Q��eC��S���^/�Cx��DRa$��	'w9n��vR����5�T�{�@�\:s1�
83�?(�J�B����#t#&DS��1�:�I���&��t��}����XA���Ps�7�s&�n�+�	]��'f�t)��`��mb�=�*��wT}���iA1�Q�hyV��T�jN$o�f��J��Kc�d:���&&sr(��k����zU�9�S����Z%C����^t����y��r�n��j_�RQa^;a��1�Id#>D���!�	��H���X�M��@40�g�Ki���9�v�Bq��t�7��r	�aj�d���~/A�2/�������g���&�TcC��V�&u�Qr�.�|&Y�
�f�1#` S�
Z��W��~!������
�������)���nL�J������L��a�P�L�0NZ���A<z?_���#�
�DZQ�R0`R�2���a�I>A6T�o�5���aN�g}/5�7�	�2S�E��'r���ff�iD<����>j���C4.��8���[&�0�zS�c�>������{��	���:��~W!�oF��2
d�(�Q �@F���)00�����fw2
d�(�Q �@F��2
�@����%�n��t�����h4XD���YX��/����.��l�U��Y�����}rs�:��@���1�,)</q �
��l�x��2�������p��M�O�8	K�<7`��n��O8�
?�����r D��I[���?���E�V�l)�w=<8�WF~��?08�,�L�}4&�;��k{�	�������K����5@1�x$�^�'w� �������w@�����;���|"��0%��O���&�4�S��V���P�68�x��aI�>�����Xr��,!{��/�_@�{��+�������� �Pt�Y�2@�q�V��=1@�AF��S�@"
 ���3@�:][�DqB�{$P��\�( �T��
����6�O�����9�Ab�{RWSB��@
�h�I1=y������?@k�nX���C�k��������.����2�������������!!�8\�=�}��M�Vf�	�����/fgg��a�|��!�O���%j������01�<_��)���-�	��3�0���i�;#�-�a�C|��Yr��������4�#�{
�O�������8_�zw$��OM��!)o0�p�~���CMx'���m^o	�,. \[[C�!H�3�A����p___�)|a��������� ���G-04hAA>�#�]�����zy�����������/�LA
J���[t)R���5��C|x��g��O?X�
����5����p���M���K� �r���^�@���x*7�	\�1�C�`�%��!���P�R����p�x��BT2:p
�L=RW�#��o���:��5�s�������m�1W��P�Sq�#����.������2������������,$�K����y�itx4h��}u��^�<y�r����%��B�2�?~<77G��cu��H952�/pf4�b` y��i���0�x!�`q���{���p�_����������G�����}����C|���ov��]�30�r�0�t(�����.`�pg<52�0:����c��	qb
a��~��3���:H&O��7b;'��P���
� �n�����f^7\$<��>|�(7F�1���	Gn����g�� ����(��C� ������D���
Q�{#L<�59�!:��aH>��Pc1�?�
�2�B-�����k�0�����:	������&>�G ���/���x*7p���EX/�_�j��'�|aX�5�2��J~2���;���}�6c�j�(�-lk ��fL1��F�m���EGN��
FhfF���Ee	RR��/���
pm<�
���W_$�x��r�W�x���._���sk���F��&p
�J�!�'�������!u��X:	��-�A���9#���U�P��3a�1~��
�
�[Hq����;�N(O������a
����
P_p�;����d����
"�M`�P��A�p��G\���@���iq��D�G���������/k�5�[���1	'�8����G���� ��f��F�Qy/x.���
v�&<�����QH����/�-:h0�
�*���>C�����`%.����i 2R$�zm�Qt�0#ip��(g9�K��;R:��A�J�@��.XF�kP�:�1|�����6d��=����r��xJ!�R�B�#���
#�0��"����f��@NL�a���G�rR���h�p���������-X�
@_b�(n@
LAy<�a�<`C��Ht��1J�M	�?8��/�h�p,:W���@VIS�7%��������_��j�e��9�k/h��)����z�(�� U2��(��x"T ��59�� ?�BSK�<�"Rp����x��`�
p0��
�0�`s�(�e��8c�D\�t\��Z`Fg1X@�)�B����wdM��QF�CM��Op�Z9|@t�Y���#a~���)����q��(R��G�,����4LA�@�Q��-!�v��hk�^���6r��t`
?���Wk��j8�L?�E�19`.��p�e	�/���S����)����(�"�A<0���4b�������6�e�m��K$��9��������?�#J�����`
\��c8|��-������w���ql���qw��T�S�H����OrqP �@�1c2�aR�_�(P������k�c0�I"W��S����@J "�8�'�:�/�?�rl�#)�A����`C�*��F�0t?)p�)b�@`$��D{�����1N��`n(��2���"��$�X�-$#i
��,�b�OB�c�H��Ax��S�K�y�+O���v�F��#Q@(����81���'S��=7h��y�b�^�[���'��<�L���a��Px���y#	u,�6��<�.�2, �6I�`_��G�9"��2��d2�<��wzy/2�-x�f���� ��@��;�v����
6�p���,�)��/�Y
�B�a=�W���I���������Z��������S�#���MR���� �H&K:���l�	��;w��0j����f��y�
A
w`��hxyo1�Q�X	�h`#�	h�?�c�'��*f!����[F��]d%_�����9��rp�L!�u<�A}�
Q0m# </�R����eC��P��f���0
/�E8��w�Ay�1MT1z��D�a��rJ0M�IA�����aU��8�K��7-���H��f3Rt�\&@IDATE�>��@�p��D�� �2s	������)|b���{^d�f���q�2�w��!�%�L!�������\���&�����1� !/����_�@A��yMM�<�9�8
`3eBs��J�a�)�
���J	���q<�g�cD�@��0�&�<�Ig��&��)��(e���� ^��X �"��#�`*�)�ApL�?���N0xAdD@��W@GM���3&?���PF�{x��Bp
��bh����pA����F9\@�<����q/����HSx`)c!�#��� �����v��'�*NN��� �j��r�3��l���F�qF �`r��s/�!����0���
�3���� �@���LC�3R�r@qj`M!��d�Z��Oyjd72
d�(�Q �@F��2
(00��n�mbv�Q �@F��2
d�(�Q`)��c����2
d�(�Q �@F���@f@�/o2�2
d�(�Q �@F�����=�L�@�(�Q �@F��2
d_
d���&�,�@F��2
d�(�Q`)`p ;
����2
d�(�Q �@F���C�(�l�R>\��������C���2
d�(�Q �@F����G'���d��(�Q �@F��2
d�(�Q�, m���T��d�(�Q �@F��2
d�(H��o�f��(�Q �@F��2
d�(0nh?�,=n����(�Q �@F��2
d?
�h�4�85c��� �(�Q �@F��2
d�(0F �����j�eY�Ba�@�@�(�Q �@F��2
d�(0~��f#���>�2~�� �(�Q �@F��2
dc
d�3'-�@F��2
d�(�Q`�(p���Q��jleLO9��]�ds��.4?���Q���H�:I������U�R���d�G�G�
<A�	B�V�8�v��}R/YyF��2
d�(�Q ���P`���k�������|�q)_�uE�OxY�P�pR�<��>�uz��$<�[����vR��
v���
����;�#~j�\X�OA������2
d�(�Q �@F�S�x���0�/��[��i�b�~����{a�����^����zz����^����Q��c�cF����������"���Y��2
d�(�Q �@F��h���������!������g����Yog��!������O�i���g�2
d�(�Q �@F��$��@���z=��+cz���[�x{;�m���������
���4����^�����V*��R��kk�������Ed�uc�d�1�����:Z���]�R
�z)����������i&���=�K��K6�e�jE$L���$�,,X��G������23c�J����W����&��M�S��f�(�Q��g��c%K���~�������3������������8@"����	!P!"$�&A��A�"!�X�)�	)��L�k���n�3�����}�~?N���������t������v��9u���}�����:uXp`���<�h�z���?�o^�Z}�������?���o~���?��wk,������g�9�����/�G���V����c������w��r��sq��J�;����/�����w��vw����V?���_����/\����w��|l�c|�����o�����w��_�����5���x����������/������%��f11�y��
_���z����Gp�����������W�G>:�~�wwk5��~�����}l�Xp`��Xp`��y�@����k��O?�������7������,���^�����'o����O�S,f�}v���J���>u�R����w�������_�J�o����}v������8p���n��o���?}�~�B�����-���	���o����;�	��w'G����<����Ow/_^�������p}w�������lS}�������_��>�q���?�������_��'�����>w�s������cH���������#D,����,8����,8���r ������p������}��{��
q������3f�����?������z�O�������i�s�A|���,GFP�Ml�x�����K��c}����+���[8��#S�����
�������v�G~�S��/���=�v��	.��}��'�\>:j�7���`n����oT�E������6+TDL���b��Xp`��Xp`(�h�0�`�l��H�}9�����L��umo7?������������_��G
?��K��=����H���!V�_������{�r�S�Z��{�`��5�[�����~�'{��2��
��[��[��Z����;7�_z(������E(n�f3kk���D7���-��|��2�A����4e���f�Xp`��Xp`��r ��v+�����j��6��|d
���WJ����+|��o>pp����x�K_:���c�!#�m���[��=���z�7~�^�����c|0�<��$'������cK8�4�H��3���<���������=�#����������O�����e���=3 ]�w~�g���W^)#G^�D��[�s�Y,8����,8��@4�h�\�
h-���6����6?��;�����m�����}�w�~����
��G�7o6�����|>�Kl���#_���o������s_�z��'������b�_����7kkk���bT:���q�_������P�)��b���� ��4o&N��;���n��w}�!������O��V����k�/?�������~��/S���2���.�����9���S�������sD����_���/�����7.
��g����,8����,8������/���_��u�BA�V���+~����?���_x�Pt��������uP�t>��K��<�6��~��������|�����������_����g��tr�������J���x'7�S��1��6#c�1�1aZ�[(�Ix�R("�[�
��)�����D��{����m~��n����������c��K������p�����<�	L������������i&h�O����;�|R���/�g�����	�z��..8����,8����t9�.�J���'��z�OU�|��8���'����w��<!���%.;�c<l�a��1M�<>��N'M �P����]<Zp`��Xp`����W���y���N� �����14�8���(>�#�`���#��S:�G�%,8����,8������@��W�����l������^����|�hM�{{|\�k�>(�i�����!�|�'B@B��!���"e�!K@�=s� ��>�����O� ���H�\T|���?+�`�4�"�UK*���`�m�^$oN�/O�P���"�����0<-�"�-�^X2U��%Go)9v�*[������
gR��J��pTL��b
��|+P���Z-��_>Q�Os>�A�.n���z�V>���c���������
�������0��/����a8	���cyy�������WVVF�G]�3�������f�E���F��S�����������.9���g�n[N��|����M�6���Q�d�����+�$��v)�y-��Z���G�I7����@8$��s��� �<��8�BN�P<=���a�i���V�]�����
��O�����1�^$4��w��NP8�|n�_�������BE��3��6&����}��r�&���Q?t2>�U^�4C�[~h>UT������e�=~>`!g(��|�|�EC�\U�T>h��YX�F�[�p�p����}��m�O�P�]�5 �r9naC��\���?�	���Y�#����v��������<�`>�)�����Z����U�t��[�l\�V*s�Tk���\
C2�����(!�[|�����]�%���h��������w���k�i����->��!�����pb���g�&,�����Q���O�W�'��Df�u���h�0e�5�\�������{{,��y������&�G�my�d�$��������7o���O�5x���|��4-7H����Augg����������i��(7��3l��)�#�	s��p���iW���o6�1�Dy7_�cjl���k���	��3�B��B!	s�����L+oW��7%�U�Qi>�<
��VZ���Q���6��������8��U8����C/���$�[��1��<����n7�X
����t�b�t'������A{��[o}�c3���PP&��O���W>��4MJ�K������|hA�����J�e���<���|����C>U���A����m���������~;��Qkk)��9s����O��^9������O+�������%�B������������#�"�S@���5����gS�!2�(�V�.���D�����������#��v��@�B��Qf�����lZ�r+�Z���O���gZF�������r3ii�����)�6u��-����zc�o�8����
���om�- "h���76���(��mm��y��>��|`U������w��!����9�����l�A�s���gs��+�-����{�/_�[�5 �F��r������c�������l����=���cMW	ps���}����c�D��;��Pt5+e�Es�lP�]�g�6 ����y���s�o*��1nL.\�0�5vL����9yI��x�ZE���9��u&��Z��8��K�Os�I�~>�$����t �o�����N�!���Y��'S�,���.�?}gkk������|,�YA�A�����e�7k��3}����}��L�"OWqo��5�h�=������"�'/m@��9��A_�r��4y��� D��3}�q�P�l5���1W�^��U�t��b�g�A:sc��8�s#^�~�����V�f���lQ��w�/�=����8�=�#��(<{����3p�������F�J����<�v���ye���8U�{�O��c��'��A�A��<M�`���0�T�E����P!����9A!���>*��	�A���`<�:U=<12�C���i\$�t�b
�����5�'[�hX�����P3��sC{rN��F���i����Y�A:�y��cepn�=c���������r��St[=h�:8���S�WF �(+lsc

:��J	k9s#�_Tp��A��Pj����z�<����z���i�	�J'a��v���>��h~����b�4���K��7��e�S��j,8p�`R��@��4����9�q2i����x}��Y�'������s� @�u�<!^N!4>���m��O"���
�lO�	��q����G��}f�p`n����sc
w���C���'����sc�Q3���
9��1�9������Jk����pZ���0�����<��qZ
br3�����77G��w8Yln��D.Pt�����I�2)���J�0����';��2��~�\�@�*;�K-����g���}gn�G���9�t��9�'�@���f�TcD��*�������Y���q�Z���V����
�T�g�Y�}�$r���7S�_N���]���V�����+��v����Z�1���9��*�Q��z���Z�������P���)��s��ys��t�1N>y��1�����A�vqt�LO�����cH���8z��
���@O���my���w$1�f�i\`������������`�8zT��R���8��
2�<�`qt$wN��gq��%��V�S����S/��L��������J�7�m��{�8�,�?r�^"�r��mt���n�B���I���
��C����C�c�lQl�8@�w�K��
���r44O[�yMmf���by�MC3h�G:sC��w��u3hB�@��������p#��q#%�~R%�=�fA�t����5� ����P���ON�X�y���fq���c��X�����-t?���k�����,�L�A�4�k�s�qB� �A*�����i4V���Q����c�����8�T)���l�Ql��0n�����l�s�GU6fS����0j���c
�����Lo�@��3.�H:j$7�
����[[[�|���L+s�������?���i4o���K���:O���|��i����#�����57�����\��Y!�(����u�x���'��7g hY��e��X�5 M
������~��'������%N
�i�s���Q��@�4s��������7*�1���@����Ta�$��#����D5���:o�����
���9�c�mzU$�+Qhi[M��=zz��ni�w�0�s�����"�X��9�ch6U�>c�<��kerB"����1�>�,�{��N.������@'��I�Q�a&�1o^�=N��!��9��0njup�qF�'zV�L$m�nG���gqts��ys��x`vqL�-B�2�bG!s��q��@�f��q�u��7G"�����n�yZRG?���YKF�ML�|��������s$�����1��#e�CZ��Cm ��7���Rx�Y����|;��/v��X�1������y��@�����#� &c�2�C�O=�+��b���63��@O���FW�8��������b��v�@e���8n�_b.-�@��s������Qc����(�����9��A
Q8�}�@/���R�E~��s������,^=l��w��?������;������,P����4�]�����������(�2
N-`�/��9��_|���]*W������������o�f��� ���U�'1j>K���Hu��KD����!n	
����<��h>����k�:mN����>�b-I��<�*������R���������c�����<��5_C����!��71�;;;_y�����8���������>��g�Oh��|xb�SF����`��	�-�A�`:9R>�C�����w�?�vQ�P||��A���[���]�����"3��Z>����|��[xK�p�]8�O�k��k��B6�8��:������sC,>�|��P<�G����c�#;�
�������K������v�S�tZu���wT����k�*������\S=4MN����W�����O/����OxJI��/@���z(��b�z��S�������y��^j�(fk�3A���j�Zi��G���Ts�����C)��]'�������|T����E�~����(dj~>��Um*��V�� �����9X�����!��Wz�U�qA�������qw)��9
��p[��N|>Z��v����9�>�����Oo"���������L&�����;������{���.>�b��0�*���@.���c����m)F�[n>h��]d���������?����O�
�Q�)�#m������g8�aZ���5��|�����1ny���bX��� ����W����������������K�#�a6�7��Ea�B�04�qw)>��t.���?�7$���l�:O������'x* �$�'��@A������:����@��>)�N�]FS:<�A�&�D���!{A�O�a�w���������+������lnn*9����zg9�zh)�P!�~��%�oE<��)fO{p�`��4F�$�9�e^9hf��f��Bk�?��jm���@��v��I{l����k��L��58hv�~b3w"��V�BDpF��/��/��*�9�4��i?�6)��������=��s	m�d[�84�!FR���?�����)�:�k�����x�j_
��0�s�����\9]���B��`���~)����}t7+���g���W�~��V_`P��op�5���t��>t���s@�e^�4��>A�<�t��*tNw+������?�W��8�4�p2�@�:J�jfI�L�f��T�bN�����3d����d����x8��X� (H�&a+��N����Jp��X�z4$��&����!,DM	���K������}�A�3h#0�s�QL��'���;h<���N]���`��D3P�49o��Fr[=���j�v��!V�A�?
:��r4�n]:�,OO]�!�4�	;=T�09u����(���X�AL�T:�e!��z�[9�5�b��wb�|3�;�	�K���� ��rVf?���������,����e���=�'��t$C��S��t+���"�K���&�q;FS���F��9��`��m���Y(����������PNMM��������:��f}v��y\�������4���eNi���H1�u:���u�6��3�@�!�S�Y��p=-��b��<7���V�&��i������R�������7'f�Ac
H��~A�Y�}���d��7��{4�[����fU}F�M��M���x�)�3S�v�i��i�u4^���eAv���z�M�����LW��K�5�+W�@�Va)����2������x�\"K�|�$��W����D�����^��9�I����9�iQ�$�O��#��
�y17��(������������Yg���(/��Rr[}�iE��@�|����{�O�na[��&�i�rH���Y���&�Q�������ft�g�u��/����>k�2��F�N��epq�X�/��P�?8CW��.�1S��/�n>��3o��+NJ=��5��:�Z/;����r�(�5 M����q"���'O*�@����L�i���QQ���'Y����i+:3f(�$�NV���I#��}V<���P!���1'yS���%B>���c�,!�lm�!0���l8�l-����O#�alR�����Y��^����9�K���RB:�k��&]bB	n���^6!x��� �1�a��'�Z�	m��fg�Ac
��V#?���(��h������A��;�������9�����-s�L9�y��cepn�=c���6���1�1p��J�aY���<\�� ����,��GlwJ�����Ft�bx����g�D��HL��S�(;�&h
��>��8
CH/����dY���X����3A��A��v�������I 2�6Q�y:#�0��j�C�p`gg��g~��QH���U'�lV����.ycu�^Zi������?�sG�����Y�=Z���1�V*M`Mc���"�XD�+!�3������%�@�}�R�|0���DW�|��'M\�.�r����A�$D�>%i�_L)����_�5 %$�����9��YLc�%1z���[3�S�16�4�v���0i&�9%�3��I��;j��.�K-5�S���I�
UGM>��$����7F"�9�9�4���	�q���j���L����@3`��:���AB�������S��2���/d;% ���*�$�+0�+�C�}s��)�&��>��.�1M[�C����9���iV��L$�q��l��D����g���8Dx
�pu6Gc� ���@��3��z{�^Vi���99x|��u<"&P5���	4<5c��w��W�%������8|�P�`�Y��h�rT����%�X����y����a'^"DL�(@��;�����ne`,��S�V�7�,����T>~G�9b��N����G�7Zq:��h��`��S2�#��oT���^-�G�[�dn63�f�F.P4������U��n�����:�kG���6s����%]������ 
P�$Z����	Z�y��h6&��F��)��[�6fS��Yl��+�e�j@���wWO�����;�C'���?)y{��2�&F��_�oa������[�r;0�s���vZQ������f���1nc#9R�1�	q[�{�f:���yZRG`��=3�f�>��qEc����D��z���Yd@ ~�r�4�nO{,��b�1��v��[�`��4�8tC~	-�o�B���V�����p!G4��g�i����J+�<�csE1��BN�q�i��x�@�����i��,��L�PTT�Kg�lwz91��'.���y/�D�c��F%��c
N�F�I���n�3��EB���N�����D���9��yrB>!�cC��<+809!�+����=���UXX�=�fY���7�u�����B"-���`�d���Wm����Dv��t�H�}�Jk�f�5h�h�Lk���B]g-��V�>����ao�+�Hgf�@Cz�3�B���q�$<�-	\�%��H.����-'��?�:�^A�IWl�b����������w
Y���+JL������,L��P�|���,b�X��9�r�6�NB�\�2�Xb"�v������a��>{p��
�gqtX:-���!�|�Ts����{����1�3���&�1��VU�!�f��8�[�yz��Y��i�����12������j�v��-�+�����|]�p�s��m'����=�%q��3m��m����2��F}�zx%�����:���J��<�F��1B�����������V���q:s����-�7��jz
{��`��I�����t��m������%b\��7;�(:Z�7
�8XM��9��="hM���9�1�gqtH��~a)���}��/��t9Z���0���<�N�����b@��C���=�'���d����� "�1��e�q�
B�!lk�9H��#>�w�F!�=:94[���T��%�.�e����T�`&kHzX���V��c���r����Fja����_�N�&z��y}�CJA�t��q�x�,���f79�#��)@:���>h�z0�d�Y��������
2#�Uk`m5T��hT���ij6T��v��h&r�~���*@"YM���rn��Slu��� '��fo�W�����dD��=7'�@����grH3�m�_���'�O�s+����t{'��u�<����b�d�A:�q�A�al�K���ha�Y���>�u�l���cn�&&�<c�`
f�4�7I�K�E9�g'w���f)E��d!(W�����	V1�Q{��@c��&6�n���C4����2�����W"�f),X��o��W�x�X��V#d��a���1j'�X�mk��9�����������)�Gg4��tT[���Oewn?zaci�LY��*��
9��4��f�D��-,2q�|� �����9zi����v*�����t�,7�SM�i���Yn��j{����f��s�e��|�a�x��V�t(�.���5�g�@#��m��u�{�]�.90��#�O4�]	L���eOB���Cx�����v���O<��$q2l�'�D��J'XH�����^"�w�sL���>e��T��D�z14t��Sn4�"���_����M�b-9�������,��e<�D���;�'���1��D�������I5�;;�;;;�f&�CGd3��d1�9L��q�>=s��$�b�F^����tc"����HZB^��>�Pv��<�ub�t�Q��C�F<�`O�K�
Bs����)���&Lxc����P��"��13u}` d{L�����'>�*@�*�
C�}�b�-��5�X� ��
�}�AvpG�>#0�s�Aif����1� �(�&�hn����@ ���k�:��81������&���f�a�TE!g"�@��m��b����qpr�49!�����_�4*�j�32�M�Y����nz�!��S�	�F�3�gw'��z����������@�Lnd_Z>L��b��b������#x���I�����@�� �$�����A��g��r��)[ZN"K��pE�f���=(M3a8l��������b�Z�<���b�|� �D.(�dD����*�	��H�o=�&�ID��3��$���B�t���NDs����[���K(_V�8��������M�c���P�$h��#��38>��TsrBh��/n�?�Y��������9��I�p�����@�N���	���Co��Zl���c�-�_Je�6O(a�\�&	���5IE�)�z����e0����!��q��0�l;:���������
2��5go����;�s�KJ������/�)���O��D���$"���@�"d������T����3�s��w�����6��xS0����u&h�Ig�������h�w���F��D�<�%=�p��s�����6��1�	��Z�&]���U}�%)� ��5M$hlaU}J�C��q���C�^9R����9K�����
��&����x����EO��]>4M�!F^v�[�d��ZQ���<�����9�_9�I�Bn)�>z��+��p4��!Op���
Fr���~y�Sn������ ���@7jU����t��S@�,�����a��^��S�I
'H/lD
�d���M-`9�����5���V���W^g��=O��bg<c���xj��)�[����0��E[D}$�Vh��?O�rvj?_kI����l>%d���o��������L�[k0,C���]8����64��E>:����[����`sQ��\����+���  �$D�D��O�.\���E��"�����E�\�Fa���O�`eZ��F����:�F>�#��C��2��h�[���|aC�JPl ����e��^���DI���s4I7ti�B��+�0�g,���L7���K+j���R%_&�6
!�����xz�O��my2mE��)��{�Lf�B��Z>
�d�9�6=����2�G���pr����Je�w�������@1������x~jTv)3��%_�5�����F���m�������0�1�����'��(?�|�U�)���/�������C����a|h�^��88U*���e���+�h���a"�%
���!<U8@f�6�n�[��T���u)��G�O�-��f<���xR>I>�����\`���h�6���/�����3^i�X��pF�#9���x�z�D��Os�9��`>(q��/=C�<�
���|�;��-_�7^�W���-�j;����L�T�Z-4
J�-�;��7K�f*����KK��|����C��F�s��Q�r���?�.��l.W)QH�����]*��Ec�?�5�J/���c�q�j���;�
�2�J����od����k�{iw��j����v�T��@N�`4J��J���v��p��\(���������7��2��Lj����5��rW@���e��-��Mkd�����w�N�7����p�Ry��{���(������M�Spw������o�k�����{��t�	����hH���������>(���v���1���J���J{�\!��,0����'��Z���dyOb��Z�ew�U��\�5�F����"��l�\or�F!����;�>��Q����/{r,�������J-������E��s�����A��x-������<�"�r'�m�p�9@�-Ow����Z���{�_�iW�sK��|�S<U%��C�+lNn5�����6������j�����
%8t�������k������l�����RKF��F��eJ���j�r�Fe���Q�	��m��l�������gr|��S���4k��W���v�|ToiB�k>D{������
�-h�������b�\�����S::j���TP-n�r^����Y:�m��������V��Am=�~��E:���Qc��������vF���N�U��4�� ��!bjj>T��@9�,����
�W��K�.����W���s�0��?}����w�F�t��_i\Z��*2��@@���*���C�$f���)�����W�=H7?�S����v3���G�o�$���������P�uM������3���yt�Lr�rI�G^$J�j���C���s�$�nh��=�����om�����y
F ����k��W;�;��f�pk���\L�v.\��?<_�cOly�`f�p���b�k�+[�f�X������G��C���-$����W���Q4��d�����K�T�;�������
��<���	�C��;��������.���`��9n>	g&O)��������b�`&���\+����*f��|�-��q���|�S`���n`�~T��`��Qk)�}���)	�	*b4=�~'�O����F�����}������C�0%H�D�a=�BE�'r���R��{+���D������z�����?&W,>��_�^e�Kg?���Q�.������o����^#�y�������Z*�?H�V��M>�s�$a�O����Hg8�V�v3s����J�k9�G�Xs��������������3<������^=j��r�t�^�u��yj=w��zb=���xV������j�{�-������C+{�����\�R�u��~�\a3��k��-y+��'���pj���F���XJ_��>?
����W�R;������+<���Z�j��nf����+,������YK�Q��V5���W2�_����^9�|������������������g�-?�^DR�Vd����t���W��s��|����������(x�jU���Z���km>���%�G���^�s����T��f�����9������7���j����#E���|k����>�`��u�wn�;���#k���+i�
�WzH���[��?~NLh|����0� �����
��[j��{8@�����9��%f$�����E�|��^���x��v��h��������5��;��~��e�����f����<��^�g��W�<e�������1����6�s�iNm��k�D�_�mf3����-5���~��yj5�:�k����xh��b�����,t���V�U����dc��R����\��#�W��>-�����2/�4�^�>����o�3_�i>^L?��OszU6��A�������r0��FU|2A4H����>����z���������U���zj��.y��73��no-�;_��^XK_Z��%������N��Bgci�����m>O�N0���6J-���u���b���wJM&B���e��a�������������KF�@;
��F�����4��5�z��������?�U���B&���_�d^�k~b+��L��[���9�*�7[�Kg�F�.�����z�q��=����B����KK��y '�'�����t�{z3��F�����H`b�U<O0����/�i�F�B��l53r���W~��6���L�7��cT�\1w����i�� _/7�|��2F9
>nS��j*-O�c���
.Zr<Yzn�=M>�G�@�f�OV��>�A!������L�z<��!T����o,,�><��y-{�������4A?ixD��	D�~������g�]�'�#�[���b7A�<)�f�4����!#�,�$t��=0Cr;���	�k|+AX���z�+p�l�4�"�bZ�+4[�@�����t�D�����|�QB�b��������c��.�?�������^n����'+�kBx&��i�\N5i%]�Y�{������z,,#*�h�&*��� B�%���g�wTRK���
2���Wd;,�����k��t�9������9���cS#(�8+���w��<
���'�_m4�
4�O�I������������6?��������C(�%
����y�]���W��w(�0��t�� ^���1��9����I����� S��G?+����>���b���k�r������m������Z��C�!�P'�h�
/���b����;Q]�����I>�
�,��K�i��/�������
��3�|����sT�]�
f�aE'��x�-T(��]vv����w�^�>������lZV����|��xzmB�!�F|�?����J�RJ��+�]�1�Et�
�'3D3�Q����@IDAT��j7���l<-���X�Z���1gLg�L�+)�����T��SvI�\���]^;��U���px�������W]b?���
C����d��r��,6<=@���A<���7B�1�W��#�IQ����6����,$��hh����M�%����&'�|����H�����8����?��)��:����%�|�.X��w�9���/i�7���nV�5��6�������s7������/tu����p��5�Q���E\"�����t�����#Wx+��Us�iG�@k������g�b��A�sU�a��rTb��'����� �b����$�=$�"_��7�����Y��jym-�����6"!
p�`N��V<��+��5b����4,Z�*�K�D�8��CL^��U����`�� E:�_�4���C����)fW��h0�sF���"���&>�Z�.��R]�YN���J����5T�������}~M�f[���	��~��%����q��	�.�q���h/L4��3Q�7(�@0\����|yu��8���`�dwDI�a���R�Q�@r4������`�������&nb���I� ���3�N�hP�kp���=��VK�:G�"����Q�NC>����m#!�������
3d���M��*�uNh���	�L4Y�-�m�0����k��/h�1�LEi��[q2����f6C�Dw��Rk�4���
@��o�X���Jh����C�?���.�+�W�CR	���R-H�z f��}���{�|$+�Z������>��Q�W�!|
Dj��l�P
(������0UL#Q���O�J�Q#����pWx�������H!]5���4�yk2Rc�0=��z^-��:������>'��<����
�EE��'����#�1�Kz4]��� >�)wb���efy������i����?�j������\���-@��C�>�dEY��7`	� �0}��A*�������2����E�R����:������j��t�<�:k�#�a�`��Wr�fbt"�����N����vV<"�g��	6�\������j������9�CN(��'=���&�	lEd��T���^��zc`��55B:�s2u9.��'0/����K,~_{4=����4�U��>�R�d.tK�+��|C+r��.|�mb�m,��sV��r���.qt5�&if (�sL����]����nX/��vV��V�e�^��X=�e���0���v�
o��^����ex�����*�K1���8t�q��la��Vxe(�as��&�8��Cu#!n����Z�a���a��`o2�}�O_Y�Z����T������)�V5��fv,�v��x�`����Rk����Pk�d7�Z,��7@��[r�IL��=B:$K"��E��0b�'�",��V���%ad�%n�d���@�������X\ gV�`��0�o(��2��jG&�q����b��0��-q��")@�O�0���(/�Yl{~�s{6�)D�X���� �v�m�QTN��Ua�vI=
8[�LP<�F���F���&��@�*�.
qYH����4���0�D�sl�
��u��>~�Q
!2�]
a�m_� �
%�&���{������T���KlXLe��2v�u�4�qL���[�!J���q��rlo�-��	���^��(�a�o���7����
��#�n0�K���� $4)�:�3�Ql%��+`Y$�!�K�f���X8o�0���QT�^>�N���yA����7�������11���e/��D:|�$M�h�0\3h�}��_�:�����Q�7' ���;,[<{�&��?�p�}0��GC�J2C���2�|�M�a�q�������N��m�5�6���1����;w��������
K��8�����@�����i[��1��^B�
����",1����Uq����^��[�q��������)^I�*�����������1�I2�����7q���Q%!��B1���!E��}>��&�2R�t
���31pN1�X�o�m0���]$�	Le ��+�9�F��t�O�FB�=��'8�s���X3��C�W��F���>�'{�%E1��V����E��J��{�Ba�zk��)HR+�u�r�-<�G��R�V���������]��o�q�z��x��9~�D���@2	GD�p(���$�Z�����p`.�d���H���N����L���v���
q�-47����&ly`����"%*h������c���{8��E{�U������~7	TM�(>�����W�\�}�6������?C�����Rx�Y�;H�n����B�q�
�L�gB�X����6!m#w�}$�	<`G
��Ap�+����*V�Y��`x�)�o��X��(A,Ir>�;�o@�W��B���Dt���n���Z�QA��<
�T�_��]�v���$��4�I�edz5�:hr8QraE����`��m��)��������b������2����&�rHS�
�fH��P�"O����>w*X8��/���v�4��1&�A�n��0T���ns�d(j��|��$q-z��
7A�^n��_)��K�V���jh���8�A�
�@�j����B0>6	������rj)@�HCf��|.����+8��W/�oqe����Y�c3&�h�r��� `��F�����54�QP�.Z���lF4_e��PV+��7�7�%���mg��	�\%iS�~�P�����nCr��['�=�,�GI0��L�`Q�����~���J���V�J�Ex��g���T���E�z��I������5j����[s���MNS�N���dbH,�h��5��&�������VCv�"���x���D�s�_�7 ����>�����4Q	s��0�alP�|{yf@-��C���.j����-����DRtF�?��f>�Y�g*&l��3�s�{������g�8�.n�6�Y���Y9��3��9���1R�v��i4I��L����}1aO��1-a��7�"1�A��RZ�F���|qXwq(y6tB*�=�����C3C5v����o����%�N{�����Is�(�$����,��!m���}�>��d�D�q����P|r�[��/qD2����E>��jTw�vT!C�P�i�H��k1�eT�	��f�v�5~4v�y"*j�G��i^�9��� �5�BC0
�9��BVUFe�����J
p>r�������E��I��Q��2q%^�����6G��r��kJ�UT��_z���H���[8`����������O8�w�,�h�>PuZ���V32�c�������\x���vX��B���V:c��A3�)iUF^�+Aj��s�X����Bs��	��L�T�pK��k�Sh/<J�X�v_�MB�;���EV�����^���W��y+f����y�lD�!�O���>#0J�5���T}z�!�4�=���d�>�C��I��}tu�����.� ����������$�%FwLT0~C�z]Tg4bdc@0����a��`_a!{��u�{�
q���2��}U�[-J�
���[�)���I���+A��:����(HTV��<���/�+=�k��"e�X��ra�������/5Ux�"vK�r�G|�S�����������m,ZB(1����D����P����aF�v��L����.�[�Sf��������9�!��]�d�&���*J�+��$���<�1����b��Pk����Q�Ra� 3�D�����_�5�I�"��g6w�P]����D���!���I�7����b�t��uO��9�������m��
��26n���	�?	+�A1��BCf�HO$
[Q�z���H�i�3�S
?'.�V1r���J�1�+�76��\�=�
�g��S;�
���:�2);���`[�l��!'��Rn�*u>X��%*�(�BL��&EL����	���wFE
�N���,*	"^X���-����)f��!���R��J��_W�b2�F���%.��Le��`!���R�O9��f����MN��0oG�
��4*Y�89�|�Wv�_��
Q��A������U���Yn�~D>��v��L�KMo���Z������!,�'�R��r^��
����bs�����XF�.����rAP\��Zj�|b��h����2�����v|b����U��j
��u0��r6s�y(���Z&�h�|����,�l`8���q����O?��9Y���`E��Tsp��,������k0A��b�d._
MC�@AZ*/����>�L� "�YP	�F~���;�f�Lg��ZV�����cu}����V�8m�'-�/���
W�U�	�u�m���B����L�q� E�����(����7�K�x��4�������a��@�3[��Q������(B� j�
�[=�IEPe��"+9���R��fn���ay���%r0�IM'���7�/�	��l���d.?����3��q.O�����t��P�>��3>b���j,e��z,�-�)8hw���b�>6[.�"���V�Qy�H���@���R�izl8�=��9���r]V�-�Qp �3"@$��F��m�D������
st����O����p	V��:�T
�����$�����z��4�����]^��'?��~�W���C����u�~n�
�Z�@)	��&lC�E|K����c5"o ���=�@����f\���=�-��6X���n��^c�����Z���P���y��c�c�v����f��V4��!%P���!���D^�>�����=ED.�c�:^�C<���[���]���j�vd���~�k��y/�%���>�=��=�:����1d�E�y����n�S����o�m���ma	[I
����a#����?�ka�_>l���|����?9�~�N����N��V
�P�j��V������E���}*�s�
*P�d�+Gm��0�V����x}}�vT!�����S�j�����N�+�m%���f�G��[�+U��_�ky��w�{����w�r`�9\�^�it�p�����s|�o�� D���*�z5�/����T�9�3�n����q:�����e��#�
o��7���WI3��������P��+���,j�R;�������R�k>�� 
����xrAC^��L0���mZ�K��o^�v�����������q;yP�&�g�A�/l�Ui�����3��eq����mP�$�A$m��K����!
Q:K$$�����_?l�����*?)@��Z.w�u*�!��m\�6�|gP^|����"I�{�?����R.�(e'Jr��VU>�������1� �}�F��|8�f���s����y�Yl?����o���������FW�e��w-?��k�/��nV�'\�v��Q���m�~c&.�!����~�w�N��ZW����[7���|�������u�1�0��o�y���6�������k�b�-}�Mt��y��
�`c�[{������ Y�����'�Kpa{���U���o����Lqy4�i���
#����?�7�NP*����5;>R}�"n��x�nW��H���1]">(��"{@�����[����'c�}�>x��Q�7�.�����#�-v	�n"}�����=�T^=la����gG�����
-d�������+��%B�X����>�������?���6��PQ��z��'X�������o71>�T<�%��=����|���{d��1��<Wx����j����t���g9������>�{�,�����`��d?���X�}mO�{�Y��6���p�B��<egO->L���������>p."&���E9;`�`�H�R��f���2S�o��qV�V�@a{���W)�`�PV1�=W��#�i#����<���
D<����b��K��?&K������-��?'�HT��W�,"A���<)O��x�D��)�����Jg� ��g������lf����9�������z2���2|I[������������ek0SX�5�b������"&�p8��
~���#�8�Z�A�[a1�Tg37��I�Z+pV�� ��!BG8*0�/�������?~.�]���� ��nmn��y��p!cu��8]���F���N��n/(�j�"�{�Yg�D��Q^t�e���=p����`&���@K��D��e>���py��S3y`��@d������0����@z�#��:�����R!��p�-���i����f��&h���
L�x���]H=�S�}�����}�����^�
�T�E�b���r���o�K� LZg��z=?���X��gq����	��:�Kpl�����������hB���Y_�(rT� M���G7tW��G�k�Ic~�G�/�d��K� Z&?��e�"�B��i���Lou���BA+�?�������[J_,f\j��>�w�E=�$a1X4x�J��:�	v��:R�B���[7�[�i�8Ht���r �Q�1*C�R�>H����c�(d����j�2}P���������<g���pa�o��"��Ve58���,���W@po�_{L1�?�
� �f�#�Jq�x���
�����.�i�_�f1���h�#���r,��\��P�|��@�M$X���,��N�l\.���)�bodxz�L����|q(�Dt.�A7��t3���'XdTo�}���l�|	b��j�v!����FQ��HV��/��4y�-�}�P�2��X��=����*���A\���La�
c3cvP�����t�Q,���:y�G�B��a�a�E[�A[XFb::��l��C&np���"`|JK-�+�����pn�pKC$�0�}�Ee$�'����e5p��2fY�Q��e���D��h&����V���`R���Z���������y������%f�&�����\�l��[*��f>�!"w�,�1�
���c��s�/
�}��*�	�D�:.l�1��om���X8 ����`�S�k��KQ��M2=���NY�,��5��Ac�MC18�R�
��q�����{Y|y|0�I��dV�x!$�Z �p��(hC���<\��XE������F����D�9��v���{(`�+��n �B8�Q����J������~s|�	r8��5k
���fnB�g���2�@�Y���>����n�
�.E�p����~]�����yq�L_�>���(`�b4�%��ZFBH�Fdb�Eo�Q��X$I-����jP���2 �b��2��Fb��5�It@�����t�-.�E!@t������q���T�>��T���L����&|�D��A�6�(3�w��l��r�X)��d�J���(e��'
v�`���3�+L����F�@O# 2S�]��?�z-��|~��V*��e>v0To��Jf���Yd ����H���J�����j�
�*��?����J��NJ�{4i�a�Ij� -V0�*v
�-�L$\�M��X8O����\s^1�����L��������t(���
�,�	 �	����x����5z1�����@��]����rb���*�����kw[T�ACn]j�
C=&��|�����e4u�*[���#��	�f���H{�Ti��j�"�8�jyg��h!p!�^�IZ�I��$��S���a��AI�d���%��i
c�j�,
�r��0�����m�V�����wvY�e�k��	�?������_[��������u�PQ��Mp�f�/(�3d��PN���z�Ma"=��%yu�?�r�H�t�5����N��6�J��s__���L����B/�(��Z�<�����[�� ��/��F�/K-�b��mN`=�#x�������As�AZpw�to������|C�6����]_��-!o��
��D��Yb���^����ek�W���������
@�n�s����eA5�Lf��B?S�-����p�)b�%��
�=�#��V�
�#9p�ItU`,�S�0%���`�@���|VV��;�g��q�RCj�gA���@�����o��X��D�]� ��LL��T� �'8�r���}-�g�s�r��/��{���$c�������B�24�j(���f:�;�@���>��.�1�x��h��@i���Uw��y4�KF8,�fNr��&_������BNy.�6�vn��q��������A�A������~a�������Pe��������(����
��6^am}��H-2��_�I��.�Ghpf�3��4���L������
����
;�>n19W�(���~6�A�1��&Ah�vR�7��a��0=X^?�O�n!�du��!��bU���i��>�$�@y5G��R����Eh�v�������;�����C18<0@���p5d���xP�&��8�*��
�4���k�8�C2��Z�����M��J<T�UF���R����6-H��/������(va�r�2���v��-4��-:lL�� BO�YA0�~�P,�|�s�<��.�F ���kE����@�y��8+����.x����}���Z^�d�$`�X���	���15�0�\>���������U���!���
bH��'1_��[#7A��<�����G]�3K����_��O����s�����*j#��r������Z��.�Ld+o�*�t��v�����`�Spy"������������3��(,YD��~���~�������&j���7=Qr�]��y��Y��Z��L� GV�]1�� ��yo��vC3������C�[�F���~)}���v����� �������Df��kD��rd
�k���DT���:�/0E.-���6���V��
��tT�Z������\e����3�0o��[����2��)p�*�pPh���i����[ �2��z���]��&�����t��Y����=������JV��s�4}��\�<�������o���s���[�6�-Q����}��A9^i���{���XRk�
�����@�oTq".���S����c�**&�6���������Iw�P�����1��mh�m��"
bb����wrM3�G#qh0��h�����������B��@3��g�RwH�q�w4��iZ�W|�@"�|�U�cA����ZP <����������@��u�� fK\�#�E�p���MC��[�6;��r��������x�C-�C�2��aF�����G@�Wf�P�PT�
|}����3'V4�����'�,�z���B5�*�4��-�U:<�7�
#�*��4�nr�H��D}!1����{T���_��|�cv�9frh���'X���H��*�<dq ���"��
0�cp��xHI"�]y��!��p�'>������2Uv��A�i�W����X����\�R*�#`��Y���N�,�.�����B5
ALrM}�K������B/C�R�mn����S
��������7��)�[���FI�
��%U4S���#j"��2�u�#�
}��S�����}f�h����zpd9�K������Q�|'@���4B���[��S�e���-��g��I�Rb��j��w�>�4s����1��M�1u}������v8��(���n-/K�������l�673�Z
��B�HGf��|���5��r�%�ilY�C�Lb7���h����$��!��?d��F��(������<��3�V��*������ E�fh6�XJ�"�M	kO�V�!��^��&��6F8����f�s��zL�\�h�������^��_1Sa{���J�1�L����(�SEAd��1Y�����wl�S��nN��R�O�_b���)BE�����v��6�ZDS�3_��s��v3��U��>�!�w��S�u�a\.�Ar��J1&�LWx$��M<�u7���J�)��Z�������H"��f��4Z)de#�u;x����#"�C�dV��a�cg��K�I��BQ�aAC#wZQ��TA0L�K-�>p�h��Fu�6[����V�{���4�2��H����y��(-��9�^�hj�� �%<��G�W��:���T��AZ�L��3P���8��]�e=��v�C���w�����I���!$�4|���]�A%OJ�[i��@��hax�Le��B�+��":Z<.�Y1���c��P������&��pe��(��k�J����e�>��������|U-4A/|��-��[�k~���m��6n����"�P�����r[�����%r���K&��������[6��m�O�z
��>F}��&�Z���J�(��&�|��������Z� /��IXf����nn�?|������� ���4V���2��2n��kT�e�7*�0z����Q.�/I����b�#��3��d}�A��zc�s��UD�1TX�����?y�����#��E�t�z�n~}uu��H�f���$��Y�	J�N�	N��)^���/��ml�6�`����C��� ��$�������"��%��.�Z�
�>N3�$�a�>	�t9a�6����2���2�a�l���5a��4)Cyp�~Z�J��_=xq����bq�w0�_��G�p�� m�DZ=��`w����
�5P��o�!
[��lJG�$4JI�a.}4u�X39������z*�������F
c�'����q��d	�L����0���o�u+(�l>=������;T$?4XL�92�5��^�n<	�T��b��m�=s��&7�ZI�TDf>��%GGV��q\O��!�	|1 ��>�J�9��SqL�8��
:�:�Q�|����<�E�xm����.�L�E'_:�ECZ�0���PRK�},�D����"n����]�vKy2��s����h��)!H�������45=�D�%�`$����G5�<�X�6#�cD3{F��T�1���	�=�����f�O<���>�5��%h��P�����%r�<y&��q{Ae0��
�0��8,..
�s�f�M��m���x~�mBQ�TN��c!A�D@�u��6��Rr�_�|L5�w�
���8MHT!�N�#*-�,�mlZ���R�8{@�E+��4N�= ����ul���d
�}�_Y����P��Vp�u����e2:n���J}��H	Hu^�~`kk������hk��
Uz:=O�bFju��	iT�6�����p�$
J��%��w���j��]Y;8<�=��-3��F�o�q�'�G��C���k�M�8ST�)��"pkh��`�!�Y�T�7!�Xy���������Yn��)Qk2�����F�����}����>���1��v�Jo2���v�8���G�DI��D����`���_��Ku�5��5{H��,
s�4oA�KB�2��"y�J���)���m�Cz��U��bJp(?��_��l���4��+�@���,c����������n=�*�x���u�Du|�P7^�<�]��(�I�m���t�>�A7Bj�&c.~T@��!��i\s��<��`�c:�1>o����a��e�T���b�7�ki_��r�����
z<�?]b��MF�����2��ufC�Z�7qS���Sv����\���y)��G��~@�`�����;�f�f�$�5@	��\�1�K*��@+�RV��	&fh�W�)��X��n�^j���z4�$����Z�����v+�?�Z,9�#��\a�l�AvJ0I
�M�eK��Lv��r��`t�;L��t��k5��K����H��%�
-���E5	�|�0�h�(Oe58A���G+���IW�`$1q������4����D����z��$4��Ti���0���_$�IE��$����$p�V���WMD(D=�����`6v���tb<GJ�=�D/�?<l49�t�6�KF���N�����@�E��#��n5�
��N-�����wg����*Tk#lE�o)�)��,��_�?���P�Uu�#���~�*V��jO%D�,�+��g����+�Yo\��*�2�xT=�0����)&���P8��ykz~?�!�w���$f�LpG�X�9<��Vd� ��	�b�1dR�G�qF�/XA�G�������bD���)��@��!���5�_i����/���TUA�n�Q� b��Q���+����ih/���A�� x
7$n$����p*H|$��xA��U�!��N*���~�BKm�dH�YK�Zn��hZb�����v���u�iGX�����<�Ki��a��\a����].,�@��`��YIp�
�=���PM���${���������k�7#Ps���'�k�y#M�	��B��v&U�L�������cJ����.
�1l� x�����]�����E��6+�8�7���Ql�x�@CV������n/�!��7S�P<	�%IaGD2Z*���&h�CY~
a4g>'��e��(���G�E�!���68����:��0�*~7_DQ���_P
4A\$�O���r���6�+�KK��<m�<�0A2�4������ym���p�Y�<�=._���)<�AH�9���2���[�]h�X����K��T����+"n�%t��"#<Q����F+x����r<�l6w�W�J�%A�'�y���h�-������)-+��E!E:$�"I�^�X����d]��=>l��$4��`F�1�Z6��;��������&�P�z����Sr�|����~���O-�{�y2�K�>�����;1�*v���0��A����
��@a>_x����9�I�O�K/�?sz���qik��i�P.�x\8����_H��x���1XzW�h�XFG�X�L��W�-P{0���wk�Uk���1�d.�6�m���r�V�uI�H��3��GK�uk����-�/�����{�����^��-b��Q�J�����f���8��,�� c�s��T����?9���a��}����V�������p�K��,q�W��
�.u��rR�9�(��	;jM	la�����M��t`��S����`R��@Dk�-��L����\�������xA��bT�1�W��/��P'q����?I����g�c�a��i��"a�1�N@v���H��c�nes^&K7!9Jj[�^�L�X�G� 1,!���,+�	�0��W%����6G��Z�O�~�,�z�����	��s�)u��b6s�#2�����3���#��?�$����1������z/)����@}�o�����@v�����m��8��Q?y�y�<6���@C�/�o��X�(��_0_"x��.�s+[8��m	&�[�	�O�����,gz�LL��s��.�'aM�K���S,�oFFR���QM���C;p�S>OC��g��F����c.$��	}F����7��$9���6�=����*Te-(���tO���'>���������Gx����y|�����B(dfUVn������f�OT��������ZYfj����������{�'t���l�''Cr�R(U5f<%9gz��drSu�=%�e7�E���R����RZAt�r�q8�c�.��_%{+^����F��~���%���������@!�/��E�4����	}��6����7s���\^^rtQ����Af�WW��J�����`��7������������W�������l���O�w�f���u���fNF�pPNFW�-����z<6jUw��I��s�zw���w�����y�dQ����v�s���������R��E���vk����jp^���	x
�^���������O��c�x�����=�r�����I�{=|������w�����x<O~Y��K�as0��g�����xi����v�}���vm>��������p4��������4��:��>��j��|���i�{������h��>��i�|��2t����������?�a��+_�k��G�f:L��u����h0������=7>���^�5��2�:�F2���hV����]#��j�Qo\[&�)���:

c�E�*������}��+��U���I�\���S{1����?���x����~��^���xPo6��	G{�oX�~�����_���\O����7wu=�L����������O���]b,��G����MNW<1�8�s*�ht���qp=�L+��`D���L��c����`��U��l%�g���u7��$��&�zu�q�C�A��bT������r����?\�
�d/F����'���TK�Fb������������<�u��U�gc�Z�3��������R|�T&�!��EQp=���UN>4�&���+[��r�I����
/��l<�*^
5_��O���~��D��A�f�	��s�b�U�ey:��sP�^'�Y��f�R,v��n����`����`���"���n{At>q�D5t����fD���N�D�;M�j���^�N���.���T����A�Za�8�-{H���x��Y�,���^��Y����Y�*�cwV��r��z�4��J��a<'�K��c���O._|s�'5+r����������sF���}���h�|p��.Z��A@Oo:�zv�l#����p�,s��l�bp���������E�%�[��iR~��"����7��*}E��#$w1V��y-.~Z,���Uv�8���$�F#�h>w��0*O�'����[���Vs�C0O*��M�R/�������E�%�7����e��z��Ey<_"����t��5N��7I*_�_���n�+�kx)'1����t�ZI��m���^N�(��z>K��_���;�+�hn�6��~��L#pc7p����/�'��_xm��>����/[��K��7
��w������<����a��������WKI���|����[O�C��b�wG��]���F�N�iZ�N����12�W5h.�'��p1uJ=[�-�J���pI71,��b�}�U���n�dSD7����s��YPy�^G������^j����q����X��%w2���g������_�1��FL��1`�U�0�p��n�,??�l��?���X��p���0N��a�d<��c�|�8
<��%�j�@|����|��1�`::p��sg�?er1���m���1�r����~W��j�����4�������pK&��B^��)F�_��yp,�v�;AXq��u�m�Eo0IK�v��z�5^xN�+���P��p0X -'�N,���E`���p0b�H�w���b<<��������WQp���B����!�)����^�z������rU�q��a��Q3�[����t��'��������y�����^~;Yr�j<���� '�.�bw:A
����������b:~�����.�z�atf�}�-����f�.a�{���_6_�����Y��mu<�a;�>���.^����������c����������s�F����{�zV2�5��gc�I`��v�j�A���<wa��~�g��p�����������(�K��c��N���n���*�U����
����;��(�zq�u�z5���,5@���M���j8s��/����6$=�G�Z-�����;���8.������i����/�v��d�����r�x6��U�@������B����A�B���k7-�e3^�����Z�7T������{����Q�[cX�8�H�����/�BC��L�cN�%�^�.^=*}������e������z'-��/p���G�{
����)�E�_Of�Z�/�z����+EdG�0|?z���|���\]�f�N�_���~O]>f
�����Y�����k//��W_�V��?����?����j4���K�X�V�e@�}�|y>�������(�$��|��� i�	��2�y�H��6�������F��Tng|��������<�:�~~RR�@IDAT~;����nK��.+��y�����x��(�{��'���&\
���w���#K�Of�1�����z�����'�.hZ}��"������
���7��c�B�r�/�{�/W�����^�r1�F��*�h����a��t���Z��^����l�*g�*ZIS�P_r3��ju�,?/��'��,�|B>U���\%��Y�_�:������.�KX�z�y�$	��tLrqOr7H)�����g���7�2�e�{P����<��m@�_e��� ��c�k]u�����~�_�������m�z����5�~�2�����<Y����4-�����i��#�d�=�t�+��"����V�o��w[�����[r�u?H���������K?:k|�_�=���W��{�����aa��"���wj��j�1�a��Rej��K���M�6(�r�{��7�s?e���p��������p	s�0�iq��,�M���U�l�i/-;4"kf���tl�>��m������R��s���n,�
1�V+���V�#�p��]K.�~�n�p���|HG`d�Mi)�q�(������a����OZ��C�����r��,*}�m���/ap�W���x�f�l��N��vB����R1^��h��A�����2�ly�w���������e�[-#v�O2c?����E�����i��er+�����?90���^
��[�i����U��_V'N�h����A��b�\����$E�k�h�)E��{PY��e�Ir�-���u`�}�M�����2�h5�o=8�����N���X
����2�BjJx������s�@������T�Gv��c{������.����PHi\���O1M!���KO��H|�R;��������5��@���J���-�a�-�(�!�������@���:b�~���l��I�C0�,�:���h~
��X���S��E9�Ci#�gh�wj��S*=}��qT����P`W�8���H��)E�_�b��?N��?l��3�0w��{5Cq8����Y��(��)�~�Y@�0L�8��GC�	i	�a�y�l,8��s����� ��������������\)�p�5C;�u�!d��a����a!r�&wY��}<K����}dZ������L`B��I8�4po�&�.eErs��'�����4:���m�S�p�1E`l��*��a@T�U�Q���;���Y���C�|��[���,l!�����}���*�w���j�d��0�O8]%V�z�`�=�*d���(��$�9�$6Xi��R
dT���kx������F�����0=�ST
��q�'\%O��Ve���es��
#����$��'B�[���	��pzh��t��O��&���m�Y����< ��<����9�x�0�@3����|vh�F�j�6�|�u��\�������:&��3���C�=�'�K��������W�d���*DU@_���+���_[�c0B���)�����������)�FD �vcse��nYd�+�N$#>�dp��G��e���
I'���F���E��6C|�>'���_����~x��;��&��������i��g��O�B:rx-��IJd���l{���v��'��&9��t�I���*��o����
2V'��{C����E}��M����Q��G���d<b���_^��y@�m���8q�������`�'�3J�F!l����e��e�[� �\V.�[�WF}x+����U@>p�Z�V2^����U�"��n7g!�����JM�t��eAX�8C{��0�*@Z=�d)���r���K���hRV�V �����*z�Az����*�Ma�H��b�^|d�����|N7��V��%�j��g���Cq��L��dH��$y�/���Y)��\�T�Re�`5\@2���
7k ��E������	�A(p�a4��=�]1����Xl�/�����$�{��US�Dw���o�|��n���Au���b����[B��?3��i�~��6�&�����	��q�����aT}����R�+T@��;
 �H�by{��5��	��D�6�Sh��<�~ A'�lJ����+}�������r�I�
k�~]�mX��st
o���b@���0��:�j��:b��a�HF|�w�R~F3��8�1C$�.X�`���q��[L�w%�����jy��R���z�B���	i�-��Hbt���B70f>���Er���C�e�Y��#MC}��C����\������O�V0�/�"��:0L7��t�*��S~i�-dr�L���C����?�l:�|O�#j��6p��x��(4P#������O-���a�9�O����v���)���3�v6U|?��u�j�P������.�����K����%�hG�S��$�������v-!��G���7i\A����R�N�j���5o;��)��I����&��e�W�PMV������&
(&�p�V^]\�K��xWm��H�~J[|�Z5��,���e�iG�>ExF���*�)��������5wbn&�@�x-�Y�S�l�Q�z���9�W(�I&�V�.��ad�4�e��� 9���P~Qi�G��11�������j�(ZYo����������l������ED"s~IG�mb�)�+�����_�Gy��$,��@

�����?�L4P�b��3��M(����Si�0��(���<	����+��1x0�&�H@x�D��C&����'���0
�t(�G�1�bQ��W�(������S��l�eX�8:�����+�/�6\���
�K$Ep�5��'�f��g	��m�
�OpL����U�$
�UQ8�7���qdB�C0���Z�@5�J�����F�._�(Z����*B$
��� u@�<��
��h��;�}N��M	��U�7�'E�4�j����U�G.>3h��,�����341�	+�e��E��tE4��'�UJb������.&6������d9���r%����d����3�1���^AL���A4�&-%n`E�3�Q<����������B/�*�K��ID����y�!���#soJ�aO�h0(�[P�z�@#
!>�+-��E�����I��O�~��X&x4iU��~=c*�[��
�.�U��9L.��?��'��g��b�u��"xb�!^�R��&TV�@v���9j"��*�*�����eW�+������c*@�U���`+�JV�Lmb�0O���b�uZ�J���/��������]���%Huc�BK,*��#e!���>C���u 
j.�O@���T
�>���2+X.���G��vI1��v^�0���3��N@�4�8hO���va����
>�E�����,8k�s7�0��]���d`�SD���/*h��d��*K)[��4hd(������9z�3K)s�g�	K"�o�fyE �$_��<�Z�{����@a��5r	��(�|Y1Rh�����!�h�r��f���]��sLo{=1�)���
�5�e�Ht?*B�]��i����3%���s��>9Y�oVE�H���
L��|�����d�W"�'�E������Y�������hJH��L��0����X���H����J�AM�������<���R�
S�
d��^�+1]u�q� �X����Gd	k���pc"���WI����8��k*��D������rz�W�>f����K�����jS@�1���,�(�6���F z��5JJ���z�&VX�Z!��%�	����}���5�	�'}U3�Q��ZL�3�E���]� ��������:.�D��n�1|~T��)���] ��f�A��B�5�
�g*F^:�J)<3}d}@�y`5xN�,$x�|�}�P�} /��f;d���)FS�4l(��C��H�c���0��u�|PO:Y��T��F��S�I�&�jp���IQ�@�?a������'������r�C�(���BP�!��	�H���f�8��*��VbT.a��@�D�3���m�	��j+H��H?l��g��Nc��5���C��9���+�7��?1���o
[��H�������d�������6C������}/$�_�����/��~����Ng��-;��?#��� �9d<���}n/�O^��Ab*���U�gp���)a�|�@c���e��wx�!��*���V�qHd����J�tX�CL@�G�*���wJ����� ��MC�R�%���P �e&�v�.
aa6�3	G[���(0����lks �h���]���&E����R	>��l��!�v�\#��p���2.V�����]U)X.����������PC5G1����t2��ei�L"��8��4��0��=�Y���D�5)�G|�8��{��2��BPb}O�9�������|��D�37���Ai'���`�Y���"�w2A�Bq��[��V����W�b1�b�dG�LP!V	��?��c=��1��390(C�����(P�t�O��<T�4]���W��[=��R��)��3(�@���q�"f�2��h>aE�
��4��=%6>���?��^.4����M�I��{1���n�w<
�LMV���
5I���@��&x�!Tqr@����@b�5cNV����xoY���7kC�,�T;�h�<SZ��"+m��J�_��m}��&X�������s�,�q�'/�@a�������D��7�]�����^0���:�v,,�2�]|��p0j���"��Uy�������{"��X����0N�750I�`�\j� ����������bU��S0���6���W&d��r�,o����Yc�j[��s�!���T�Bd�U
� ���au�O�j^�Z��RjJ���-=�
�e� N�`Bc�`e�;/E��hI���B����"`��.�2�*�/�s��gj�I1�~rm��hH�F5M���3
�f�
�������RATLz�JJ[���?r1�!
x���2
�@�AL�(��$.�C=�al(�?R�"}P�7?�y�zB_���PbUU�p���
~�N����-�A�r�i|�j�JT�����;p /t�G ,�Z^��90���Vy����b�F�(�����3Daxqq��}1��3l:E �g�}7u!f��yDXi�0�2
r�W]���7��0*��A�`��t�M���;�Crh.E��t���70�SL)���Q�W�3�h�� ��0��h����vX�������h9D�dFJ�������j�hM~�[�b�+F3^"C�G��$S��0/~����Q�bC�Z����`�#����9
,�_�<g��%���T-Lo�)��U�F�A=�f��(�j����4������|�	=���@F&T�Q�F�t�(R@F�R#��
]H�~I�n��R ��LIF���@�4�Q���K5��@�r1R�V�b&hH)HK�`R���-7
/�^=R�qQ��X��S�^���q�,�i ����'R<E�$�t��:� �+R������[�hu�N����<�; ����w���d��us�:_��s��^�Wm�$�P3��-t�"���wT��1(N,�W�A5W	�����=��|-�lp���x���9K�g$�X�EM����o%��rPb1����������""w
U1�����&�Q7+D�����'~;�*TW~�_���0g�Q
��I/�f�&��������kW%!M|��^�?�?��� �������*�����(���2��?���Q��iK��O��5,E_tY6�d�/|(� �O�C��H�B���Qq�8��U"�'=��jA�Wd1"�6Cb�2�����d�^��!`�2�	�i����H�b����Z����h��*��P�P%#��>��Uc�Y!CV^�����uK�`}�4��X�/e�e�f���Ug�\��+R`��d��^����<���g��g��u$���D?0�)v������y��0�CMtb(YvL+��
R00�L��&OL������]jCFZu
�-�DkQ��<�K���Z��jIG�9�#Z6hc��<TP���� ���oA8GZ�dA�)
��$�(aTV�������p[���{�4�
��BCI,�~�LU��\���*,����E��pI��y��{3�9�>.����F4�7g�Rhn��:j����������`F)]o�z�\j(6[�5�RSX�_���-)��-:�H�x���fEa(�]-U��F2W����Sir�'�H�|���d�#G�9Y�o�#����T�v�hA`���"(Q���SkzA���_�U6�bC�
����,@vj]��;���B ��eTp�&�M�A
��^�U�(�Ft��D*
���dU�%��/���00�cM]�LI��0��VWQ;���� @�.e�).�WP$�t!$�/8��
2��HA��'.�s���1D��a�!�Ax�O����x%-v���E�!�d����
w�V���l���H�} �t�}F�)���;��f-�$����bp8��3��H��g�akg+$	�R�"�z��.OA���_i����~st|d�c��KZ�*p^�f����������%�tB��<���VjDB�)��"%O�H��;��7*�~4��V0*�_a
5��:8T���(j�����i����YD��}��#i,	H!��(N�<���P=s"����b���+t��~A��J�e�0�yS�yt*>&t�onKL�

vTh� ��&^s����KO��$��Q\r!�"VL�1�	�"�K��
��VP�����33������(�
��+���� 4L���[!�8
����p	��0���,Z!Nv�6��Bg=�����D���@V'f�Hq:%����qO;2�0��1:�W\�%#��;�C���IP��l���r�!�l�����q�����
���w�\�(�N�*��y5�F%S�}Aa-D`�i��5���Zh�?@
�P�.��X��g�s�i�=G�B{�O �^H�7.�/	�D4z]����RY��J9Ug�_��]���S��]@@�N�N��&c��"COiF��*���O���b��dH9D�;�@G�Uz��t����@�9�M�`��P<�D����]h[,	������`=Lk��@���r�]H�B)�p��j�C��@9���41�-J�*0j��z�B��:�:�*��I��$��X�����#���\������Z4�T�z�o�1$�V��II�r�>d��S'���T!��(aQM�����-E�Nx��<n��_��
��U��}���^�^��-�@����R
�&�L�h<�^�� �����{�C �E^�;m�D��-��{��E�f+��A�)DS&��we���� ���&T�i#T7��r&R�U���&��"����ar�W�����������h�: ��t�Vz�(2��V�����<*�JBi���$J���<���7����#��p����Yh{�(�4T�W29*'�
_E��!&��yi�U,�p���T��a�=���vk�E�Y45���WC���+�8%��m}VL�O8Z�6_��'��3�UE���`y����r��l��R*�_�o�� ������
�'�Xm�vA?����U_�S�n(>f:L���&T�4Y�(��BAH�Q2R��Ny)fP�\`J/b�p�k�V�u[Se
-J�S����0'/��|��0AFg���>���O��g��J������P�"�(7��������V`���t��(f!�#kg[I����Y� ��W�H��c�G��B�G|��Q����+��Y�Q���������������,@sP1��O:������v�8�N��;�LQD�IpV
��qTA����Yr���M%bZ�!y@���}�\��2Sq������I�p����:�-����F2A2Z��6���^��R
����r���B�P�E�����X;�M,Q�
6���=�@y�!
02Y��m�g=}4���>Y�c"8C�m����RZ���4���P�����>��@��z�"x&9��/��i���
�t��e���:��q����yHAZ�@�$
�:h]��{�:�|1���TJZ�6�(+FP8���-���0d�%HD��nb�"���' u�B����H��H�(:B�������^L�?���p�K[O�(��=O�������j�il�^�AA^�X��L!O���@��!�hNO���b.�
��<��h6�ir�F���J�.�( +&1�AO�}E�b	��L�'yXh�Lz:���_wC �j^Rj�r0�T��^�#c6�nf��`�|��63������"��r�
�z4`��-�
'�S�b������)@1S�Z��,{�p*�?�;�8y����w��$�6%Q�j%%_e�I�,��s	dAs+>R���n���Fb-�Rg��p��4����<*0d@
��82yr��\��>����O�O�i��T6'��7j�v����P
%��z�LIDz����5���UV�m�a�*#�M�n<�~@�m5(9��Ga����(z��A1��R]�(�%'��-�5����
�AP(d�O����n���f,��v�K�7�3Y��*�):�7A=0�s�_��WI�-k�V0
���W{���<@d������	HJ��FW7�
�:�b����z1/e����`E~I�g<�iDAE�f��<M�S���*ok�Z�'z?FDEX�7���%�?U�����X��h�����y��� �	l�YH^TP��zQcky6�&����o|�����n�Io#���x�9����X��Y�j�|&�A5���T���Uc�����n[��~?vt
W�y�Z�+��L���$Bx����@{�i<Xj���)�CQ@�4ij
��6����C����� ���E+�$D>BU�L����C�+�m���������h
����p��3�j��D`,Y�R�S2�]Pn�8.���AP"��9f�t$^�@��H�>��K0=c|�l*�Ob@i+�H�BI������t�pI���[�:���I���Q��r�"w9�&a�nS5�x�����.f�/f��r�$EJ-DS�"H��#�N������(����4�y��Y���:�;9��f-lT�0�D� �����y�1s�*~cm�O�@��A]�_���@'��N�Z�@|9No�2��g4W���}���Vs!����4�|����������.�Qp��p�&C���A2�Wda�bP��TE��v�"��d[�������h��FD�	��,�+����E��Y���/�J_�B�AA���Oz��.��'II�q�o`�'�4��������������2�-MC���H�H������mN�����!`K��������0E�x�s��w���~����np\���t��_���A*X1�����;�X�eg�3D���hf����M��I���9�B��B��iL��
1Q
��h9�*��^{�l&��T}��0(`�<hw�.��E�#�!��(�K����-<�~%�`��O�D���#�W�4�����&�$j8���x��\I�j"!u�AL��V-i��r��`O�2sSDF���a�c2�@xr�Ih_�.X��J)��Z ��O�W�`S�(c=�Y��3�23]��-$B�C%4�����/EV��Q���
q��U.��
�B<D�"���X���BJ	��uVo:n����Bu:5����
��I�C~z1]��4V�R���;�W^���U��I����]��_1@9[�`i�D=#���5Z�l������q�y�TF���R�<g+�
���JP��}��zK�K�8�0d���nA����.���s��~��z�4}`&S�,�6��c���@�6.�
�+�g��|e���= �V����U����d3�Vr+HV��\A��^����I��{�pS��
��\�X��=�,��k�����K��C�^���FWY��^4�^\�mWg���ws���"��O&���:��h[���&'�1�`|�����+e+�S���i_,v��@AT��$��7�a�H��FJA�\f,��%�Y\;��J>o�*�����W�o[F~�g[����J'�\�
G(� �2�i�sCcB<E�"����&j&�J2k�Gf���05���J����p��=r1�CY�b�Sf0!,�� �� ��>������+J��d������
��_�E�F.�w�gC���d�X���Gt6��\C��
��*����������Ds�W�H�c��9f5_�J}i�c��7�T����*BG���,���N�kZ���m�}���?H�`�g.;b����F��*��_
G	I���F�cU��*^g�j�qV_v���Q^��� �n��$Au��4�*���,�@g���P�CRxU��[��f@_y����,X�
�$�j�������lf�V���dF-�Y�����#n]�����tl��k����48Z<��\����DeBA��E�T�AL�$`(|�6�OYJ��V�h��Z
?�����'��d78Q�I	.��%��L8��B�����'#0�H`�]4AY��� �$;���gco���F�7	�F�W>�P����
$4����II��������dg����,j[�f]�P[�*5:�B[b"i���aL�(Ek���K�B��q$�f�#P��� �\<�"�������uA@�O��E=�� ��F����	����,J�
�����U����P�*)�	>�2���&��g_n�c�J��� �G`�XF�� &6��+��zxD�����[7f6�\�)�V[E��t�U��U8�1[,N�vp���s�ep���V ����W�XRL�0Q=�G"�P^�
@�Cv��Z��HN�%0]��.��(�SQ�,$��4�f"+Z����-e�
T�=(_���W�Y���������^A@�����P	2��dWE��_V�rL~���R|��V�n�[77R���A)J?j�gXTJ��QO.F)q���<S1��>�)^����'"������ZlDx�uk��}q�2]�A�i����s��������4)}1���;7�r�f%�b�Yr�$
���I�u;j��R��2R�w��w��#$�$����~���j�<N���y4�����f9�L[����i:p`��k
W�����&������q�'��9��d�q�^���%L�x����8�l���y�]����E
�!�&�I|���~���f�V�$r�"�*\r����������k�?�|'H�/������k�G�y,H�R	��� ����e����H�����z���]������nt��'R��S(K���K�
0�	a��$z��/N����g�Iu������������\����������h�E�rq��|����{Q/u�� ��F�g`oX�����_���89����UG��)d#p�?���f����n����S�����~�!V:0����^�a�1����J����c�0j-�g}�!�Q�+���q[�qd�&<���.|�J	�����/_���
Z���q���-���8f�
_���n���P6��}.�v.�����uQf�m�
���\�����K�N�(��:79��*�����Q������5���4
�Y@�>l��335�ro�6%n�#>r�`1�`z�@����F���e\��at�|����#&V���
�N.[����2
B��d��H�W^��'_JFE�1�Z�b��X�+h�����v��G��;��������`����
.�5��0D+�	}n[;���N������"��.�4��U�X�{���(U��;�c�
2��09-�0pj8���]�"�$�i�z�e�w�~��0
&�a�98����L�JW����s/���FeB�Y��;n�(��y���l:����y����Sn���c'����eX!�V.��p�M��]pZ:y>���Y��;��l���;�����	N8�f�+?���J2������c��+����uK'�����.��;z�=��F"���w��
��k�+��1��?�@iF��D��4.��:F-�|(]���k���/	x(��+�r:�Et�2�
�K��1L�o���������E�+��2b�^D�{��]�Z�:q���]�	=���.�<���F�y�v\q�W�n��{,�h�������*���
:������XB�;b�kt�t 	5���,6&wX6&[�jc�s�{+E@�������@�*r������
���#1��SH���/�v��<�3I����/;�/$�w>z9N5�/_
���o&�Z�>hv�\��|rW=��2b�0hj���������*��U|*@�OX���m������it];��ay`W���������j�|qiZl-G��k��e���������^��S�,�����<)������/��Y�nA�Q���{p;\+_��bFC�������i��S��#&�w9IN��qX����)'�&\���!�S�<j�l���{�O����w�<������_���������:��(<P���o��$4=
%�|��S���K�J��{������I�6�$:/W���p�����OdtFy�I�~1-�\��T,�L�������TQ�x�s���m�%�[�:�x���G��e��b(�f��O��8�Vy�b�����x�����;��6�%����\��&J"�T��5�L���������tk�T�L��UnX3��qE��T��g=|w�0��3�g=G�G�D�q��DQ��h�49Jx�T�*�n6l�T����)�$:�5x��$�=�H���A������������:g���>���
4��������&1pG+T�����(��p't'%�s�6XR��t�(X,�Dr#�?������q[L����b1���4�����Y��'�
�=��q��ul���JR�R���W+V��,�{�1I����'y� �!��R|����e~��3U�e�y�v�q�zZ�W4l��H:�����<au���|�m&�x6���>�|���?s���?�|!�}����A���=u�p�<k��L?T�N��2�
���2�O9���x��s���W���x�������w?���Q�Fs?��������n���c*�e�!��M�r
�C��$��������U���i�<=��[��W- V��6����B��������hst�@����&��� ����W�>#����i#��o�M*����
�cv��$q�f�g�A���g�����M+��u��Fz>Nb��iG���������G�
������V3d����w�~e��i�1�����y���j��A���}F{Y/6��?3�+����K� :�%|�2B�jrL��,�H$iPS����h�"���8�W�����\����j����rMp�d;X�H����A�~���|�'�g�8G�A��}O�l��=��CO�&��F�E3k��4�V��f��BPA��XnJ��A�c&o|��<�jqrl�����2�k���q��hz>���L�@tQ�i2�;�S??<����kv�����;���t\M^��`�@��������i����LP
��>"Q����4��<|Ho���������gM�Q7�`q��e�f������#�H$r�{����vP5��_�{������@�E��/�Ue�o�S��%��F��:1���A�����n�� �;3�L�p�W!��a�>�t���=�[u��D�^-���������'��^q�R��>pV?0���7������y�v���(�k�;V�}�T��	���j��Yb�2���)��rr�6��N�.w���=�X��Q�C���(�:�3���������N�����w�`wqiv�D�w}�_�������_���w;?�5���{���:|=?�������d��{�,���y�4�f``����,���R�v���o�B�CF!�H�q��������#��E���\�g��_2�Z��zu&���=?��>�K��l�j�kf������:v���
X���?;���������[N�Zr~�8��9��k�s�T�:��cp�*���&l��iK�v�rL�u~����qRy�����q�_�- �_��1��3�����`.1���D��A��x�	��/�%�k_�}��7�=����	Y��0�_O���5i���n�+eH��U�M�-+���ip�0[�o���d�r�����v����n:�oW:�d\��1�����_��N��{hE����(�`�� ����w����Vs�]��r6L��$�?j�g~:O����c�7�G������?����v��q��Q�1EC�
wXHF�R�����q!.W.�W���<�Q�3���=0���0�P�������]������C���tI�<4����ab`����M���r���uT	�? ���K������GTr�6i���������g?QEl��G#~�HF�h��d�Q[V_��Zy�Iy�q��y��^���F��f��=�|���_��Y��=�(���"�[3��
4�<�C�������l<��s��[�q����q�A����V�q��]��r��]I��.�f��&����������bc�����i���e���[��F��'������{?�����7^���L�[e-�������?���C�����/�r���]����lSR)��W��J��pu�*X\&���>�rv������gRw����_uA��y��&�������w�'��g�xK�4O����&�_�@�N���%��g^��`�����2���g����S2������B�;�C������7�Kf�*������M�����X���s��	�B��0���ZwB��y���J��~N(H'f^��B��1P6��ZH2�f ���G��
h�t�;����q�`RF{`@B�����1���X�vj�8
P��5����O��H���nm�����{�}��H�����J�za0e�����7����L��K��}��a�T�Y���9�!]M�^���9�$
9��Y99����A�����r�N^"n����0B��i����N]�w�k��W��wuFR�ZX�S�@^�����V��d��ap����BG<6SZ��x��
��is(es%m��:��^�`��S��R�OEhl��4xR����"Z������1��1�q6
6y���"��	�BB�rd��m���4<�t�R1`��Y9�W�N�^�pu=�������q�2�[���(u����/�q���8�h�����n���\���c��|~M|���LG9�S�D��9z����G/��{��Y��������k%H�8�7)M05�u
&��Wx�Gw�l8��=�e
4�-��qN�V?�Q��������s�6+w�]\t�B��N�b���������5��Q�*H*f�+!g�/x�T:6��o�,C����� d�8,���zbU ��
� ���_�`NJ����P�����T�[?<qlV��E���x��Ot
��%���m��������?����]g�uX��T������X#��l���f:�+����o;M�n�.N�,��p�@B�q�S�I���4f=�D�.���-���KY�8`��*Pya[�h�b��n��+��M�F�U6�~�x�����P.�I����D�+H)��hn����M��~�&X�W��'����=:���Mg�Q��U������\���M�>����N����Q,��aIl�|��Mg�L�*�g��-�IC��������H�$�	��:F5D\7��UfM��*2J���lWe�2K����� ��e+I��F&�*,-�mN�k���Y������c7��4M�_2Xt�X�Ky��z����2�L���: P���2B�~)2k�����M@IDATR5��:X������K�XD����"B'��5>g�Q)��@`��(�7��>�����{d1�G/+��&c�X�����	�`��w?�o��uCE������������Y��c�G��\�k������=�`#���iJ,��?����6���u���z~�E�Q���F�H�|@��5�V�I�r

�x��f@�A�R��(�N��`�OZ���o�n�a���#���(��|���]c��[�j5�/�;i���W���I��`��gq�	�&��u	�D~�~��
�:��!�op������������9�X��z0�����dY������u#jX�RA��-�����5F�6Z�����&���`B�+:�Q7�m\4H8^���5�8��D�#@A�n�U����'	��@{PemH���:~�s���v6���>��~:d��<��#���KV�51\�I�G5!r\1�v9��B���-nu��Y��b$7����6;�wA��Ia"�M�������X����k�`�����Cl�U�i��p�P^����'��Jz��S5������.�Iy>������J��������$e�~�D�Y���v���e��{��#L�E���#�c0�V04�VD�����[g?�T18�xIH��W�������T��F�Dl����K3�X�*�c���������eb���	�$�pI����l[/n�Q���a��3E�l b�{��FR�g~w?�1��Aa%��:����"He�}�������
���!�[�%K�xQ���!Nb����*WL��|F9�v
��'8����en��t�m<���,�f84�"t3d�����c���*M>Gt\8z1#��S�$��f��@�W��Q���r
�����x%��0��@2�#T��q��`=!�J��n�.d)�#��G�������� �$/�
�n���M��0']	�1!S2�2�H4~�	 �+,G/���)�8����+���&���R�'��A�l���1��9����Jl�
��eV]��e$N5�p�
2�����V��V! -�L���$��c���f���[�l|�(���)��R�wVVk��*�o#	}����u]'?H������2�����%)�$�)O�F��9Hb~Yb���$qY�{��D�U���=8��������m�t Fk���0�F^X��1F����E?���B�
��v^�c��y����=����E�w�2�����U����n��%��;�w�;g�8�^gG�x}n�d%���G#R���]�{�F�q~@ 0oPUcZEh%]����U)N8�4�!gf�����?M*� �P�b�DJZ1�&�i;m3��kfTpY��P@��������	��u9���}�E����`��j�P)?��vJ����tO5`0��C#�5����v�����(��4��rg<�R�$�un72��x93��S�,������:��PP��8K�GqZc�\����+/��~�#���!�@���".�Y���t��d��Z�����{��H�#P_^���9kf/�m�3�Y������_�L��	�l��!s����
�lJ��R�&�a�0S���aZ���q�a[��vV-<E-&�:����H����5���V5v�8��lz`1��(�7��q�
'`���n�KQ�m���y,��k�;��2S0�$�Q�v��"����>�E�n/Ye*Y������
k�H�����V��P�gq���Dvg�?�j���)W����%C�-)������lP��o�3��;�V�j�I�z�{U�<-�4I$1�5�}�pW����J�o*[�/ox@�b������pq�{����������nv�td�5��7B"�(���tj,�����������X�D�69���;j��{�3��na�*�^X�j&���?QL�G�Uv�:�-xZ�D��Y�o�P��"K�X��� �eb��nr�d8�F�!�x�M5�?��X��BO!@��/�ylL�����X	e�H2������Ef#fU������4��Q�h��Y*M�$��&t�E�U��2��5��W��Y8������6�X2����n|��"�`��[#,��B������
��S����(������8t�(�sX�A�U}MR��&31���{�]��f��O��LnWI����|5f/�����O�u�
*I2h!m���-��Q3������3[�TS��O,}{���QI5�*-���174������V\���������lz���c���;�@�x>�^`E�'z3�FL!�(��D���������]���e����S�"�O����V�J�<1X��P�9��.��{Y�}��_�~�aFa���|PC�d��:
����w��AM�C��"ZTw���:-��t@����cD�
�R@3��v25�:�^+�U�o��-�o�H���]�0��8���y%
(v��_��������%8�q�[+y��y�+zQ��:�T�	�(�N�lz�1;��j6�v���L�Z���C?�J��y]A�Y�����gZ!�evq�)�^���<''���uZzo�������c3�Dq�$�f� �����s�`������zN\�����y���p����fU������1W'Y��	���Y��,e--4`Z�h�rh���{'�8���0�?��
2��1�oeF0��t���H�
������L����q��b-Gk'�A��gp���{�Y���kO6u
�C������1XZ�����%o�<��C�k�����NM�R7'����>ljfq3���g=�����Y��������IG^Gm>�nc����i�7��:�2��s�a:�Q�D|O���[�����i�-,��t�*�@H4�D�}GtA�T��eu9�������;�LB�M�\�DYvD��z���:���UdZg�h��OP_����l�_Gj�A(�U���k1�|��_Cf�D3JQ�[�	e��O��e����HR�C����$�����g��AT:F�����<�t.
�4��(����#B���'/��`��&S��7tP��2�Ao�^m��\��$��oh��0�f�V�G����r�E:�c,y{{�N������3�I��:o$�2�����\de�A��s���E��n Hb1p^"�-T�r�bqpR�I�O3p�e��X{�r�:�����sV?�g9��s'�1�('���D�����9�LJ&�,~b�,X���!��/r�
;[!�������������~��j.v�AE,w����T�i���G�D���p�����y�����q�bdG^.��-�G�����B�*��{"E�Z�����L�*L#�nL�;�a�U[�j`�b���6��Zq&���EL�P������H^uL����	���q:������7>3j���)>�S|���F�����,|D
���~�q�������p���k�Q�L:L���F��������fs�9���4�]�H�u��'���9f�0I�xI���/
4gG��� �Jia�]�6�
�s";�ih������%"�j����D��O�xr��Kf������2�jMY�0�M�b�:�K�q��f���~�@`�(��b�
a�n+�	%v9�IN��4�VM��J_��4�}R[|~4��~r4�!v�<�M��yP��e<tR�,z�@]���k��D�5�k:'-�]s���~8xfS��^�]4�b�����`����f�F������T����������%�-i�y����S���:j��.<$7��IQ�na.�WnP�?l>`��!d1����z����/EX#6����>�r����s�Y��������}C~����	��y`��q�F��b��jP��|�Q@5'���%��rH��r�G\Q7�.EL��2#j:��V����N~t�Q��Td�B1�8����mU��(c^��f����d�
�AQ�������Z;_�r�H�Xu%BG�A5W��$DC��j��S��l	E8o���O)[�����R�ed����K��Y�%x��!��'���9I�U����3ia�Rt�*f,>�J�T�S�3���] )L����*<��W'aV&n��������h������^j�I�����b�n���r�Q�6�:a�1����Y�
����bJ��b�0�\{C��)%b(�UC��sX4����������^.E;�:��hrC��&C*�v�QL+M�]�xu z�VX�e4�R�����R-�?���j#����������0�t7��_���x=�?�'�D�n��V�L��\�Q@�a\�[
�����N6��b�s��'�6��;�G�Q{��a9�?���*�dfz�>�|�/!�Vl�6��
��<H�^G7��!����%x�	�h\�R�i�����-��������]�u�����������F����Y��nx�g��l���'p��a��@�1��#����&��F������o���G.<v�������:���^bN��������?�G��*����D�`bQ+������hR��bhxn����q�8�M��(�3kE�����3f���q�����+t2X�����k-����O��~
4�E\��d���<B��*L�&J�P��������@��2H��_p���b4f�R�u���������|e�EK0���vo�n���i�}[b��JW�X4��Z��1O�i.�������|����!�4l�{����N�k$�F�tS�����f�@����6�*�Q��\U��^�@����b���L�B��������@CY�1��2�a������80�3���-��"Jje�r7^Bq�H{�"T�0�����S����'�Y�+.������3���h�,��.�}:)g���gr�^���v��DI�q��t8g
�V�+J�By%�,�z_ �tbrI����5S���X<�
*qT
I���kBzv_��]"p�!����	�N�'@��lv�a$�?L�bhA�+2�}��,�����(�=lc��("4tV����=U�����@������C��+Z�����������,���@a�c5oK�:X��O�����D,��~`��;��"��*�X����Y��7&_g�	��f��/�_�]�ZE<Vl��0c6�c�q�����UJ�wy�NJ�Zi�D	e4?2%�h��aK^���k������&}0-*	���X��q%[Y������k2ce��������A]X_�
c'��"(���b+d3gSH�O��q���bUup�V��|��N� ����]����v����o����a�K	5��@�1"_�}�����Q�4�["K3ac�VP�W5K�g1��
�O�+[���y�����|�Pz�����	gl�C�����r@��)�#C���{��8A�2��t�$��g�T��7�hn%
��L��6b��!nGHEq�K
�����z�8&����4OGbx�
�QL���=
�73F�����Ij�e�c��!��h`�B*�Z���o��y���b�P>� ��p�c��{VT��&��#AP�n���.l
D�bf��D�a�1�v�`��dB�Q�����p~�t��1c�T
��]hO��������co�j����lO������IM�6�0���d5��/Z���� �����d�����!����O`���7�Eh_�d�!��L�h�%��j�e�]�M�z���!���>HG�A�^z�]8���^t_���ZAR�w
X�%J�o[������{��u6Jg��h������*~
t���`����(���-��z @�#e6� �\���2v�k8�\�~)��������� 	0I�{��lq�M���.��Ui�[b`^�@9��Z���s��-y��J�bl�a��I,��q����<ac�R1c��>m�*��26�L��9C)�g��Z��xH��.����|��D��u�Z|C1U#�*r
M��O����.t��D�:��U4H2�L(�b�wg��#��
��S�w~���8������(���_)���G�n��}3��r0`�}�S��,�-�VJ����������Aa����� ���j�����`��o];�����(�c
p�]*��h��(Ck��	nUY'c �)���,4�
�&�[�y����wsh��-t�}���M�(��g4^�F������wR��bY�|�b����;G���2~��g������js��`�p�.;jvy,1H���XD�}���\���w�1�e�A��L5����nw��m���!�1�$�D��$$�bFQ(�	:��@��@�� �^�~� B��H�����������sM�T����^U��{������]�{�]w�����7�o}�[k};��������w�y���a�v���Xf�/�51�N�4N��*L�eF�n}���rk��������4�#�*�����aB?�����y�&�S3���|������������������O�
�������Nx�}�j�� erq�/���E�R3	8���.>2�z��I�j�����G���)��/~�o��%��n��L
�(\���r�)��o�m���j]�h8�B���$�mx�`��[���|�����+��[��C9c�� K\`q��`�,\�����L
]O�!�PXi���Z�M��&Y��@�W����K�����l	A9����m[�.��5A�F�I��I��gc�E*����.	����d�p��G�%��:���K��$�JtqX���vs�Z�r�Z���t/�T%9Ji���]�� �_���U����7�_��3��[2���/�����5�J��V��y�@s����.�I"�m;b1�*A���|��+W��pD88`[��X�L\k���M�����ka�v�%�ttu���K������)��P+\8���I�������J�N��L��d�c�����1��i@������S��~�X��������i��:]�����U��(
�.S`�o1��_��_'xH�a�����%�T�>7K����^H����}@
d�����.a����^"�I
�C]2LM0����<������#�2	��1sd����t��
��
�:i�n��^�{M�a�������[�	w�`�WI-��K>��~$��ar�����Z8b��d�&Z:1-���R�TV���G����\"��O��/����Ok��8}~7�%��������ady�N���Z7�J����9��E��i�r(�jO48��p.L�s
�$q�C�@`7ST�~���X-2�NZ?]���Mm_-�,��Y���[�F$h��:�aBn���<1���������6�	�g1Ts�!Q�
�e�Z��{����%K/K(�����OCy(�e�#�G�$�WQ�_��kN8�2�%L6=?�G��{�A@��1`56�a�
��5�}��_����(����������+wv����H���v�3�ak��{�m�Y�T-
�s6q%>�4�a�#�]-�C����{LK�� ���N�W������N���ZK�]IA,[+����*���'x�2�������O���}}����8�O?�t��\A�zi�x����l�l
�	j�^���;f�c_v���jTB�F�[e^�"�:P��4|����������H����cl�[+���97� 8���1��{u�>Bwx�5x	����4���_Y�^��a������	_)L�FAIjk[L�$4Bq����Q(�8�C'	fCm�~�[�����u���pm]�������"-�']�����H�����Z�jhe��G^
?����X�%Z=T���Q�c��6��oz�,�l�6e�>�:��Tk�<9����]��V�U����A��E�[���S<��8�Bg1����?��YdV�P-���M�i�S��M�R��F;F����8q��{��=��#�@���b���W�m�������.��a�1M��w�^P&��fW������*�����!%[(H�����y����?z���Y��kP����p��w	(�yW��0i�t@��������>����l�9��N!��x���N�X4���������������k�fpj��	�H����7�t�L���ZB�#��FNI?i�N�T ?���UV��Ru��z�V�����
 ����a#H��U")�=xV]��Q���T?��>]��^�����V��|�qs��~%D���~e���4�|��1�4���!�6����n��G���7o�{������j4�����8d��`�������'� |�d�a8�+���,c���%7{��;�wyZ"���`��Z����.���+2oD�o�
iAN���
O�/����Z� h"�H���P��P%�\bJ���-�0..%�6�	��2���a�f����/.�^-�k�m��-P����sQv�d'��fu+>����"y������e���G�����c��w�j�����k��C0�/W�
������Hv�o,'����M2�����
{�k������'�n;��k�:R���k�����w�%� E�}�[a�����%���|���k��p���0_��)���I����T�2���XKP���D,����W��\���^���"��m�T6[;O^��b�8�3Xg�o|{��j�-�r0�7d
��	xbd�kH��G?�N��o�������m����8v�$���8����>DM�H_������8{�����}�8�o�o2}�����m\K�G0���e����Y$ZK��P�j���^���;�W.����L�n�J����E���^�[o�vB����U����rg���>��g���{R�-4v��������
+��M+������v%	�/�5�4�Y���'�q�'����kse���V������45��+��v�}{���|�x��K	Z���9H���	��Z��*�k�k�Zk��*\��\nU7���sml��S�1>`.��o�wj6�����]h5��!�p*k�����;���P�z8��0xs��n����Gi�"�`���n=�����;���{�������-�T�Ov�7�����//:
��+A�����}���4v�l�����|�)�R��W_�t�����M�'uh�m�i��n���t���I�
�^o��K������n���-G�)�]������t��7���1G7m
�8�7q�����{�����k�����=�����j��Q�P�W���4����X~�fJ;��GH�Q8������n��o���v�i��	�p��GA`6T��r�m�i|���iH��?�6vCD�������j�������m��^��tSxn������j�C+�c���;����-0]��+;I�l:cA��,�x=���Q�dY<P�M�����T*��n�����k��\%n���������A�F�����f����C$�)^�r��h���\��^��k+���k>h
J�K�{�D��8�v[T$_	_:����
7sA�>*�g7���maa��������W��u��W�)�XS�mlq�8
��@���7�$����<B��u��.��`@^���Rm����{{��a*-�Dw�������Z���D��k�;���Y����*� S��/�}sp�]k�X�p��^����o�5.�_�/;r��p/��n.m��D#VBQ���}�������
_D��-t��HP��yZ����{<,_*��To���lxw��X�5��nX�U�
�(�����s��Q�����=[�/
I����[�V����*����5v;uxG8����U�v��'��Vq��Ry/������Y�8m^��"0(������Zm�Uo���M���tO�����y�Q�ed�ip�f:��^����v������	���p������!����)n�mk�����=������S�V:��
�����^mJ
��X�,��;�k�������^�K����9
�lUv6��/\XoU�q�������,��8��~/h��]D��P�7-���n������Y��]Sf�K�����[��Z�c����[K{;���`�="��@��C[	OH�S�}}�Ca����&�`��{e#��T������N8�Q�ou�x��r��~�����rA���k+�� [�]��U�8��7������q����j��s����(��z�>sa��h��^p����)1������!���m�d��e���j�$��j���u������
�Z`��	v������Y���A��#����n����6����v)H�I�ul_��%q�5t���r�S�j�v���~{w�w����v�Q��UM�k;�����a�!r�%4�����O*�f]�y�"��	Y]aT��3���>���I�O�o��/�;r�&rIi!S^�������F���$�:�7�k�:����H5��!�Q]U�x/��,�����[k��>��[����l<��\��\%���%9���[����e2��
H���%��5����V������X'���>?B/���w���D$!S9�|�����[u��-�/�r�j��R�c���
�j��+!]��2��J��b�.��
�A����������+� ����#.��������-��K��bo7���jj�vc����E���9h�62��mW�>F{�)�say�1�������W�>7}��w"���z4g>�p���to���/#"�������v�6��m�Z�VZ������e���������|�����/�n<�$�����E�[�����-u��J��5<����J�fK�U����D~�LS�[��}qe�Z_�-����Z�B�|N(��m��+.���o7�B��"��p����~�������xp��ay���)���]����!�va�����=3����rW���"�9�v�nX|��"u��f�we�{V/����K(?(:��&x�l�U*Vj�E����{�S�c��w}����^co
S�]:������9�����Y�;+b��n3E�K<2:U���ns��^/�`!r�?���@���\��`_>g��//_j��-���;�������<S�>p�����a	�=�������:�
�����#�������<�Qa��������<)s�+k��2��3r�$��M+���k�l5��+�����������]���v�nS�vm�}|�������XKAJ�wo��������p>��CZ��V�m�������H�F�d�I��'P��&�!��b�a}Sd��=�?��g�������6��t�+k��	�p���t��*������286�U��*zCJ�{�-�*Xd\��������H����v���>_^��^�)+����uC�!�� v:�S���ZR�����tA"[+�2�=��g��Y��
����v�W?���������}������/�8�}y%�{��,]]�R��U����J��V4�Dv�'���{bh#6p"tjs������:d�r���������,�s"��U���}y"�@H����%�~}S���������9�����p�U����O�����e�}��g3{U��u�5��h[�X^
)��<}��J�|�~/����NX���z���.]��~�
���C����|��+LO}
J���]8��|`gk���W�y�J-�;�����(��R�g�s)�\�&�[|{6�	qV����`��^���jL��������^���+�%.G��������u��[�:�&�S8]���������z}�
y�������u���%;aWlo�w�j��%q�=K:�P�N7���r��u�VH���C�+���m�1���w7o�d6UR��M�K|�@}�#��d@
���}��k�P��;�t��k>#Z	G9��x�x��?�����|c�������������\������^�g[*�,��������'U����;��������Bcz�zK���p�.����w�����:�����!��a�P���rg��FI������Y�b
F����<��{�$�\&��!���{���kw�~ss�W��yh!��wn_2���R����5n_}6i/�n����J���:�%���C��l����{�W����=��ccU����U�����R����l�/��~c�z�$LY���Z1?��Z�\j^��Z�];F���[-{WwW,��.;�����/:�^^���h���>�#���nY����<tw�\������+�����v���_]����I��CZ�k��^��~�{py����=i�;�7�j+�p��2�<R:�xZ�H���r��I������V���\�]-])1\�{��>����_�fS�2���h5B|���Y�t�pN���k�3����#�
��\�0�AL��}4LX�Dg��X����Z��$L14�Jf*��R'LAB��br?��+T<��A��Xk��
��X��H8�B���C�$^~����9�n� &�x2���g�8��>{XR���>�w�7�}D�x%�a[� ���0�� ��q��qyj�7����L������]!�@��������x-���-��t|���R�<��#8�>a-��������V�=��<�����.��=I����]��=���0�H.%������z�s������������n���4C-d?|�(
G�����PHqH�G5�h �58�s��nh\���U��g��.�
0����z�5�b�w
���`�'����|�������m��v�
u 0�R�	��

�L:HbQH7Q2j�	�p�]x��?^��t;��1T��N�	H&8��@�T��$H��~����H~�q,�t_�a1hi �4*���������r�)����~&pb�����
�������$��N
�!����$�$
���,�ZV7\4?!�!bN��POr|J�!���&��#o�.P�i�9t�=��r�2*6���w��+�qKhOv����-<��NH����T7����c,���
p��z"x���`$����Rh�~�:���I�M�z��>����t��P5����S��u��*��t?�t��1��C��L�����h��:���ct��ay1��}(w8$�#:�����z��h���i���0���~�?��{��������?�����B��?�p$�OJ���.X�`���_�*��w��}0�>P
H'�	L����������c����0-���8�8\���
���O��k���S��'����#KJ�7
(8Pp��@���
��@��N��^Ik��6�O��������v-�4������9�3�$r���u���HNz�g�l1��[w�C9���:T�ovx�B���l��x"Q�w��%�u��N_�J(�����<T�Ff�77�/��D�"��'�H��~�Up�O�����	��@2�N�p$��U�O����X�#�E
���S%)9�i��O�"	������C�����U�!E�GI)�N�F!!�L��Y:8��!�����R��.�x��G�5�����sx$U9*���)�9��+S���H�
�
En�,��d�^Rk��{�"7J�6��G���_�|~6�����7n��yp�i�������C������o�������:����C����r�/>���������}���c������2p��S����W����9���|03�1�����_}�Uh���B�K_���%
�D���/K���'p�.}:',�9�����a����m�Gr	$�9��}[z��Bs�f�$s��.C4��7�to��*�O-�H!r�]�=ro�'9&�:�;��I��
�`��{r�O�rt���+,���i%�
����4�8�EF���S%$:�*�O�m���1$@]��{�.�I���DLc1�(G�{��6�\���TM
�!���i���]��8�0}�9���&��������*{�p��T$�"R�q��V�3N����y:�N�r���p�����4D��~���H���L��-)��d��N���4���P�"sCR,C��tx���G�^���M���-J�F�bGc�r;��9z�����D���j�]���!�HM�o�M��I�u���s����|�#�	C���E8=����	��O>��n���AO�z������jR�}��gX��:�����z���^�e#��:*<��>@���!����
|��./"
�J����+a��m�������B)�!�g�0�^�T�(��~��O<�b����L;��p6�P9�g�1�:��'�h%����l��E3�!�S�3cC�g
��z�@�����4�@�A�
���Q@/�G��
�Z5ZD�(ZL;���Q���!,O���sOd4���!E�������+�,���r$��{��g������M�qP`g���:����e���1�
	�?5-�����M�wtp������!/��=��b�Q�����������������q��A�O",��[��#���7��O��dL��i�
	�! jF�����
��j=K�v��v�"���Qb:T���"9
�
$�B��}^x�I]9����6G�$��Q����(�?�K	Q�KR����=���{3�7
�7 ����jFM��=������i�,�3y����Q�$��t�K��z����j:��K��6�v&On4�d���A��c'��O4H��:�l�:�������S�7��1�a��C�v��(b�������t`���#x���P��@�L�������e|��0���?�E�
�Q���8!t)d�"9A	��'�����5��<�E�evq�"���_qQ�h�<" 4�#�����hQ����I���!��<%���W�2��s&"��(��94�:���"�P�����_5�#���v�S ��#� ��7T���Do�_��J��:*��(Bi�
��dp����� �FAX	�I
���x�/�`rr�t�@!?�.�B7'��C�O7��9��v�Q��&�g�Q��qb8�E!�`>I1�h!����V���8�'/P2��?����W���������F/}##T+�TD�[6R���Vj�����/�0h���}�c0�|���J\9@9���(��t�]H��?����rh�	�K/���s���o��o|�C���������)
O�<R��mC�YO�CQ|tN�'?]��#��r�T4�]�YD9"J�&���O
3���S��6����MEqf��=���*E8V#� �^��!�+r5��"�:��R0 ��a�b�~���D�@%d��#��Fl��0k��)�z�=��f�����E��[)�����tH*���_�P6��A�Of�8���/�hpeU`sBE�F�%�����fO]�;�����f������z+���� �7}���F���IR�4TD�����}��e���<���+Z ��C����#�W�@9��=",&"J�[J��9$'"C�"G�@��?�y����#F�M�*|�7~�������>zY�l���
��Mf�_y���Ac�>���*��_�UDE�&��[$���\xn_����h>��O��q���C�J�)�S����x��CB?�7z8��20.��h2a�|(t��|��	[ir��@�F}]z;��,��q�	��vH��(��>��!�"��������o�+���}f�z�a!��D�����D�o bf;�M�#,��
���'��'����#�P��#��F�A8�!��bo:CA7���`��B�
�T��~S$�O7����
T1��q��r�E��!�F���C�xn����@�Q99�0�!ur��x���`�Ca2C.1�F-�q���������E��g�NQ�L���������F4,!�Hg��y�AI��$�S!�!�� +�<NT��T!�3Z�!�3�|d���`�����`.d���d��D�#)�89�@,��m�JGU2�?�@����v)��z����9z�I:F���O#)C��Q��t]	fh����9�� �pO��j�5c��h�'��mC	�CV>^��Vx�{����\O�(�B�>�h�z*��S�&j�"�_���02�b8������?rt��SG�%B�Q4g1����]���9$�>�@IDAT�`����^���H�n�9J���@��&B��7Z���z��L�!I:0Gu���#	*(!2�RK�9$�!#��0F�J����B5L"~�7�����sB��+������O��50O�a1�h����
����B4�����������*��Cp("���
�@���)�=��-(B�B��7���
9����4�C2���~��8\���y�d�1�N>�3�G$!L:�w��{"c�;�F!�+t�N��sr�@�th"�hd�<�cJ\��P�h�I��rh�p�\���s ���2�M��7%�b���Pd�Bc>��y���:�{��42�#h+Jc�un9*������������"��L:�2 ���a�_:��'�G|H%'��@��@���
(8Pp��@~8`^?�2zcG~-0)8Pp��@���
(8�+t��Q Sp��@���
(8�wt�%T�Wp��@���
(8�+t��Q Sp��@���
(8�wt�%T�Wp��@���
(8��9���HP��

(8Pp��@���
������''���E�@��@���
(8Pp��@N8P.�$�.5�;9A�@��@���
(8Pp��@�9P�����
(8Pp��@���r������0
T
(8Pp��@�������o���n��*8Pp��@���
(8Pp`l����Zo��
=�^���@���
(8Pp��@��u�kk���������#
(8Pp��@���
L���[���VE���N�
(8Pp��@���
D�J��b�F�
(8Pp��@�����@�@O���j���
(8Pp��@������]�}{s�������j|2q��/V*I$}���
���^���n��F���ru<#����$'�����v�7�u�~���kk�q��
(8Pp��@���'�����	5�V�{���n����r�W�wB��1W��T��D�VK��U9��W�G��ht<��{j���Ziuu,0��M����|	����y�:���Z�A^����O���F�W(8Pp��@���
� F8���������^���f��������52�������h��l%������zFg������_��}���rQ��@���
(8�u�������������5^�{�����;7n������>�\�z�w��6_�������#�?�JQ\p��@���
(8����pp�lM��}��W�>����>���5^�?�G7���._�|��>���~����n��u�V+}��]������[������� ,//�����V������>p�Z��~���;��������|���|����&*������m���/�����������~�����~������]%;;��	�_������k��<i������'��J�����=E.?���{����w��_x��'��B��\p��@���
�z���t����������������O��W����_����=���������?����������������W~�go��y��X�t����o����__/�w?v�����������[���k�������oW;!W8�S�\d���������+�����O�����?6�gn}������f�������|��\���6��?}�����_{������{���9����^Z�p��Nq*q*Y�(8Pp��@���O��@�q����_�+/$���/�����?��g����������7o6���������/W�������~��gW��{�}�w\u���<���o���~���,U��K�?��?8p"��w��+|���G4�%y�����������}O�����������}�H���J����k�/>������7���a��w����O�3�?���?����?����W��}���y���"�G?����
(8Pp����v��h�LY�66���������W���}��������O��O��[���?�'��re������(��?���������_��������o�#}�6������������WF
v�@on��zjY"��~���>���/�~��_9�m�����$�{�v�k����������8��R"\^��"�q(�(8Pp��@�����90�����S�M�n���E1�p��}�)�����o������_�j������������my9�e������������������|�?�3�F��_�bzH;q��e�3u1�����y�+_��I��~����u~X;���W�b������������p^|q�
��I��bq_p��@���
Xl�v���M�Z��(?���cj6:_�Z�=��������������?�����������\����6���_��o~�7^����.��Qv��#���M���^��z��?D���x��bz?�iZm�
/�������v'����@�������[�\�^�����]�u�w���?��o��q�������_�b'�:!F9���������o��]���K >���C�{���!��W�q�S����
(8Pp��@��a�p�c����V�>�_�u��='Q�����?�������1��|O]�
G�yf�������}�s�����k��}����w�8}��~��="�?[����O0{��$�z��)w_������tz��q>n�����V�}�cF������^�q��_��G:]
�/'����k��]W����k�����O����CO�����M�t�����g�]��o����+�lx�U���G�~�����x������^��?���'?����o�������Ol�
7
(8Pp��@����(���llL�3Y�����������)tk�����[[mA��Q�
qo�cB�����^O<�������#d���lV&|��7��8��cD�7���qR�x��X6���/B}�I� ����"��-:�?2�**(8Pp��@����>8������j�������	�/��@��B����[�X|�����	?>�O��
(8Pp��@��|r u�G��O
��c����q����Q>���6�T�n���
(8Pp��@N8Py����"�����wwwWWW��P\.�<x���6my��!�����M?�����W�7o�)J%�����g)gee%�������'��~�r�Z�������.M�tww�������z}gy��i�qpb��N���T��Y���)]����_�����F���D|�o����+�T*�;�|{{������V��v��~Y����U9aZ��r���}�QJ�����wO�������goood���!h��w/�s�?��5s�>)���#C(r�	�n��������/�u�z+K9�Rm��	���X�)��S���.G;������x�p�S��,Ws�d
����!#G��Q.)>�G�cH�>��t)g=Rv������r�����������88�Je����\�V�;��b�H|�-��2#��\N4X�K�% 7���HW�����c�k��r�i��Rm�K�|��8�#9(�?��H`Z�S��;����aH7��[[[Y��q��>�)���^���O�!C����/"�������#��Y����9D���|��r��
S~b&����z� ����������X�����!��("DEw+-��ioz���*���4��*�a������5q������N�Z���}lw.���<�|�h� ������S>������������yD��~�v����,V���|�����)O�6g\�j���A��+W���'���3C9��!����
L�O�7�#�hG1������O�T�����s��������K���.����nD�}y��:�<B�s����<��1�d������t
�.W��7���%�o
?)O�
E��p��	pR�pb��rM��kW���r����z���)��Ewd�N{��fs�F}imu�b�Y���})>�f�r8���7���gz3\�of���������s,Gu�^���i��_�l^'��3)rO���gz3Cy|���k4����<��p������/����[L	�L��k1����r�R>����2���[�K?]o$]�-��'��E9�������@G��gn�
�x�Jb8ga�1!{���?���;A�D�hG���Y�|"'���<_�c��`�f����sW�C4qh<w� �R�������0S@���otz����z��X��<��('�(F:F:���0�-��f��a��s�1/9���Nr��!���l�|���,T�q�W9r����B{��q�i�U8w����I��C~aFY��a��������E����k�0�
���(I��+d������d
�!<��g��8�d"��Q����C�����~{al5��f��e����1������"����)s��!���o~�S�:����
(8��;���t��>y�|5��<�������s��!Gh����9�8M�&dke����t	��1��@���3��9��	���q��-�N�X\X��-��P�oS1!���������DG�8�LA�K��;t$9��}R:�"�8�����.���f\.9�orF"��'Y�?[�MN���h��E�8ORN�NGny<U���rl��m�x��������r>.�h,#�	����o��>�FN�r�lY���/�w��$�H�0�E�0��A���8D�
%_�XYrP49g�@�{a�K��t�x�����Y ��q.�h"	��"�4���K�
����m��r8���:�q�E2����P���;��]�5�� �i��{]��(��!B�Z�cR�i��a}��h�ms���(�*3�����I��0G�H��0��A��_FQ��f6|H����l�b�������W��_!X�s]��Y����
F:�����+c���3��tB������O+�62~��`i���$W�Zp���<8���w:��_�\��0
�S���!��,�Vt3�E�����9U�a��>�,E�w&��!���>Q:BCZ��Z��2Z~s7���) ���������d���������f��C�������A���4d�ea�iH��H{�Y1+����1��0��cYpa��\��E����d�(��,���\.���yv����X������� '�tf��o�����-R��`���V[8N����tL�����@��@���q���v���������)�p�������&uy���1sB�I��r|�U���m�,�@�Y:,�"�l������S!f��:��\�[*�9�k�!��	��8��DN�z�z���<�����q7e�Y)4+A��,�����[��;E��Jb��(����:J�����7�\���s������gy�s!�EJ�j�p-���(�@����A�S�����/�����cND:;0�n�#��4�!�����]AO���3C����q��f g�!B+A�\��9	�y�������UN���j�:Z����{l�,O���\<)��!���I5p�pm�*t0��>DX��>]
���"�t�:����-M�����������O�:!E�9�@�:G�(P)8Pp��9��q}���j��8��Sge�`����a���%��39)���K�32F��i�������f��Si��y:��N��O:CB���Ic��"��w�[�l��k��s�rD���f����g[��NVrr&�atX�E��DS���r~J�NO{zm������������I��9���x��{$q�|;��q��N��!G+��}���SCo���1��04;P���VN�>[�H�-{hL�����u(�h��>M�8��X�,��6�)�@�����t�Hnu�U�7��2����l�Qd��
��0W�u�"��^N�s-�~��X]�����������{��p���&�yv`��q���^�'���^���-�t��5p-�sR-���g�	�G���\�v��z����+W�EvD��a��o�a�����������6�/L�9&�b���!��
��E�b���m&�!�\���g��U\X��-C�����S!�L�Z:��]�-�q�q�<�S��iV�f3$N>M�mkrFD�9LO>����P�I��HL[_s������c�0K��y
:0���>��o�t �y�t$�Y������#�~L�%���/<����(�tb��,�����*�p�y{DT�,��%d
�E"g��@�CMF�B�� �1�d������������8�����Ol���d,�FLc����������_�Z�J������i��u�?P���I9<��v����k����m��f�wr��D������g.�p����&�>�P����?��s����Pn�s�r�����P9l�s�r���>,o������Y9
�����i��gX���"�8�����g,' �J���������(�8*�?��m��V�8��p�b�����_�Q|��u7���\�8����rS|����k�+��R��#����Nlnn�,�#��\
����a��������������F��.���������7j��r�������G���hvR1E�����r����R���\+5v�+����P�8�,0r{��W���}
�r\�K�S(���"?�Bb�i�B��!�u�~��U�r�/���G���J}������>#����u�v����rr�����p}$�d97�(�@�X�	i9��'�M����5/�)�W>�]��";)���#|B9n�O��.I}Z�^;v�0�p��V�F�����t��~�����"Bs�0i�#�kwr�������s,
C�T�B�9��3��@��3V��s�r�F#����!��~��F�{+-�&���<�Lydo���\5�v�M�G<��7�s����#G2a������R����>x1���~Z�?i�B��O���]���gl��oZ���_�'8I��r�������[:��h���"V)�����~4���g??�k���P
?2��Yc
�!��L���0�����m�N(����P�p�5�������5���!��@2����7��#��97Q�n�/��T���[��W�>���&���Lo0��!G:�_�W[i5w�r���<�X+���k�?~?��=���&�{=�	G�p9������b����?�\����S�?�l����rN�����	pH3.~�M��Ao��r@F��/�?K9���~��{�1����`���O(�x�;P?�����������p���\��&&�����Ig$���k�(�H/D�8��c�E���6Ga�R:D��U����9��y���?������
�5�htw[�����/�/UOdkV�}�rp<�ZY�n���T�_p���\9`�06�\��DS S��PIE��L8���LU�C%����P�}���y���8"DTca�O��p4���r��;rf�����&���<���) ����^�X�E��DS�����Y��L�aX/8�Ko���HC&ZH�l�:��I�e���3�����O�O��qcHgah}��=N�y(g���M��`���M4�b�AU��k������7E��k��A0�N�-�p��82[l���o���O}j�)h(8Pp`�8�F�c����o���\����]�l[8K�
j
L����l���9��01N��4��CS�$��m�w93�O�f�J����D5�����X��W��n��a��C�f@)�,R���f�f`E_a����v8l�!��1n:��0�k�y��W��q���D����vC�f ��s������*�T�!�)��1a���YD���R"�Tb�me�8��on1�
1}'������V&�x>=�N�X<�>�[���P��R���c�S�G��1nQ4c��tX�<���H�T���O������H������n�g���-��:z�S1!��Y�E�i��E�2��I9�d�����������T��p�5�`k�:u.�T���"}�Z��q������}�J�V�o��g�������-���A�D]���s����^�eA;R$�_�M�����/�h�R?#p�cYpa6t1num5������#���|E�Nb�� �a�zgW��C:c�t�AF�����l;�+���0���9��0�H������O+f����z����~���V
���:A��,�t�d�@?�V������I��g&�(8�r@�w�C�'�he�H[���iZFiD�R�9�7T�t�"��;sBH�:�]��1n��aX.��tx!G����#�A46�<�����L�����,��&�"��i��-[�����[8:�����-��.l�0'r��0�4�q-L�}��28m?9���Q
c�,���y��H�25�V��������4�l�@�i���'�db��T"����>�FY�,��6�)�@�]I��H:m$��-�����N�{�]�s~sd�b�b��<��-������_���������W�O���f���^������������6[�k��(80���)�p��M:���V��>dF��u|�U����`{.�@2#w�����lg�[-H#(8��'�Vi�b����W�`�<��Yv����Z[#��	��8E�	�>�G�l���g����g ���kV�:��&tB�n�Y�^9����9��,�	�l�r`���������r�ef�bV��I���y�3�*�0QZ�+��R���1FM3P1�@K^�^��d��ta�k���1nR�y���fenr�y�m?�}���O>�T��m�l���G�:��O�"��%�q�
�X{��<1��
��C�ff.c�<�3s��_�l|��neZ�|�Ji)��s��BN�<�I�����j!;.���H�GB�"�|Tc�Pt�'���A�����Pec}������vo��,��\�*�@�k�UW���dY��}�B��5�"�X���s��:O9����T�LL�T���-ch+���y����Lj��=�;9x6C��V��a$�z��{��U:�4"�W�\����_������(�q-�h��&�9�hD�����a�����>��s��h�Ig��C���q��&�I0���6�#���K/eAJ��sC�|�rr�K��u^�=����o��o>��y���<��c��,x�`��Z�h��o��o�%�G\�g��'��v�i������{��P�7����y�q^���V<Hga(B��W�r����AH�z6���[��qs�B[�`�:qGHc��_
gE��qGZB �|B��t�$'+���k�H��h�<�g�S���:=���4C!�j��Ad���8�Kow�{a<N��e����h��@�b�����R���5����8��N���Zqr��\����
���w�a�e���T
��9������s<3�� gal��M�:������t�H��<���7�|�����Uj?���w?U{fm��}&t����"��q�h��@���8���}��}z�r��)�JX-/��0u��mt���Jo��/ly��QQ����q����<�v�}����zM���^��a\�"tvv�r��p�X{����.LTC�y��@K�k�v�z~B����\�l�C)[-H#(x �}W�����)o�S�^��y�;���$��~������7��=o�<�`���sk��@N���_�"�vuu5c�0��s�������;�i���g8^6P?-��B�����	�S}�\���rx;+������?�\�sP,���������T?K�j�����_�]�5��ny?���La��@����3�~9��t�����z����V�������>G���N.��"d�>�J4��:`c���#>����c�#�	����M�Z��7J])C���r����a�r`������?P�i�������l�7Jr��]g���������7��7���_�����L�W?-������m�k���8��1>Y�U��?���+�bW�W�m�U��i�����_d9MSm��	�k(��t����n��.�"��!��"�����)�����J�@��Y��������\���n��i5����[K���z���o�hb9-��+g=Rv�?��������j��_�u6j���m���<Pd9��D����4z���~����VV[�k��WDw��#[�7�r��t�z$>Y���~8z��pR<�S����v#������X��>���~��&���|sk��J��`{�Z�����e���W�0���r�E�r���Q2)���^���(��#|��������{�j�Z��r�ayZQ����	�?�y���O�������/'_�@�'Q�!��x������#>���3�i����w���M/��f)b|�4>�$��{2@w�+��+��rH���g(w:(=�����'�R<��
s)��?�'|@sE�f+�:9&`�3P�g�?P��s7c9�p�|���q�S�
�W��k*|�i����
��n�/�U/����[f�p��;����|�����?��d*�����W�;��?�TYN�5�� ��g�F�c�����6����j�{�/���A�Up�������� \j�j�mu�VJ^?�3�~?���q��%'Ot���� �	?y-_��u�K��zP�iD/���G�����O��50���Ga�r�1�L��������#���oW�������.O+g���a�fc��f���������!|W��v����&�c}��4�	lT��:Z��W�$����(g��#����c�^���l�,���D|�����k+}=����?�����������������G-�l�xF8��{��i����u*����\�}a�����K�VB��!5���Lo&��:�]��3�G=��_�H�b~y�X�M��KK[��������7]�1�����~�)��)�t�(����@��!]I�����EHH�2�'Z���{���;���^�SJ�����_�O���-A�l�"��Y�_��U�0x��7���a6���-3Q1d�R���f�sw��];������W��k��gV������~��sBs\����/m�/TJ�PY?���������,}x�x��06�8g��O�����_y��M��9�;��|
H'���| �)�h
���f�|��}o���F�����x_���:?q1�o����v����*���R���^���������Z�Q�����O�j���z�������Q7����#���
�R���D����e>�Q����o�Z���F��(�����?��OO�������w���g/U�+�����X�6�F����{���2+82������%�Y^��}R#s�H�+g]����q-R2N��k��E&Y5���s��{A�#V^�>�`h��F�����?�9�cf&�Yh�@Z�6!4��
���E:�1���f
fs��La���(���I������x������y���Z�oS��H#)!�v�<�k�1bv�z'��dT���1nY�@���T�L��q*D�SY�Y�<��c��AG��;�%��['i9�8��t�k
;�(�HN�^�W�r�;�N�������y&�!u���Q-����w�a=MhC�:i�\�|!�z���C
��5�VO\��pb-�*`��erx<a+`�q�jw�'���d��g���c#�0������O3[+�!��)S@:G�3�FOk����	�C"�G5*�������2Z�9B#s@$5�>`<�.�Aar�p�I{j��ID�"������g
9�<I�5"�i9.c�|��
+f)-v{Vx/��_4$�%��;b��9e�
c\��_���<��-��hv�t$�`��l����Z��>6'Z=bE������lY�@�}�A�����u��;�X��ht��,``^��v*���v K��a Y_r~Q3�UO�99�I���Go�0Rr�OnFdYp�V9i�CTV2:9�=e��p�b���fgi5���FC�j��a�q�Mbh$B�&�yo?~8${+�/���P�AA���%N`����YN:�n>f�'�:���3�������'����A���GTJ�1:N���l����3����<<@����=������|�3�9�E�����
t��<I�V����#"���~��G�C�q�01N��4�qz.����h���ih��h1��J�F�7�C�
�2��M����b��_+��n���X�HP0��#��D!��l3�lO���d����"m�����
#�14,�m$`�!����l���[:����W�|>��r9������Z�0$�_����vG�������9:m�>Q������Y0D������H�#��,\�q�f���	�g9zO�����8r�������2AxX�!��?�u��8��.���A��y^.rAQT����d<�w���8�:���}J.�-��,��j����#���[��qc�y���/Jez�~���|/:�N�"�y�0?M��w\��79G;�B>�"���1n��Fu�j����iV�����Y���q�������e�i��P&������.6t�ELQ$ad<>otM!���>
����e�lU�����r�o����n�X�H������+�����,{�%��O"<�n�$�>����d�'{r��0�z��4��>�?Ks"\9]��M��q�n�'���r�
�"t�h�B/��;R|Q)�&�����-em
��_�2�F��x��"���.���md!�X\�
]�C=[�����n�a������y��F�/-37_���4����7�o0R:,��Y13b*�������+�L���l@-��r>a�f��:��s�gG������O;:V�v���Z���{��3��k�5�$r|+l��@�e��0 &�NYI������o��l���<��#[��pr����#�fi���!�	���bn���C��[%��9������@��\l�]�<���k�"1������y�92�N������t��m�M�����"Z�XO����[�������>z�5[_z��/o�|f��'�����y��g7�����Tv�_��F���T�2�<h�~}k��������7�9�6"�� ���������F�5X;�����;a���X����A���in���l����)�N���A:)ELUp���w�W����N�-�d�(��;���GW����zk&�� �1��1'F����Vo�{����?�@�|� dBha'�al������[����O��(��!�~�������_���'AWr)yc��8�D����������������������.Z�$'|B�����o����:�;�.[����C7K�I���?-Z��V��J��z��F�]/=�'��i��E}�����������u��:�/lw��������������L�i^D���U�;�:�u������S"�������9�����\)�67����_4����ni�,'�d���������(X���n@c�4"���)�O���9�����h���n?C��7x[o/���6��c��K�j��������pu�����@�m��t�&����+�10a�{��mTBb��]�=������gt{����� G���L3��~g�r�k}��[��|�y��@�l?qpO��Q�����zk�h��[�	E�1��s�l��+fe0��a ���(���6��V5��;��{����cu��9���_4�����2�mSZ�'���_���<�L�-(�jf��#�y��1�':y#����������j)�^�������qO�7C���\���J�r�������
7Mu�e�c�WJWW�w�m�T-����tD������<�\��{��e��
A�G���i;����-�^����P���N��^�^�g�����'�C�+9+|:(�Vh
yr��T|n��5G�
�`8t��d��}������{��mjq{�5�8+G�OB����R��_��Bx?�8������ ��,ds����3.GJZg��xf��}��v���Z�d��
���e�����rr��Hm���� ���pd��
ld��P4�a���K+2�v��4���rc�a��,T�#s��A��U�	-k�������m�i�@��<�d�ovH4����o-3��J{�+�|<��#��d�z���8��Z���Sr����5�bnxZ���q���I��].�H�Q�8��q���r%|�?��
�M�M��������YhBhl
3���q��`��I���D��t2n�����*2�U��h;,��[��n_���������g���D��qUM4bE�/f�k��4�����/��BJ�b�(����f��j����@��xXg^���\���E�&�{������8F,�����=69���{q��u+/����8����P�etX�H<	�FapC'��H�'[���<�F��hkBQHc����4Q�+5�"����Cr5*Z8����|S�'���GAN��-�����#��u����&��r=�p�^���{�C�1�VE�=Ec��],R�������[��1�������J�_�h{�z���l� g�<�Z��05z
��3�1�*�xk��:��i!����zy�O���� ��P&m�6F�!�ov����Ec��K{�l� �#'���B�e�b�Y�@{�[`T��0�����d�g8N�v�nN�����	�Q����B?5q��}5k��>0m�{�-X�����<����:Lh�sA�i������I:}n�!�dB���L?�6&��3�N*1�y�u�8��K�'L���5����0�]��v[��KV�SZ�k�5V�v����#���{�%�|�����d4+#u��1N$Sl�F��(�uM���6��!a
�q��lth��dA[�U"�@�3
U�pRG��Mj6C�����������N�����b���&���X	��f�::���{��''���~P��L�&���h�Tb��/���r���A�3?:1�=	rg�b��n���
��
�����L1���&�&z��Q��i���>5)�K���Jk��@������N��2m}�f����Pl�DIzK�EO���2��dH�w�$�6�f����^�����bY�5��`�^J��.��[B�b]����*n�d��G��w&���z�X1�&!��8��\P4m�>�r�~ul�@��:Y�L�KM�q��{������@�7��H�^��9�|���t��\��@WZ�zsC����9�`/�Ze)����yxS`E�=��Pa�p"|�o�V��ni�K�Cmf-0�?'����N_��w�[����
r���u�n ���u&��a�lrN(S��Nw�R�?;X�>�^��Bx�k��#�i:	1<R���}��������D�;�������/����#R�����q�.�7�|suuU���;o'm|�S>1���j���j�7��~�N	�au�Jb�f��:��Oh���A�O7	d|�X�I;���dtn�4u%KMut�N�;a4^��m�&a�W3h%�e���3��h#T�@��{�8�dci�h?y�QGt��J�;�0��#�X���{����T�2B��:P P��h�Q0�-B����}���������~:�k4���Q:��}��I�As��?'2
��,}3E�����P?�d$'}]�T7���K��o�o7�I5T��UV��W�*��4����$��u7����)�<��?�$�����6�o�a�d�R\���T-�Ez�T:�b>���L%�A� ����.S�CY�8�w�7:�=��q�^0_�"�0�$c_�t2�sa&&l��e<����mM�I�*E��T����|{.��8h)9�e�F�N�����{������%c����S}s�-y�wvL������5��w1q=i,3����#�����a��:���u��D�����C`�f4f?�0@���� R4�8Q������x=�i�
���:Z�Z�-8l���G��d;�6���}�G�$?��&WV!L0���H���{"�=��P?=�h���\����J�:V�'��G�|�ye�;]l��@IDATT������A�U=F�d�M(�#���E�����W�?zL�q��G�k��k*���"~X:�p���obX��Q��A�{����1O�`��T��`3�z�ZntB[*�������eH�+�I�����5������6�_[[��vlm���Xq|�(�F�a���p�d�^6��x�XCX0b�L��y�%t�K����1If����P�?�����������@
�
)g�������YMY�{�{�y�M��&������(L��x��������_�����#!0�����e�t���J������/0�B
�j�ty��3�<��������\���t��;�U���=�T���.�:3t�e���_ZW3��Xg���2n�������2]
���6=d����O�
���:S�����~f��f���vR����^8���1&uab�_���5{�'�1������c�hLI1��:��6��?�E�$"��1��-a�u|5Lp�7�������u�`N��<���%�/������Iw	Lx4<����-�C%���O��-��}�;�%������p�'�1�Z��J��'��G����_Ae/]^/I��O�~��
5�;��[��%j��a�@?�:v�D�A4�b��_Y�@�4��3Q�i�L7D0�_��F�Hw
���K��{�����8����b-9�{��(F�m�9@ 0k�i���������_���[�>���0i�3�{��/(�����w�j���O>���/�=Nek�.��O�!
Z���8K"H�N��l��4��l�2n�1|HN�5.6{x�=dS�Gy�:�
�TJ�<����L:�o�����y����D���J�a�n��:|��+�sD�c�����+}���������c���K0\7��[0�acp5i���"dB�i Q�`0~x8��l��t�	�1�tl�s��O���q.����C(b&�����4�D	�,�:I!����Cu��"�3���bIs����8�pM�?-2n�H�����2�!���*�v��8�saZ��[��+F������m
�����Z�d�D�Q��J�����������a�(�!Mv*r�je�D[��g*�M�j��y��u���x&|K�������v����h���'6��Q�S9���`�L+��aL��/$#��";���Dq��Q%��GtZrF��x���^�	���m�"�P�����242s.2^����f��y�eb�Y�V�j!1�E��y�L��p}�������`��[���� A�Y��].�����z��4�:�vl�c�b1t�N�7f
��n�	�,�>�n�M����`|�`PB��=b%��8��6�����2t���AOB_CG@���!��\/}gB�96HH��Et���)��E��
t�8�Ko�~�q�d+nLP�y�(h�y�Huk�� �s�$Q~t����f�)�U6
�������<�����[����$ �m���A��ay>UY�8��
���gj)�\�&�����r{��:dH����"�RBK_������F%25��������x:�����y�EZ�h��l0�6v����<��d`Y�9���DXF��,HB/bs��g�U�/Oq&��9R�
��PX����w��/�H3"�]{��m���)����x�[8��g?���l[`n�H�[�3�P���JEb`����x���VB
�r�3�����G�:�q�$A�l?zb��[���+���U�q5�����%S���,D�T^-�=nK�q�p��=�j��D�����Qy��������\)7O����I.��1G�V���}���)�x�j$^�<>i���&��:�1o�R���-��	��G�5�l�M��m��G�@��mL
��� �������N���*NtM����c�%�����gi
c��`�9rCW�g��U�U���"�������:�1���td���������S��
W��:�p��D�B�$���,a�j��L�1"o
��/3`8����/�L&,�����a����6��1����M�(i��8�#�����c��n��r���D�-7�Kk��rKj���X��\�+�N�6����O�3\������Em���+�X�S?���G�@h\��������V����k�������6�����=�����gXL>(�/�'�"3��>s�MI������x�E<Ds�_xK���]d�����[�6��^*]�r%�kX�����F���_��D
T�D��~�-���*m��WYY�������vgu{k���e�����&"��x�D�z��0������'.����q����[!�V*������%����>����j7���9�y��|:z{�����H_v��[Q\Cr9~��2��w�p3o^S�=C�<L��L$�@ <{}2-�c�~z6?e>O��\P��
�+��+IoY/N���YdUz�*>�-N��� {�����g�J+Hf-���gQ�O�7��u�k|��OO����)���� X�[������zu�\�-��"���������-�Q��nNS���,����.�NE��tvfx�I/�����iV�H��l~<��K�a�&*���f��]���o�:����eUR�l6#�Z�^V/��n�N�K���V��f�^`�Kmz�L���~k�OV_�G{s>[�Q��a��e4K��o/f����33YZ���ly���+{��9PE�, >X����]��2+�e?���g����lP�������T���g���"<�<���
O<'N`� %�0zJ	�o�%���-E�.i�z����W��%��In>��D��<��E���	&��xH����a^���h���,�e<����.K���]8.>p���,#��4�N�iO�����eP_M��t�,���(���(^d��4�Yx�s��|~��-��O������$���j~��i~�[q(xB[���P[�#��(����E�(~e�m%����u\���r�W�����c��-�f�"e�)*l7O�c��$Wt(�r�\B(�7��������v���t��x'O��|���r>�]�p�/��nG}U_�	z�u`�������v�<)��QE!
���:$�y�6"#���'ii�i�Lq���~�Q���C2��s����DN��s�/��qg#��4�%8�:�,�����n�Wpt<)����,���D8RlI��`FlQ
�<��hE�+�{2�M��9U�L�eiVy
lkc�����|��HD
����G��
�j�3�%�|Y&SWYr�.�
���eq�aK�cV��/y���2����8�s��������8�+�2���*s|lH�W��Ib���i����iq����:��W�1s�����<�m�@�e
e���<�"i4��2���FI�eC����3*��b���P�f'E����`��e����of�Ye�[O�0���~:�yi���>g��M���J�x����+F��Z��<�/H�8+n��h�|��oz�����W�Qd��F�=�Ml^�����p�`�,�vE��N�t>�6��*����g�����Tj%��3KK����|�Mt�z�\Z7>�����w�D:}.3��e�����^v\�\�����blU�%���RL�QL�>��R�u���/��^���a�����Pl���l�4�O������s>��f5������n`v��<;	�\�08}����<\.�3�Y������<�g�� U6����������L�F�e>;���>�	O�6�*�@K!@�3R3�!���~�0w9��Un�N�"��/R&M54|�"����^g&��r�'��k�F��tvn�t��v�����f�65)@�TY<	���n]���7�{r>0�V�����$�������tV��O�n�mh1���n��!�����q�g�9=���a=yu>�s=�(������!���� &-rzz
'hy���C����,zYz�b���T��X�a�����A�i�_-�k/���NV:L{�OcQ�]�E�}{]�t��a�Q.gh�Ojk<��g�<�%'�8u�*\��N��:�S+�������
��\���dnf����4��C����	j�m{hR�,�>�d:^����~�s�Y���!~����X�^���i�	���2%���ud����#\����w�s�;���G����;�$�9� �~@�}��O3�|��q�������.�G}�43�8��^X��ia�s�
���������^d����jO�����D�������@Y+m�$3��!�s�G'5�!���c�{��s�3u�����g���8�LF������M!��I*�!�K^��� ����R���}����d��OK���F��4����G��w��P�B��@��T�%��6��)��~��������M#5�Ge���A���Ym��� [�'8�<I�#N~���R�aYW��In��9����	��14|�[��7a����w�K��|g@��e���m[����5�pZ�C���+:��gZ�Y\��0o�:�v������o��J�fjX4(�	$H�qR8���[��-�_eW��*�(�o"���9�R0���K-��eb�_e����C$���a��;�]d8\�}w����UXG��F+m
��Fm������=_Dua��	|�F��`c���X����h�c�v��������%������������������������&X��0n���=/ai�Us�<d���
2�����E�w���Zm����f�z���������>Oq,1{�eF�dt3�?��7�)�bYP����+�-G}����(���W���ii�LZ0sY@��`�*�WBXLr�\m��k����^u<�:@g�d��t�&Z��M����(~YY�zVXOx��0�N3��i��|i���~lx���i�A� ���J��	[�����|���cz�����O�Q��j�&����E�%����i(�`�B�E��
�h8�i�~����Jd�KX���:������o�&���C�
\{��I�;�sl��_��}���`{�b9�6Q0B%by��%��i���m�T��^m5y&N�{b��8TqqVPws(�H�:<N��8�]��n�]��e���{c�
�����"�o�Z��5g�09��=1�,*3,�W9<���l�]q�<)��"`Z�xMg���b�������{��	4l*B2��OskY/�5J�`S}<-��[,��c?`,���\���P��p��1~b&]�-�4D�u��7.�E�~���3�����G���r������h!83����\�1|�EF����h����}�Y0?R�R����M���Ii��D���"%552d4|�2PZ�����J����tv9f�������b�<
��^�l����e�6�iF
�O��^�j���k���y-�����|���M�k��g�L�6h�4�>�we?�+��=��	(���>T����q�b80� S'�;��h/5�Rj�5��B�/"�hq�Yz��/��y�����������Ml~2��R.p^4�I_�B�Q�y{��m�Ea_a'�b����G���Llj� ��.��P��x�?_�Lk(�E��@��4�?.Y��t����m`Z�7���=�O�j�Z��r)�M4�
p��=�al�4hSCRRMMg*�e�B�q��?�;=�I����:@�=/RY���	��w�0�E��pxhC�@���@��x�xYC0K|������Tu�&�X�_�\^I�/a7�:�9V�R�|Q�tz��zC3�Iy�����@l�W�O���a;�~���9���Y����q�t����j_�4x�/$����t=�<�B����{}D�.��?����i�����0��}<LP��`���cHM�������:t>Vy�d+�-�[#O<��^`������h���&�Y�l���:-��W�+V�����9C��n�Q<d�z����{=�v�
L�x������
,��jY`!^����};���T�^���hH���a�t����Y�O���gi}�*g��)�J].��K��d��F����j���;ev%�\���_
�t��}�S���^\p����%wCZ.h3���B�T���/L�7:�\�������zZs����]Zz5k����!�c���Y^��H�#7��������2Z���C�����M�
>g�U%V^,��3
����2"�?68r�+��+�hL\�����)1�j���x�m���yK;t�����4h,���[%���3��Q^"��YQU�.P��^^.G�������~�]H�3�����,��D=��k>N������'xj����yj���/�X�_�UmV�=�B�8>�E�L��'��I�x���Y�� ��+��XB{��
-�����	&�.�i"=aL5<t��n|��[������9vb��	��tY)��6R��yc�(���bJ���/v�!f+����J�
N&���SG��Y-�
8��
Z4H�1t`j�D���W����;���,�Zx��F��}�����>6T4�lp*/m�^�U����9\{��R�zu�N�b�+q�e ��_�^�z|7W�SL]�P'(��x@�E
P-�z�h_5Sa�?f����6r[�h�S*����>Z2��F8vXw���c�q�'zL�d��+d���Kzk`�.J~dU��W4~��������lEe�`�5�M7��+��"%fEF[0�����z�Q8��~,���n��1Q�PGP�����tY,�H�\������d[6:H?p~�P	��@q?��0�&cG?l�����G�A�����
U)i]_���1�0v�)�;k�#V9����lm4*�%�9���7f�����N/��Jh����tk�	]���B�H3��!f� �6���
�����B �����:�}h��;��0�m�����#��9+��<d,w����������@�E���U#]#�K:6�%]�D*&��%��`�-�o�	��s���q~j*H<�NT�z�A�{2r4��
E..�}aW�r���]����h8�Ql�%���aA�
8�5
��O�.G��:#Z��q�q�$�z���8�e�����-�X5���������g��{�]�����9F1��>��r���aZn�t#>�����7�(�z�����)�Z�^�*�����$g.6�Gp�	�;���8���1&��U�F�w����}#{7VX
�N�X��
<������A��(v�Z6�5�Vt0��Jh������[]��5�PTu��_�m0U�3�@
�����yg�m���=E�Y|%���������,��q��O����r2)Yb����ew��,�����%�[�mBB�Y4�xd����N�9�p'��a%��t4����A���8������[��BN���6`��_r6E�"�\���GW\�y�Z�R4�A������-��W��3�1yPe�Ek���hB�D�0];tK�-�� ���J[h+:�
d!%��a����4:J�R��8U�VeYmg	�J1B���v"d�<��?l�`:H�unJ[&�@��]����lD\�o&���p��C�LSI�6�lv����+0kX�F������s����t$���l�f~�g����1�PC��2?���H����ef���_0�R��>�Ru)j��*�l��(a-���w����	�Q�������4eT��Km���-w���U��(gn����I�h���	��e����S��G h�u�mg����$���v+G ������W�^�L�Tan)f�{I�($��3R^!�|h���M��b����WR=i>u�v�~��
Tx]�9Dy*�Kd*�D�*��P��Y��q�����p������U����lA���u�������GI��p��l7���B�]��Vt�#qm4�!	�t�;m�JB#b���o!|��z��2)��-L��b��v�����+��������j���X�b��o�Q)W2��K�����8Xo�D�R
=��"�����:�JA�sH@+���-��
���/����s1��?M��_
�f+�OJ�X5+�`[���&�Q��Z.�����+��Xl�A��8{�>���/����sA=}u]R�W�����G�,)X��P2���v���,G�C�?�)�����wh���v����/��*����35���A�;peM�x�!�~��/��<����(
c0LHI7�h �}�dPG�H0
�)�<�R)t.a5�de1�G���p�^|�w$�0/e�=X�� �rl�z���&~8
ga2��-�$�#l���}�3�)�U����Z@�EH?l�Jd�xV����l}����P!nDS�M9�@��pN�Cp�9m
��"�hHTa��PKQ^����R����0����Th�������0<p4���ix^C����Q�DC��|0���H��e�4��R/E�e)W���T�K�N�����|�0��M�b�@o�l���!�&]t�6"c

�����?��'r�U��hD�ts���*QXR�:����K��3d��#���O�/�m�[o���h/y���d	E����-s��}��q�\����m!*J��wQ�m�����n�"D�O���7�.KLTSi����>r�����M�~�zM'��q�.2�G��dY���"''#��sH |x6��N�h$���H�1������H�M�Q5�m�����n�B���sU(�����hb����]
���#tF��
:�����V7)e�;��)��u6��3$?R��`��@5�cSK4}tk����H��������
 3���������4����aE,�md�H;)�#d�kT7��g����P��� �,kR���j��}�rv���!�h���uS�{�'n��b��i'�+�N����N����|9� ����
'(
{]���"5�������|�P�?poB�����ZkA��b��
o<&�hS�A������}�zIb����4���-P ���4�q~���k*$�lb��Z���W�a��}'`�Og�N����������0M&����	
F�{`2Z�P�>�7	`BO���8��E�,�����S�B�dBv=n����,�������O"�������3�P�a}���g���C��0�3*
$q������[��S���
���)e!n�'�Bs��������n��<�����,�\Y�F�B
���R2Q��V#��z����T��RtG]!�>���cT~Vi��a��=x��`.L`���Pj3���x���Z�l�^��4����VJ0�Sl�I�0���FD1p�"�(X�_-]���F�cV����#^�R����P�C_���������W���:�"H��K[�6������*U85�������	(yX��E�~�s��4d����������D���E=k}YG����9r��i7#d���V�,$��@$0y�qh�P�!R��0�h\eo��"��B�T���\]��xN����D��J*�z%6~-�u1��V-x��)�'�CP�i]��5=�����d�@v�� �*4��U�A{������$M�:;�{�<�-W�K�!Q���d�����o[l����-��|4(]*:�����c�G��k��B���6�QZ��&��KYX�O7���Z�Q�+f�-��
��v4���!���\]����A����h��E���X�'�c��T�5��f�E�=5�.��k�o�0�+ d~����b�B�f(��X��'5�s,�XH���,�����������j�EhC$}"�:��y�+�+e�iP���[55\[�Y�������}��]�#�=�A7�A��@���p_�-JWhN4�\��F�o��h��O;�Q����W:h
����~��-b�^�������}i�.���g�@t/F�-��+�f����S��8�C�����tZ���D@\]���M)��E���@]�Z�`~E���E`��u��0��tA��������p:b��tBH�j������m�6�a'���]�?����{4
@)��T4����*�j��,WI�m]�=��O2�Czs]q�G�A"Ju�a��|�|�+< ���`�_���]��ud�����HJ���.xP�JS���N���_��P��()Q*�;��n$��3#X��>����S<�2��4�����O��"t	��P��b��%}�}���u����x��-�=0jBs�"�j�d���2�
Y���g��zmE��L�����m���r 
t���:��tk�-+Q[0
k2K9����Q��u2�HQP���n�.�����u��S4���
�
F=���'�S5b&�D�����������
�*����Z�
f��.��� %����:�S:�f����O��)�O����~4��{�������0K����P���
Ck&]�^'��~;�������)�z��P��h����i[vX����O<qQ���60�������!L��Ez���"CJ�i�sN����[k�A��6���4=���;c$�a�i�~���K���I����j��fq����!��
��p"N�h$��Q��[�m��
��JA�!�d
T��@7��ZC�M����b}��f���4����?�O�(���M�X%��^V�1E�Y�:UTO��)w����=����8����W�� ��V�x���h;�
��z���k���P������j�����g�{k+��u?�pO��=ER��	n	�������~I<"F�h���A�F3�I2��v�$�*����"���� �HD�&�nQ�~f}�]w�:������$��w�%�'WiM�����?�v\���y�G���:�c �Y\�&_ZiB�U�r�p����&�I��*BHt1�������p���l��B��@&���^��fo��>���8����(�`���,e+�y!�P�${�daQKC��~���J3$����K�|�����|<���p�O��E^�TJ_�T��
���@�.
�%(�UIp�	�&}W����:��O]��M�i�:�l#C������)P^YO_�G�t��}t��U����v�H�E�gJH�UC5���aJ:{���QHp��� ;���LW8��4m����/\@�$��
&T��D*5�P2�`�^I�-Q
u;(~�G��"�k/(�,�-�N����
�T�!C�B6���N�TiI������% 
n��i � x3������N��2�3]'��{i#D�jGm3�����A_��]���@��Z �*���E���7����La�w5/�*G�a�G�n�3���n�
��������k,�����g�vSf��q��������I&j���c��8p,��o#/|���L�D�l'�"0pQ�e�	�N�{�]������q}i�-�.U�����������Lwx�$p�����Y����P�K`�����9���.������M��E ��_���u��
��5�?%WmpQF�iy0�DqD	`���x�c�G����p����I�d��|$����k�o��",.��d��{� ���i�.h��b�����@7)��(�~Er��{1��i�$`��"<���l|��/A�6���.(�!>����	����-D+A�(;_��+rW�R
K~���>Q(��K�Va�}Q0p�+8�b������e���|095�5D[RfCi�#���W��
�xQ��.��1��>�R����{�%UV��M,�o�	>���:J�P�CHr��!�k0U���Y��L�a]j��}��0wx�p��m��4-�)�W������-;,��"�~��iO�B5���P��?h�%S��@�X�D�8$g7���2��w���o�(B���|���
@���vQ���>��Y��6���{�`��������O-L��"�i#���_�x�\�`�~jK2������:���������
E�<���S��O� "�Y��?Mb��D'	��@�u���i�(�+D�2�7���������3w~DU�J�{jn��I�QH�R�x0�_�I�iA#
.�q2��v�N� h��[������c�GG�vu�K�P�E�a������|�����/���d����uQ�&^� a�&heI��
�`���>�,�9��boJz
�v{�#���A��� Q�eQ����L<��8~�6n'��#3I��xrT�%�J���<=�q�8��i.��^�7JU�z+f��
���g��@���t�]��d����P2�mQ�W^������\�l���x�9�K������;Q���N!�B#3fY�\w�Ny$

@��FA9_J�e!��^�R�6
4��:3M'q���wOk��o��^A���hK6�Q���j{��J��%�HC���if�;�w���S'���r��`I@���}
Vj�~����A��y36)U�0����w���5�n/ I[��*E�5��
������U4
��Cm����AW���8��j��
�����.����h���F���;����6��}����$�$S�.
�O��q���&�������)�����$���miVi�B��W�N��)��0�V�6���0�S���������9������C:-���b�^����4��*�
������EJ�<r��.���P��d��L�	�
���d�0Cs�GX�#;�yU��nr�!�|��D����r�\�w$��u�J����0�H�[(�>�k���)W��"#���-� A
������E6�|��b7�d�|�~������=�I<��.c��eT���J���(c��,g>l�wQA�*@-D�j��9��f�h\N����z��{W������
m���P�0�az��S�x����VXZ��d$m����� "�#��9�e{��f�����?r�{	d
����TT���YL�GGG�u��B�uyG��/�h��z���V��O�� m�-A����E>�0G����p"�Va��B$����&�h���IH7��������n��v�~'z���Om����\,#�H�8/���r��;���~� s��w(����8��H�}���ay&)
f�.P^���el�����Q��p����JW�HF�s����@�?|�%��������7'�
��`�d"����+CR�7h"�E�����U����2�]�f3���E�"P�df���H�Ql�J
i��Z��mE=Q�Hg�!�(�:
��F���P4�j�UV
e`�W��{��U���!v�]^��2@*%����3��J&u�s�7�t] �����������4��I�If������^�)CA��
2����Q
�
X����@�-"����f����)I
p���������,%�@3��/�����/����_�t~�k�yf,2�T�J�B$u`�^�(~�d]z�|H������C�q��Hi����$-.� �5�!�)���E���x�cU�(�����W��8�Y�`Q����K�1��%Eb�V�*�Kk������hM���KXE��EX��=�2�3BFU��C@�
a���r�/��S)%����I��|���ES���F��M�TI�D"8�I���<7����/���zyA��4�	O�#��h%tMf+�3�`y@
#��K����hnFxo�oT\,���BRaK��g�K��([@7=L4Qp&Z�+���m��[�;G(�~�)��O`��f���eq4=(����CM�|�&�:
�F� ��E�������H[x���v�#
��b$���\�#�R������b��kt���{��������!5����q�y���!@R�X�����X|����h�D��d2|�8m-�� (�|aD3A��n�K�7�A8^Y���{)	�@��i���.�!�K��
����;��t!|�g��M!������F
�;RG��8���X:����yE�o��Y/�E���\6�%v��@'��Xk@O'��D��X\w��7�Lz��p�)����m�U6va�a0�����D8�&� �ER�&��P����~���%��I\�A@�&(��oR.C���g����r�|�9��`#���6T�M������T��c��E���6�<�c��v���"Z������e
sD�FX����_�V�����v�C���w�e�#kq�����������2�E�M�mZs�"i8�[Q~�1P���|,hr��BHQ$���er��m9k\,�\�
��c��P�<�B�$��,g�?1���+����<�,�����c�����*����6���o-n@�,�:�N��_������00��U�CC.r"��Y\�|�����'Ir�[�
���9*�E�q�2T8��'5������e��$�/��	i�m�+\E���Z��zUpt}���^����1p �9����r�C���Z�J�DX[&L�8��uF=����x����
k.@jS�#.��R2��in�ffj��e�}n�Q�������j��I��fl�������*^��T�%�{�W���*�����br�Uc��+�`��9r��J(��s^'�W�m4yU�\!%�\�:K�af\w�i�����4/�P|9���Z�48���)�4���0J�� ��<|�����e}I����U�#�R�]��7i���H!���p �x��C1*xU����,�"7����m�L
�&��G�sz�/�a���Z�'�L0�s>.��|bK= ���~�����p9�����iu����S<�\�a_%�����
�����I)��2�^lZp�)�+���nH
����%�����[��&�u��5Sk��AsP���IQ�I��9�N��k��H^�8&S ��D���3�e��y�VN��Vq��X�z���r�*z���(CEq<9�E�L���t�9�c�K7�gsCU�h.�F5�C��`��{��>w2 ����������1�Xl��eYaQ�z\�y�qa��lB�m���8r�7��/_|����?�w��U
U�@�`^��&��
�+\�'P�����x�px������<x �������P�P���s��yeqck|��3��tDF� �i9f���3
>��U8Q����?�����x���@1�����I�N�S-�+F�*`z`+N���t\];*:�+x��S��3��z�����{��Js�N+�{��N��b�i�������:�kc�����2������.�XWq�����t�@��o�"<�����/m*�;������p�2K��\?��F�2brm��#�P3D�"[(��E���	y�B�$���W�9h���e|�Z��`"��Z������)F�y���9��i�u�e����L5����a��	/g�����?����mE�q6����$�/b�qe'�Fv(����,V��������DhpE���}��Kp.7eb��K����,�&?������K
V�����U	(-�/��a�(������6eb�&���*�+��
�*��O�c���Sv�I��K6�b&}������M	'�*"	������ML-������������#R�V�i�&0I��=����E����B����pcd�CF=0Q'��#��%������fx�[�=��Wp(jg���N��fm��������?��G��9>�c�
hB��E���Y�G/����� �������
�7��C����3�%�=���y2q��c�NS�����g���a+G������R�����f��g�����_����2g���zx��wT���6n�r�&�%������d���C��6�fE�����>]�����
hAt;�1�y^����pE�,�c'��9j�e\��T�[��s^��s�G_]����m����o>������p���>J����[�P�*v�+��x^�^�g���^~��`����Mj������z���-1���5��J�3���[7���"W�U��W�h�a��?�#������T��o6@IDATj�������=��#�d:�������O){{��AUR&F����dC�\�</v��&<J�����V������=���t�q�}Bo�.O���<�8��|��0�]���%r��Z !!fK^�O"� ��y�M<}9��~���|f�?���x�����=����@��7���c�0�����V��_S�4���,�����z�D�
��i��Q��p�����l<���O�������=��c>��������{}%�i&��a��tdCa�1�Q�9_����,���@�e���7�Y�wa�`���|��"|��;�N����C,c�����(y�>�9�K&�#1�vT�%�{2f q8���_,��=K�e���rI�I�a��~4@�cT2_���
:#�
��Hd
7�����k/2:���N������:v����1<�d���o�r\���'_EC��-/d���Q�
d�����z�,h �!�_��
�>�'��H�6�)�	w1a��HAZ�YQ����=��H&9w�l����x��H�O�wz��������n{0�i�C�2�C%��7�o��S������x�&?��N�6��5����O��R�'#�������4=[D��W�&��=��j.�o�c�'`�r��=-N�|��DY�i}$�G�����j���UX�w�2=8����r�:�E�������q�yg��.SP��:}������G��W#��+��U�����wf������Y�E��o��/�>t��{�����x(<�"��_p}����^�z�w����O��G��_@[D�{���[�I��7�#�uX�
0���	�����{
�H��u����������ay=c�Hk��Y��4�O���S���WG�`����\^�8������y���=f�(5ny�[nn9�������k���C���`GR������$��R.�:��D.������~���������?��V��CfmU���.�����+�?Mf_��e��y��U:|00�5��
��KL�����VO�N�K_F����������e�o���&?��G�~�6K��\l4��b-7�H�����.����'��yY<u�PuM�b�����L����4�����h����j�;^2J����@������-#�yZ.����'�on���]�t�/�1���_f���
S���:���@g�2�U>��o������R.�uG�2��\��GU�"�-�~L��h=��u}��������[ee}���7�Q�����G��@�Q����{@���#�qq�`d��������:�q��c�uR��@l{�OR'����s�=���'&�Z�����[�(�S������e�e}����(]0��e0( �����b
9��
��,�|v�M5���o�^�������>��{���?p9�'���l4:��k5�`���Y��+��������{���7=�|�wxup�d������A�����x��W���C�=�c1
��)����#��
>����3��KD\F�p��##�m��#\ L��Aq�xF��+�W��;#���,���dPF|�N��o�pR��g>s\���!�V���'���i:N����	t
��# S4����k���pu�$(�v:(�O'��������i<�6��o��f�R���(��O�a5�������"2�yo|�oQ5�3�����w�?y������z�3jJW�
���"s��h�;���-�����8]Z	H9������h��T���g�'w����|�O�;������ >��TV����u����|��PQ
q�WN�������<�8^�D�1��g��px�'>����L�t^=~��m�����P�"�����(>���N���R�Xw�S�D��9�;����2�B�@~q_,����u~�m<���Y��?Z�k���J�V+�����@��!���	��P��Mtz��4�A�����{��>�o�#[y#���I�����q	�w ��T���u7���7���_���u�A�T:�D�_�M2kd�A�8�qi�w��'�J)L4��T7��/����#n�����x`_?���"��)t`6Y��Qq�d�}�c��>��#$]��i1(�X���0{�<������a/���]�*'�o�(���m9w�,��Hj�!�F0�4�&��?�~�0\��>-�����3g��O|�!�fEF��n�A��/����<��J:
�A�M�����r??0�{��!�5+_V����X���8������8V�@���qy��"
:Am��������l����
����a_�`�d�|`�������``8�3��1����T�C�^.�eF��	
2�6~�8����p���M���K�alR�c�z�&Q�'3U&�~0��{���Ww	�H�����3�`��N�#��/Y0q�o�����7��/�?�[��f�������<��!�;�T�P��~<b��~��B%�������m�)��P�/ch|���	�Z6�L�7��sl6�����^g��fx�	e�<�����G:�G�T/�������~t������6�E-[�x��)1��/i����7?p�W��s�}.��~S�7��`��}�����n�&��i�tg$���C�i\���d��XM���}���fe�D���q���r�g�"��Q������������6>�Y^���lT�^��/?	���M���u=@����5��}����In���������]���IN��.c�U�x@���X��A�jM,v�?W� :"��7�U����7|�pbv�C�]q
�D=)�0��(:n�(`b���Tmzd�?��in\��KIQ����Q�#�iZ��`ha��N����	�1C�����9Xd��~�w G%�F��*[�Fu���?.���&Oo�>4���Y�4C�c�hOV
�~{��9S#�c �D)o������m����9}=�3�_\q����E�-���i#�+4en�[�2/�:�57z��S���dW!�~).E�1�
���{�b<�K�hD,��g�������P����.��J���i�]u�7��+�i���c�S~:��guu�eM�K���b���������3������m/��3%�H���Y����@����2�l	3=�_�����g_fE�����Yf�`���kQ�@[����*����\��Y�����5�LY����G��p�c+���FhT�ur���}�\}-����Z��p)���Y���[��s�
�5�+���>v�G.k&?:����
t\�#<������������k������9��1��O���������r7kQ�w�c���o��~*�{��CZAV�jf&d�XYlX0�-���>cr�H��_��/BVij+0��$c�h��Y�q����:,L�wT��+.�K��?M*�#�����$K��<���]n!F@��Mo����&����;D�����%��	S��Z�XI��O^&r�>�[��3,b���m�k��K��
H
4]�u���?b�ir~�x/|nD��tV���uyr?���eQa��`���������e���
�j��\�J���O��jp$S�bu�d��^���������)XK�3����:J�\�<����?������._�D9���'~�gk*ufYZ���[x�|Y:l����<�������<[��''�
N�#fE��,Q�,*|D�\��:����9��B��s�NOX���O�o�#5pg�v�@I���[��	7A*k��<�`E�
R�39�!\YI����O-����p1��2BYD��O0)���U�(�\J�E�(��P���nY��OP��Xk#���5��-E��T�#'������%;C�[zC�n�+3~�N�olUX��:�Y,ZQ��Cr,J�>�����	*��:iZ�l?��1t��0����X���D	��I���2����Ng��\�k�cr��-�7���KJ�Wz�GA������m����r%��F���e�'�%�:F\F�D�4�U����:��	��+&��X���j4Y�M����4(2K!g���^�����%�,+��3@��	��3^�>A�w��H�Zb��}T\�cQ��5-d���L�p\�~���/3�}A�ax�|5	�6R���`L���$�
�������lO��{v���QSY�Q��`�P��jl�}$����I��/��I�jD�����XK#?I�l[��`.l |����;D���������O���N8dfE�{��NU�����]<a�4���r�tFz���e?���w�
����
��5F8%��6t1+#D�):��exA�VO\���Y���<�+%TuRM�
��P��Q�H������	h	��PROEFP>���4�����
�W
d���D$?�1�)��1��t)J�(H�q��@J�J��#+; �.���b��F2�*����=An�����dIX�C,�b��D���@�d!O�E�MK�����D��������	��{8~ +�]��^���>��Rjr���5�>���vq�sEcY%�CH��'?���"����RI�)�J��jROr�9G�c�L�3%��o�Y?�E�����LMQL���L���OH����I�e���_8�_,^��!,���x��Q��i���5GL#�\�%#n�X��	�b~���1�(�2�-���F�8m����--.42���V�� �p�$���L4������#�EC��O�.�2��N�/��s|��J������S���&�V�qx��,��XK	8�e�-�p�%x�u3���U.� �c�H���=����Hr���j��)A��$e2�P�h�9�`H9pv�n���]�^p{�lJ���U6����^�]\���M�e��e���#n����_�IT�������N��,D��Cox��o%�.#��h�:�QSK����vyq�^�A�����js�`4B00���|��?�5`��C6���2,�l��
�������"�.^F���11��B�5��DB����0B MtR'��.uC�$��	�� -sH�pDT1y���":�2�Lj���I\�#�g����'����'�Y���:��,�;bk��CS�f��*,D`,!��}�{5v`����g���*��'���P���S��_"�g�M��aY4�+����p�����d����p-�'�Q�v�U�l @?�������Sw��jp�0���yd[4�g�	o�Oj�|��	{�������wtk�g�.&�0-�0\D��%k�:'���a���M��(���
�!y7P.5eT`���2�R�;u�z~���6-��
k�_���"H
�������b>���X.�\FY�A���.xb�N������D�8��k��
�H���
G�pP�(Z�Wb `��pH�0j�������3�
N�>���&&�=v`��0��Xe���D*e��X�+�*�lF/*%���&\}�Bh�)�
��Z.�������%��pO�@(�f@)�vq�A������3����*����`�pB��s2��I@�"Z�N����G�7��?\���$��P���"��T��2�?�w���;%�K�*���>��Ls;7�dn�z%@����!�)��g���z�����\&�b�Qp��A�S�- ����y8�8j���Dz@9�D�L�c���G����	N�x^�	6Y ��HWQ��t^���aA�h@/:b+?�A"�^0���`fP���g��$:��&�k+�2�^������_F��5��~n�@vW,�.��
w����,C!�	(C%�-
�bZ�"a�D�V��:y�&��8�yV����JS��(������aV������B������y�tc���P�A1��'m���0����~�[�Bv�y4�d��<=���W��:z�p�j\��c�ZE���������=T+	E��T�������c��[���P�|��cBNSjd�3�;�F�v�o��~����G�����mP�
�4;����x��D�A�Q(f�"	2�HJ��wbx�d#��3a|K�D�J������:���I�(��zh������1��#�Z��H������{A���DL,~����S�/�����o�Ai���V�IQO��L�;��
@D�%L�-��h�h�����{������{F��69X!���P���y�������e:���V�EL�����V��W*@���6>�B<_�(��r�+�`�bI9)2�=�}.��r(�bh-G]���%�Q���GC3:��2S7uQ����G��&�P����f�z���V����_�cG�kH�����J��'�������V(1��0j���@QqV�<6i1/oj��m������8��0*����
%&fSWp0����;}Sl��d 3o%=Zh��$��(�,�	�����-��wb�et�&���J$tK:m�uK�m)�D,��]PD�$������i�V�|�*F>�@�eQ��9��1.��,��j�!�U�z��7-�������,	dr#
�������u*��,�cPc���������TJF{�
�i�
C��e�O�>_�����
8+�.�(�*���I�������bW���r��&�E�Y��XntD�(o�h^�&JHz�P<!���<�KK�0�HYz��4�Dr�k�u����&>:�r�k+��jsQ��w/P!
�������D��`��WM�|��;4�������:�V3KGi�a����~�$���1j�:�h4!c3f�m�a��B=i
�q�e�"BvU��K���D������{�-�"�d�7�H��{b��l����y�J��jYK�K���O����`�QLI�v��5*m���YUT���+�%-]�#,�G��Z�RLJ:��H'
7Z�fz���"CY�lg���Hv��x���,���ii<���r)�@22�8���i!��(���W3�.TY�y3���;b��1�AU���^�������V�uS%��1$�L��N
,*�D��(�q����,=Ij���D�h6�3�����p��LZ�����91q���2UvVJF���&�P���&�j"����cp0m��1.B5�&�0+GS8��T����Wa���_bI���0w�Y:�&���N#��.�n�Z��p/�Pv�c��.eg�fM����u�%�R��vI��N�!@�$e�=v@��}�h��*f��d�Hr��c�'+qnn���<�I0.\P<�� �'�	��K���/����QmY�o���h�����[e+�p�>blx3m���������=C\V��P����w�~����.�����P���t��`o�6:#�����5LQb�������7L5��#j��e~���ew�x���_.{uM�bx���C�@<�e�*�*D�w���T,ey���3`�/�+��0�D�����	$������	
����`�B&2n��X�5Ed<���[E�s��lG��y�������/q�?6&��H�2&�2,�)�HK�:9X'	����"��V���4����e����Zi�����Q�E��PY�D����+���r�w��6c|D$�n��_@@�r/�N���@�}�F9�u�����|�@�����W�>�C3��������
�Bb��
#�i�����a�����'�<_���$mJ�@{�R�^�|������S�X���w���G��R�T��Cb(,����:
��� ��t���X�`!b�~C+\�G�!��A�G�\**��{�LW�N��b��z_�J^Av�i_��1�UYR 
�m�t���b�P\]5�����v#iphm�$:3�c�&f������*?3�n�#)&�&�n�J��R#�q`f�T�Fm���@R��W���b��g6<������|/Y�����1E�A(~f���}1XI��xDQ�8c%
 HA0���P��+����	�B�$,9>��)Je���4p<����4�R���P	�����
&���vpd+
^I�.��RF��,��,��x���s�%
�M�e��:�x6���Bi3H�����U��a���M�it	l��(���<ac'g`�B�[�``u��W�$e��	GA0���q]��"�*��i�R�
��;����'~A�`��%�I��x��[X1���5��U;�+]� g.y��}�1�$8�'�p"���y��J�^��[�/�����	����S��,��L��x������)SZ���&����{+�����5XY�2��U�W,���Wa�D��
�.���v��������l�������41����,�]a��88��/�����r<�h�(Ay�z�XO�egU-i��Qn�@��U-�[�[���L=7xk;���I^�x	&6�\�-��yZB�}^&	6t/����x
�A����^ c�
���������F$�c�A���=������vnU^zv����p�ViY�L�}h	�oD#{:_qqC��}'�g/};`���������\G����9�V�`M�����1� ��Z�M$$��\��`��}&�d�����#������������`�����c�p�]�&-![���N��.��gU���}����ty����29��*2�B��0"����]���Z�� ������|���Hl-�8����v':���v�&_����F����0�����r���������&@��%���w�ML�Ua�p��5D@�����*����k��5E��Gela��� wY_�"(�Fi�
�k������W�J�(�:R�}{�v
�~x�Px�����k6��`�r���{���S&uA�"�Z$���������3���`B���
�I�**J�2���o��U��v�]����$���@�K2�]�l�^���9�X��u�16����n+�h
��$����N���=�Y��{]��YH�}1��iU��$D�+jhF��HUe��$Q�@:/hK]))����3c��k+wU�*>��p����G.��~�ze�+�W��1
b���nYz�����l�4TW�0����tDq-�\rm_��MAO%���[1���s��S�x�%�q��H��w�H���,�:=1H��r
�P&����C�� @��\k��6[KN:�68)H�e�a�S��F}i8�4_\������8].ZH�_��O��n	da�`���&am��F:6��CZ[�J?�{����P���S�E��x�+siUq�D4&�eD@7A8����s\�xf�SW�x�a�����fN��Bt��hij�N�y�j(g���u�tGU���[�VsXe��� Jk+���}d��L�h��@kKPP�)���Ne������-f�L����I5�L7��`!q<A��=�����g�%��tl��L���T��A 7�Fn�A�k��M<
�}(/@vFv~��D#������7�/���-��0�t!�����c�QL�<�����qm�$�8����F��_h�:�d9�������!PC�:�S8�.��)�bp�������f�H[���������)=x����/�m	he���X���E.w4]��B,�m��k��V��5/�f�k�>�&��V�������>"h�F�*���L����.M����P�4�O�hL\����<EZ�v�p>��]���S���nY(���(���:���3@.��������D����r�QD[���S��d%oU�`�-mJ� �r��i��`�e��d���*� {��(����f�K�&Y4�/��x�s�
.��9���<1��6��<�����C�������ZF=:�Zu�C�/���"KNhmn��@p�G4h�B���i��a�W"2�O�#
�&k��RZ
��C����q���
���(N�Mw9�OWT�y@�Mq��7���.��k��&z�BmH]1�T
�w��q����
�l�4Gx���
;�?g�,��N�t�2a��Y�&a��he�|����[�9�z��Ypy��Z2BE��|8��sK�r��jv�M}VT��C����*�a�����U�[p��:Q�H�tE�b��|Y=2 �	����{��f&l� *���-��\Y0�8�E����&�JC�-���h_����hE_���d	��m���n@v�����=���g*�c�/[���4�j�4�h,�����,��C'`a�
�����������B�D�������(�����<n��RM����<b�F��i�P[�n�U��0�%q�v;�s;� �	���"K9Tv�Lp]��9���a�A��������b�C�j;���b��Bm���z�4����n\������X�2�".�CQ�! 
p���&�j�X�5��/����/r04*��R?�9?;�����]�(��%�����wO����P��8����)���,�r�%
,(AS��|�&0��0k�
x�X��Ma$��J{~]K�Q�?�R�8sL������}�c+X�
�
�A/�@�J�@Q$���}r��o-�E����(��
����	Y�D�D���(���p����,?+3�����-8��B�����_[�������e4	��@�r$���rJ	�G�D��,/
9~j@Q���(T���y�p���F8�`�tR'^
�%S4(R�K1���[��H��d/8[n�_[	h�Z��0��4��g'��3|>!�T�grZ�(���n@��@���?������}9p����<iY�F�dd���C����Q�����z4�"��Cpy������	�p	��"e��Ijl���U��`�S������	��eAl�'��%Bx�j$�.�Y�w�(���q�*�� o(�2:o��d����m��7��>����LP8�.��~N�@����F��K��W�,8���|��$8\���bw4iT�^`�y���s���@-h�_{���q%
�g�F���dY�{�������q�����MI��1����F��	�#w[k���N>���e�jR��������(3N��scy%mC,���s��S�����W! �a���9{�`�o������,"�����>��'g�]x�^��`��Z!�h9zu��ZSYxR'�2kx)~2�*��'HO9�vD+�������r+�����a�8H��X�!M�)O����^��w�	����n��
�RHiS��uB���XV�*�8��	K�@��2��7���g��d�������r��U��}���gh�(�����?j���l�OX���A�8���������?{p�����)�sMi�~r�Hv�fr="�4$ ����L�c��h��k��6?�y%	�y������I�-����H:��Zy�UDo?!�)?D�[�1�p*G]�NDlb�A��6��kv5���LRQ!���MDBb3��������^Y��]@B����"uB!3��G�Z��i7lo���LcM�5�Z��� +�G�1�������*��&-�I"JDJ��7��D����g+Bj��G�A
��+�����g-)Ct1�ezT������i�Jk�z]x�%�{�P�Z����B�Q���B����a�Fg�t�4%d>=�7J������@����%����(�/q��9���H]�pu�V�CkEE�FO$���2���	9XC������p@������g�=��A���������������A�b���D�<
��R(av�� �8��QR��M����Z��R�D1�DS
�a��A���Y8i��
�: M~>��T*��q��9��>NZ0���o��n�P=V8��>�d����Y����9�x�0������<�C$���O �6���8�T���%�-�-��l�O��j1�q->��1U�2����k���q!�N�^n�RK�b�E��&QQ"#�Q����/����0S1�f=��TH���F����hT�u<C�}����
�F��F`��02	�J�+E��'�z��������RG��-�(e��q�I�C.<��Y^���R��5_���g��sMjR�:�����r������
��?�-���,����~�9����Q�k�S�d�$���X���=v6������?Wkt�
o��2���<7P�!�3��P���or2���p�"�~;����z�5�^�Q���N��[�����w~��n������F��t����W��[_��>��Ph��LnX�4f����d����8�	��h���A����}*��_��ep5���I��o�r�����fy�0���=+6f��)Z���n9���v��s���%*�K8;�c�k���x�2��m.3��N���1�5�b��w�Y._}_2:
^����h��|B�}��0�y�,t��w�6$+B�mle������97��qi�"��0���O,2K��p		��>��E3i����Q���.>��b80�b�Y"������_���x=i
�n��e���@=���,]
�/��y�J��v���"��d�\v���\(s�����a��g��fo�q_��r1a�����y�A�\��%��}���8D"?Y�~��a>�����
�d�}�r���	���!b0I��Z��4E��wq{���"�~3��S�*`7,k�����M����W1����4>c���D)��$F��%!���_�d��|�E��3��4\�`��db�\p�j.�Z�	;���?�dX��
9�������t�c��;��,�ZpJ�8�Y��@�I�X����@��������#��g���u�m!|��%��qqQb����Z�:�P7�A0��a���'��Gs�h��^�V�r=N��;�m��N�����}+u�M����0���� �����,�����K��Zg�p�6>�f���8t����E�s0�2�m�cC*}���>S� '���3`p#�8G�hA����js�F��G82�Y:�����2#r�����G,e��[������h/�J%�Y�8#���l�{�8.��b��tQH%`r�Q���������L������X'�j�k7���}��h�2������t���9�L�������1R���`� ��4����N�)�Qp9�M|�����t�m�������O�9`5���\�+@�m�w���q����y��=������
����1���%����pH��t���$��w�t����7,9Z����ekX�$�}l�/-���j�H^@�I��t_��q<f�*f��K�o�l��E��E)�Y�=SF�v���������sF�sE�'��Tf��{?��b��������I�����G��q�B��*�d��qQ�	�DT��D.�����N�\����^rz��'�?��>y=6F~�i�����[�o}��_�>hu{iy�����
�t\Z;��|�X�/<.�6�)}i�wbt*����Ei����a��M� ���"�u�b��ZcJ�$:�>Me{������hSH��
����\&^����r��z��e���<���.<Ha��}��\��F%�z!�k.6�"-(&S��8
��+vX����zb�%�����zq\�^3�\����,�Z`��B��%�hr`V�1��������7�������l���Y$�?>)���iq����4@�<"Sl���X�6���;~*7~&�a�46�"�D�sh(F�y}�y$)�\=z6�������z�>��~8��0UxO�<d�J�Is.��
�(M�q�*/�3����m�XP����?N[���)?��/`"^�����2���y�O&���}tn���r$@���B1�	R���G�)����-��68)���ebd�C�������e��[�D}n����s��P�?��T���O`��X�~���n�\o�������&�y�B�X�:5��14xc$�s+)��]Z`���KvC���b	��1���4�,��Z�&��,�'4��[4+���Z����:-�wcu�B���>���y�;��N�����#Rhe�C��I��}��@=��E`Wo���)����1o��+6��o��%%B�M��n����o�t��a�x@��k�{�%�v��fV���w�����b���a�4�[�:u���B�uDZX�h���3�33ke �\�0�����:<8�V���83����t�����mz	�����Dh���Cq
T5�,L��5*6��������'b�t�d���^���Z0���_��"w[��3W�F;1?���F�����Le�����/}H��~� ,O.��E���}��X��z�(���L����:4 w/i'�������B~^���d}&R0R��i�G-G:�?�?N�p>t��Q�.����\�m]��rY��w�*������`�WCY#?��~���i�c�u`��@z�/wx~_�L�F?��sl�Cs�Lbl�J���A���i=�!s�cs��'�����g�#�^��ot:��������j_F:�0���Y�^X�P�\�,��T��un-5�r0'a
qJ�D�H�C#��l~��������������x1�X
B,K�/�S�8�,%b_�(�69�� /U����'�S���:���2�b���P%[�D��g|����V�����m.��V��7�7f�T���`������A�f���������FG���/7>=:9�v�����B]Wa_������.+��l����5�Z����;O�,m.w�,czq4�Kw��o�|����x�W���q�p��?��I��������vc���"��D���&��t@�pw�U��#���b��=�,�"�:	#zj$��r>o�Q����^}�t;^����E'X�z���'�-=@����Z�-�����q�]{v4�_Y��H����k/�.qn���G
�6ZO�F���m��b��k�������G4qsW|{xr�����r����;�[��7�z�Oi���bm|H��.09=����m�4S���n��i�����}o6��N�����^w��|�:����l����6����
�f�_�����4�������{J�&7>����_����r�����~��l���������$���N����k���b{����?����Z- Nr��������v��d����_�:�p�l�������o������u�7���K3��������:���#�������8����#2����s�����������Z��������IcpT�]��8����N������XX�A�9|�~�G�G���
'��;�|�c�D�������o]y�{�B��o�[���zu�E���
��#�2�v��~�Z����o0|=��w��v����x>��7:�6N���;K�S?��������Rs�S������="����U.����+�=�@�V�?I2�Z�3�|V����G���R�������I���8�JZ�5�?�n�L�y-[���g���8'��n�V�]�;�m������2���;��[��y02�2Z.n6^�n��VY�5�B���H����zc���yw8~~4vc:��>:8��f�i\���O�^����h7zS�M���b�U�[����X�����q�^��H�������[K���=>=\m�h����L���j��2���k)������-:��V��QS����7�����B�[�}nD��3��8��XF}���&������1���6�m�f8��m�7��79Q;�3.�t��]��w~:���A�Z���
�����[���!V�K�N��������K���R"�8�����VmP�������=�_8�������l������ra�t�{�����0�������D�C�&�N������ ���>�<�e��t�����j6`�6�J���5�����.�^m�G�����
����
]Jl��`�`���^\k�l�>0q�v��"���h��>8hqc9N{��V3��=�o�6W����G�������h�4Ta����U/�����&�/��B�}��^yt�l�����mvm1�F{��FK\�w\�i���0���N����Uzgo�q�lm���h������y8��v�����p������I�?[8p��6LG�o�OW:�����e���������_Z1�{y�ur2�5�t����������g!�^KsS��5z9�a<Y[����k��4<�S<����2I�|���IDATk�]�������^3C���4������0�=q�g���F�t������-W�������N���������v��.���zC#�	����V
���v��X`mO��1+�k���cQf��n��w��Z�a*`�;l;@�[{�r�{�����XZ~�X����Ww�o4�����������[���R���j�:|z�Y�f��D_;}�����VXh1�Y8���^j��m-/5��_��i�n���g7v6n�Y{�!���Yi�Y�=:l6O�:��G�'��nc^=<~���������Q�����GO����8p'>�U�1��T�=
����e��l�m������n�����:�N��;SG�W�����=���	y���L�/���<98�����(��
��U��j���'���I�rEwAl�b�z/���G}M7���ac)z���N����o�N����%������N�����8K�� 7fv������%�5/������s:z=�h�S�����E����c����W�7��
��$�oS4���B��������76���A�~{T��Q�8l"]y\��3	�m3�`z��\vK�VDh��Xxvh��F7��pp�����q�����S���L���n������+Ss��OZ1�&lzZ�b$\�Kiw����E��������UR���������Z	�^���;�
U���'L��W�C�n��<���<���4l(P����^*_�c��<����2����Tg��F�����[P������l���9��K�!�3��6�g��������K�^?��<�8k+:=�hw?�P�=��wf(m���|Q[���f��*y�-�3-���3�:�Y��������he��k}�t�%��i���3�0gY���Gp
��#HB7
1�����o+Ir�1��S^��o��\��A�SO}���q����Y��p�+��?��Y�uz�[�2��)�R��2��s����V��w��v[�)
�q
�����6�zJ����)l�4f6�L^�1��fK[��0K��0d9yW�e0��G`�����H�8S~�&PX~*rN&^Sy�&��yp:�x$S��a����G`����,M��gE���BIlI�w6����x5$x:d�Cz��0�~M�i�b	xAQ�^A���#��!��������^A�����1m��)nV���r�8�'����'�M�x^v�8���\�R��2�F~�h��)�z,�����aCBm�"cQ^0��D� P��G�6�6��)?�Y�?���g����S�/�ER[������,�xE�k
z�:�H�'����m��g�%���ie��/��X^���S!G��n4����E�=�S���A���e�2A���^���������L�9�Me<�H@_���y�X�s1C���"_mA���$@� )�4*�.{@i��w��"�����*���4�{�?���9m+y�����4��.��6���|t.�H���$����?O�OaK��v�QD�v/Mg�P <i������3M���K��S��O#
�/�A�ET��`�uQ�^�%OGr��;��b�}
��v����r�}����'�@G~~��;�Y����*
T�(PQ��@E���(�����*
T�(PQ��@E���H����kv�X����~�����f:��k�G������Zo�=z���k`����:?UIs=?�����G�Z�H�����g��u��Q��8��?��������a�����]��������y��-3 ���?p�`�B	o�@Z ��/^��)������_���8���!N&~��A�\f=}����Wp��'O�<��'p�Oy���`��8�b*�;�Zj�U	��S�x��4�z�`�d�$
#�IT6G8Ec&�V{��%d�����z+�V:P��ZdF
w@������[��0qE+�
��7�|Q@'���,�A5����L����wr���|��@: �&�V*w�M_ K��e��jHIc���v�%��q�'��H�g���@�%����|74���x�T���fr}��4�dd���Wl��!4g~�]��aD9��N?^:�-GWl�:�AGX��e���5��x�s�[��#���;��4H�P�Y�x*#��v���a%���Y�QF����������o�.�D��Ob��
4f���c��9���s��r��(	 �3��������{���%�L�wF/+ ��H+F����u0�����d�n������SV.��[1��[�n��Qf�����@�/sF��C���yPo������Qa�����m[��
<��fp�8E"G�u���-���dB��m��\��am<���%
#��w�� @��� A^��U��yp������R2)4�d�c���b�A�Wi�:���$�'�q����;�$�-�<������IF�5Q�j$Y���[iYN+��7��D���`��6�|�l�� ���5��F��+`�S���y��!�1��e�2k$������Wl�x�$��)kDdb
k��?�Q�
��[<�C�������+�Y�!��l����Ga�$i���|�p�~�����(��?C�;�|�
^x�()'�[����k�F������~"��lE�p��?J
������JN(9�M��_~I��ZQ���M��	5�2���E`�0`>yQ�_|�������I����^�����7��N�o��
/���������
� ����x�Y�a���`�=Q����'N:hN���	fVjL��@�K>1������9o���P�s����d"��C.|�C����.@�4�E��?���'�xD�h
�@����b"N)F �
)��������@�Xr%/��#�N|�`PE.���p���?��|!N g��q�4i��+x�-w��9�'���A�~�)1�V�
)��(�C�y�N�&-3�u���	����k���0��5o�������?�&���#����W�;�Y��w`�'��a��d;��9����(d��['���wP�&�`
)���9�t`�
_h=����/0yF���>�W���\���|�	n���� a�������(?a��V�R��Gg�G[���"�Az�s����9���a��L��SO��6��}�.�w�������T��I���!�p�!K��;@5�D��R32�Yy�e��/�3��3����_KC�@�x�_�6�7��<��6��L���!c�)���&�&����h��x�vU?{N�����q���#������xS�X����>�/��2�@�+�J�S�:� ��b��Ar��)L.�	�1�f}�����W92���'k`����7Ya*�����&��8oq�������F��j8fq[��o�P��9oH�����C�04���>����$l�goYr�g��+~6a��)@6����x�����7�����_�>���e`�5��chCl�������f��aA��i�E}
"���������]������_|g��+���K1xSp� ����L��(�/B
:�JF'�I.�-�0lN��Ff	�e,�k!R���;zb���)�BU���O~�`��Y�t.���,�'����-wF}�N� K�M����92SX���|�OxH�2�ez�q
"�R��������>��PQ�9�*3w�iD�+�G%q�	�y4�!B����F�Dy�c��4���$���[\���!pB��KC'�O6��'�(&?#�A-�����;���M"�Z��:�����2���O�,�B��	!>h�	#�&�{/|�}�\Fj��l���@!�t�  #iQL"#����K��*�5��!i`�
�UFAN.Iw�H�����1%? mFG���#���o����[M���,�`|aB�8C���l�`#�}:������(i�H�.�LhDg�=����o8����`��i�z�R���<!��f��� ���������p�1�_&��\'���^>�9��M�694���T�E��+?1�B1����������h�&ad�:�?����T������1���O�#����W@/����Dd�D���AL0t�7�.��:|O����t���B~i���8�<
t���������b�p6�!��V��f���g�6���#�(I�����f�rz���+3GXc�.M�8�������B:��|7D0.��x`H���~1��1Y���N���}�I�yU�:����2�G�xO�BI�F������)��N}�f�������&N��e=P�D�{��Ot�E�H(�7�C�F���<��e�$���l
�X^}�E*��}e���?��4=�@0����&�Q9���j�C�H�g��O+��WZ"�nf������#��,�r8J�d4'�9��Z�������������Q{�`��
A���Li:��>2=��*	G����{��d9]��)��H��st�@i�C
��x��������N��Ua��xr��:�������j���T@2���f�
��`����6����x���,��r������{���t�����,x��������<�7(d�e��2:�s�IA�$h�%h����c$�9�~I�~kdF�p61{�L�0����T���*
T�(PQ��@E��~�E}.���/�w*
T�(PQ��@E��*
\�&���*
T�(PQ��@E��~�F�|���(PQ��@E��*
T�&
T�5�j��@E��*
T�(PQ��A��M�D�2����(PQ��@E��*
T�(��( f��v;��i������*
T�(PQ��@E���
���<;�����J�2����(PQ��@E��*
T�(��(P��A�sz[��C����@E��*
T�(PQ���O�@����P����@E��*
T�(PQ���U�O��
��*
T�(PQ��@E��B�*��)����(PQ��@E��*
T�����Kt����IEND�B`�
#27Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Andrey Borodin (#26)
Re: MultiXact\SLRU buffers configuration

On Thu, Oct 29, 2020 at 12:08:21PM +0500, Andrey Borodin wrote:

29 окт. 2020 г., в 04:32, Tomas Vondra <tomas.vondra@2ndquadrant.com> написал(а):

It's not my intention to be mean or anything like that, but to me this
means we don't really understand the problem we're trying to solve. Had
we understood it, we should be able to construct a workload reproducing
the issue ...

I understand what the individual patches are doing, and maybe those
changes are desirable in general. But without any benchmarks from a
plausible workload I find it hard to convince myself that:

(a) it actually will help with the issue you're observing on production

and
(b) it's actually worth the extra complexity (e.g. the lwlock changes)

I'm willing to invest some of my time into reviewing/testing this, but I
think we badly need better insight into the issue, so that we can build
a workload reproducing it. Perhaps collecting some perf profiles and a
sample of the queries might help, but I assume you already tried that.

Thanks, Tomas! This totally makes sense.

Indeed, collecting queries did not help yet. We have loadtest environment equivalent to production (but with 10x less shards), copy of production workload queries. But the problem does not manifest there.
Why do I think the problem is in MultiXacts?
Here is a chart with number of wait events on each host

During the problem MultiXactOffsetControlLock and SLRURead dominate all other lock types. After primary switchover to another node SLRURead continued for a bit there, then disappeared.

OK, so most of this seems to be due to SLRURead and
MultiXactOffsetControlLock. Could it be that there were too many
multixact members, triggering autovacuum to prevent multixact
wraparound? That might generate a lot of IO on the SLRU. Are you
monitoring the size of the pg_multixact directory?

Backtraces on standbys during the problem show that most of backends are sleeping in pg_sleep(1000L) and are not included into wait stats on these charts.

Currently I'm considering writing test that directly calls MultiXactIdExpand(), MultiXactIdCreate(), and GetMultiXactIdMembers() from an extension. How do you think, would benchmarks in such tests be meaningful?

I don't know. I'd much rather have a SQL-level benchmark than an
extension doing this kind of stuff.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#28Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Tomas Vondra (#27)
Re: MultiXact\SLRU buffers configuration

29 окт. 2020 г., в 18:49, Tomas Vondra <tomas.vondra@2ndquadrant.com> написал(а):

On Thu, Oct 29, 2020 at 12:08:21PM +0500, Andrey Borodin wrote:

29 окт. 2020 г., в 04:32, Tomas Vondra <tomas.vondra@2ndquadrant.com> написал(а):

It's not my intention to be mean or anything like that, but to me this
means we don't really understand the problem we're trying to solve. Had
we understood it, we should be able to construct a workload reproducing
the issue ...

I understand what the individual patches are doing, and maybe those
changes are desirable in general. But without any benchmarks from a
plausible workload I find it hard to convince myself that:

(a) it actually will help with the issue you're observing on production

and
(b) it's actually worth the extra complexity (e.g. the lwlock changes)

I'm willing to invest some of my time into reviewing/testing this, but I
think we badly need better insight into the issue, so that we can build
a workload reproducing it. Perhaps collecting some perf profiles and a
sample of the queries might help, but I assume you already tried that.

Thanks, Tomas! This totally makes sense.

Indeed, collecting queries did not help yet. We have loadtest environment equivalent to production (but with 10x less shards), copy of production workload queries. But the problem does not manifest there.
Why do I think the problem is in MultiXacts?
Here is a chart with number of wait events on each host

During the problem MultiXactOffsetControlLock and SLRURead dominate all other lock types. After primary switchover to another node SLRURead continued for a bit there, then disappeared.

OK, so most of this seems to be due to SLRURead and
MultiXactOffsetControlLock. Could it be that there were too many
multixact members, triggering autovacuum to prevent multixact
wraparound? That might generate a lot of IO on the SLRU. Are you
monitoring the size of the pg_multixact directory?

Yes, we had some problems with 'multixact "members" limit exceeded' long time ago.
We tuned autovacuum_multixact_freeze_max_age = 200000000 and vacuum_multixact_freeze_table_age = 75000000 (half of defaults) and since then did not ever encounter this problem (~5 months).
But the MultiXactOffsetControlLock problem persists. Partially the problem was solved by adding more shards. But when one of shards encounters a problem it's either MultiXacts or vacuum causing relation truncation (unrelated to this thread).

Thanks!

Best regards, Andrey Borodin.

#29Tomas Vondra
tomas.vondra@enterprisedb.com
In reply to: Andrey Borodin (#28)
Re: MultiXact\SLRU buffers configuration

Hi,

After the issue reported in [1]/messages/by-id/20201104013205.icogbi773przyny5@development got fixed, I've restarted the multi-xact
stress test, hoping to reproduce the issue. But so far no luck :-(

I've started slightly different tests on two machines - on one machine
I've done this:

a) init.sql

create table t (a int);
insert into t select i from generate_series(1,100000000) s(i);
alter table t add primary key (a);

b) select.sql

SELECT * FROM t
WHERE a = (1+mod(abs(hashint4(extract(epoch from now())::int)),
100000000)) FOR KEY SHARE;

c) pgbench -n -c 32 -j 8 -f select.sql -T $((24*3600)) test

The idea is to have large table and many clients hitting a small random
subset of the rows. A sample of wait events from ~24h run looks like this:

e_type | e_name | sum
----------+----------------------+----------
LWLock | BufferContent | 13913863
| | 7194679
LWLock | WALWrite | 1710507
Activity | LogicalLauncherMain | 726599
Activity | AutoVacuumMain | 726127
Activity | WalWriterMain | 725183
Activity | CheckpointerMain | 604694
Client | ClientRead | 599900
IO | WALSync | 502904
Activity | BgWriterMain | 378110
Activity | BgWriterHibernate | 348464
IO | WALWrite | 129412
LWLock | ProcArray | 6633
LWLock | WALInsert | 5714
IO | SLRUWrite | 2580
IPC | ProcArrayGroupUpdate | 2216
LWLock | XactSLRU | 2196
Timeout | VacuumDelay | 1078
IPC | XactGroupUpdate | 737
LWLock | LockManager | 503
LWLock | WALBufMapping | 295
LWLock | MultiXactMemberSLRU | 267
IO | DataFileWrite | 68
LWLock | BufferIO | 59
IO | DataFileRead | 27
IO | DataFileFlush | 14
LWLock | MultiXactGen | 7
LWLock | BufferMapping | 1

So, nothing particularly interesting - there certainly are not many wait
events related to SLRU.

On the other machine I did this:

a) init.sql
create table t (a int primary key);
insert into t select i from generate_series(1,1000) s(i);

b) select.sql
select * from t for key share;

c) pgbench -n -c 32 -j 8 -f select.sql -T $((24*3600)) test

and the wait events (24h run too) look like this:

e_type | e_name | sum
-----------+-----------------------+----------
LWLock | BufferContent | 20804925
| | 2575369
Activity | LogicalLauncherMain | 745780
Activity | AutoVacuumMain | 745292
Activity | WalWriterMain | 740507
Activity | CheckpointerMain | 737691
Activity | BgWriterHibernate | 731123
LWLock | WALWrite | 570107
IO | WALSync | 452603
Client | ClientRead | 151438
BufferPin | BufferPin | 23466
LWLock | WALInsert | 21631
IO | WALWrite | 19050
LWLock | ProcArray | 15082
Activity | BgWriterMain | 14655
IPC | ProcArrayGroupUpdate | 7772
LWLock | WALBufMapping | 3555
IO | SLRUWrite | 1951
LWLock | MultiXactGen | 1661
LWLock | MultiXactMemberSLRU | 359
LWLock | MultiXactOffsetSLRU | 242
LWLock | XactSLRU | 141
IPC | XactGroupUpdate | 104
LWLock | LockManager | 28
IO | DataFileRead | 4
IO | ControlFileSyncUpdate | 1
Timeout | VacuumDelay | 1
IO | WALInitWrite | 1

Also nothing particularly interesting - few SLRU wait events.

So unfortunately this does not really reproduce the SLRU locking issues
you're observing - clearly, there has to be something else triggering
it. Perhaps this workload is too simplistic, or maybe we need to run
different queries. Or maybe the hw needs to be somewhat different (more
CPUs? different storage?)

[1]: /messages/by-id/20201104013205.icogbi773przyny5@development
/messages/by-id/20201104013205.icogbi773przyny5@development

regards

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#30Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Tomas Vondra (#29)
Re: MultiXact\SLRU buffers configuration

10 нояб. 2020 г., в 05:13, Tomas Vondra <tomas.vondra@enterprisedb.com> написал(а):
After the issue reported in [1] got fixed, I've restarted the multi-xact
stress test, hoping to reproduce the issue. But so far no luck :-(

Tomas, many thanks for looking into this. I figured out that to make multixact sets bigger transactions must hang for a while and lock large set of tuples. But not continuous range to avoid locking on buffer_content.
I did not manage to implement this via pgbench, that's why I was trying to hack on separate go program. But, essentially, no luck either.
I was observing something resemblant though

пятница, 8 мая 2020 г. 15:08:37 (every 1s)

pid | wait_event | wait_event_type | state | query
-------+----------------------------+-----------------+--------+----------------------------------------------------
41344 | ClientRead | Client | idle | insert into t1 select generate_series(1,1000000,1)
41375 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41377 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41378 | | | active | select * from t1 where i = ANY ($1) for share
41379 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41381 | | | active | select * from t1 where i = ANY ($1) for share
41383 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41385 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
(8 rows)

but this picture was not stable.

How do you collect wait events for aggregation? just insert into some table with cron?

Thanks!

Best regards, Andrey Borodin.

#31Tomas Vondra
tomas.vondra@enterprisedb.com
In reply to: Andrey Borodin (#30)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

On 11/10/20 7:16 AM, Andrey Borodin wrote:

10 нояб. 2020 г., в 05:13, Tomas Vondra <tomas.vondra@enterprisedb.com> написал(а):
After the issue reported in [1] got fixed, I've restarted the multi-xact
stress test, hoping to reproduce the issue. But so far no luck :-(

Tomas, many thanks for looking into this. I figured out that to make multixact sets bigger transactions must hang for a while and lock large set of tuples. But not continuous range to avoid locking on buffer_content.
I did not manage to implement this via pgbench, that's why I was trying to hack on separate go program. But, essentially, no luck either.
I was observing something resemblant though

пятница, 8 мая 2020 г. 15:08:37 (every 1s)

pid | wait_event | wait_event_type | state | query
-------+----------------------------+-----------------+--------+----------------------------------------------------
41344 | ClientRead | Client | idle | insert into t1 select generate_series(1,1000000,1)
41375 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41377 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41378 | | | active | select * from t1 where i = ANY ($1) for share
41379 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41381 | | | active | select * from t1 where i = ANY ($1) for share
41383 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
41385 | MultiXactOffsetControlLock | LWLock | active | select * from t1 where i = ANY ($1) for share
(8 rows)

but this picture was not stable.

Seems we haven't made much progress in reproducing the issue :-( I guess
we'll need to know more about the machine where this happens. Is there
anything special about the hardware/config? Are you monitoring size of
the pg_multixact directory?

How do you collect wait events for aggregation? just insert into some table with cron?

No, I have a simple shell script (attached) sampling data from
pg_stat_activity regularly. Then I load it into a table and aggregate to
get a summary.

regards

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachments:

collect-wait-events.shapplication/x-shellscript; name=collect-wait-events.shDownload
#32Thomas Munro
thomas.munro@gmail.com
In reply to: Tomas Vondra (#31)
Re: MultiXact\SLRU buffers configuration

On Wed, Nov 11, 2020 at 7:07 AM Tomas Vondra
<tomas.vondra@enterprisedb.com> wrote:

Seems we haven't made much progress in reproducing the issue :-( I guess
we'll need to know more about the machine where this happens. Is there
anything special about the hardware/config? Are you monitoring size of
the pg_multixact directory?

Which release was the original problem seen on?

#33Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Tomas Vondra (#31)
Re: MultiXact\SLRU buffers configuration

10 нояб. 2020 г., в 23:07, Tomas Vondra <tomas.vondra@enterprisedb.com> написал(а):

On 11/10/20 7:16 AM, Andrey Borodin wrote:

but this picture was not stable.

Seems we haven't made much progress in reproducing the issue :-( I guess
we'll need to know more about the machine where this happens. Is there
anything special about the hardware/config? Are you monitoring size of
the pg_multixact directory?

It's Ubuntu 18.04.4 LTS, Intel Xeon E5-2660 v4, 56 CPU cores with 256Gb of RAM.
PostgreSQL 10.14, compiled by gcc 7.5.0, 64-bit

No, unfortunately we do not have signals for SLRU sizes.
3.5Tb mdadm raid10 over 28 SSD drives, 82% full.

First incident triggering investigation was on 2020-04-19, at that time cluster was running on PG 10.11. But I think it was happening before.

I'd say nothing special...

How do you collect wait events for aggregation? just insert into some table with cron?

No, I have a simple shell script (attached) sampling data from
pg_stat_activity regularly. Then I load it into a table and aggregate to
get a summary.

Thanks!

Best regards, Andrey Borodin.

#34Gilles Darold
gilles@darold.net
In reply to: Andrey Borodin (#33)
Re: MultiXact\SLRU buffers configuration

Le 13/11/2020 à 12:49, Andrey Borodin a écrit :

10 нояб. 2020 г., в 23:07, Tomas Vondra <tomas.vondra@enterprisedb.com> написал(а):

On 11/10/20 7:16 AM, Andrey Borodin wrote:

but this picture was not stable.

Seems we haven't made much progress in reproducing the issue :-( I guess
we'll need to know more about the machine where this happens. Is there
anything special about the hardware/config? Are you monitoring size of
the pg_multixact directory?

It's Ubuntu 18.04.4 LTS, Intel Xeon E5-2660 v4, 56 CPU cores with 256Gb of RAM.
PostgreSQL 10.14, compiled by gcc 7.5.0, 64-bit

No, unfortunately we do not have signals for SLRU sizes.
3.5Tb mdadm raid10 over 28 SSD drives, 82% full.

First incident triggering investigation was on 2020-04-19, at that time cluster was running on PG 10.11. But I think it was happening before.

I'd say nothing special...

How do you collect wait events for aggregation? just insert into some table with cron?

No, I have a simple shell script (attached) sampling data from
pg_stat_activity regularly. Then I load it into a table and aggregate to
get a summary.

Thanks!

Best regards, Andrey Borodin.

Hi,

Some time ago I have encountered a contention on
MultiXactOffsetControlLock with a performances benchmark. Here are the
wait event monitoring result with a pooling each 10 seconds and a 30
minutes run for the benchmarl:

 event_type |           event            |   sum
------------+----------------------------+----------
 Client     | ClientRead                 | 44722952
 LWLock     | MultiXactOffsetControlLock | 30343060
 LWLock     | multixact_offset           | 16735250
 LWLock     | MultiXactMemberControlLock |  1601470
 LWLock     | buffer_content             |   991344
 LWLock     | multixact_member           |   805624
 Lock       | transactionid              |   204997
 Activity   | LogicalLauncherMain        |   198834
 Activity   | CheckpointerMain           |   198834
 Activity   | AutoVacuumMain             |   198469
 Activity   | BgWriterMain               |   184066
 Activity   | WalWriterMain              |   171571
 LWLock     | WALWriteLock               |    72428
 IO         | DataFileRead               |    35708
 Activity   | BgWriterHibernate          |    12741
 IO         | SLRURead                   |     9121
 Lock       | relation                   |     8858
 LWLock     | ProcArrayLock              |     7309
 LWLock     | lock_manager               |     6677
 LWLock     | pg_stat_statements         |     4194
 LWLock     | buffer_mapping             |     3222

After reading this thread I change the value of the buffer size to 32
and 64 and obtain the following results:

 event_type |           event            |    sum
------------+----------------------------+-----------
 Client     | ClientRead                 | 268297572
 LWLock     | MultiXactMemberControlLock |  65162906
 LWLock     | multixact_member           |  33397714
 LWLock     | buffer_content             |   4737065
 Lock       | transactionid              |   2143750
 LWLock     | SubtransControlLock        |   1318230
 LWLock     | WALWriteLock               |   1038999
 Activity   | LogicalLauncherMain        |    940598
 Activity   | AutoVacuumMain             |    938566
 Activity   | CheckpointerMain           |    799052
 Activity   | WalWriterMain              |    749069
 LWLock     | subtrans                   |    710163
 Activity   | BgWriterHibernate          |    536763
 Lock       | object                     |    514225
 Activity   | BgWriterMain               |    394206
 LWLock     | lock_manager               |    295616
 IO         | DataFileRead               |    274236
 LWLock     | ProcArrayLock              |     77099
 Lock       | tuple                      |     59043
 IO         | CopyFileWrite              |     45611
 Lock       | relation                   |     42714

There was still contention on multixact but less than the first run. I
have increased the buffers to 128 and 512 and obtain the best results
for this bench:

 event_type |           event            |    sum
------------+----------------------------+-----------
 Client     | ClientRead                 | 160463037
 LWLock     | MultiXactMemberControlLock |   5334188
 LWLock     | buffer_content             |   5228256
 LWLock     | buffer_mapping             |   2368505
 LWLock     | SubtransControlLock        |   2289977
 IPC        | ProcArrayGroupUpdate       |   1560875
 LWLock     | ProcArrayLock              |   1437750
 Lock       | transactionid              |    825561
 LWLock     | subtrans                   |    772701
 LWLock     | WALWriteLock               |    666138
 Activity   | LogicalLauncherMain        |    492585
 Activity   | CheckpointerMain           |    492458
 Activity   | AutoVacuumMain             |    491548
 LWLock     | lock_manager               |    426531
 Lock       | object                     |    403581
 Activity   | WalWriterMain              |    394668
 Activity   | BgWriterHibernate          |    293112
 Activity   | BgWriterMain               |    195312
 LWLock     | MultiXactGenLock           |    177820
 LWLock     | pg_stat_statements         |    173864
 IO         | DataFileRead               |    173009

I hope these metrics can have some interest to show the utility of this
patch but unfortunately I can not be more precise and provide reports
for the entire patch. The problem is that this benchmark is run on an
application that use PostgreSQL 11 and I can not back port the full
patch, there was too much changes since PG11. I have just increase the
size of NUM_MXACTOFFSET_BUFFERS and NUM_MXACTMEMBER_BUFFERS. This allow
us to triple the number of simultaneous connections between the first
and the last test.

I know that this report is not really helpful but at least I can give
more information on the benchmark that was used. This is the proprietary
zRef benchmark which compares the same Cobol programs (transactional and
batch) executed both on mainframes and on x86 servers. Instead  of a DB2
z/os database we use PostgreSQL v11. This test has extensive use of
cursors (each select, even read only, is executed through a cursor) and
the contention was observed with update on tables with some foreign
keys. There is no explicit FOR SHARE on the queries, only some FOR
UPDATE clauses. I guess that the multixact contention is the result of
the for share locks produced for FK.

So in our case being able to tune the multixact buffers could help a lot
to improve the performances.

--
Gilles Darold

#35Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Gilles Darold (#34)
4 attachment(s)
Re: MultiXact\SLRU buffers configuration

Hi Gilles!

Many thanks for your message!

8 дек. 2020 г., в 21:05, Gilles Darold <gilles@darold.net> написал(а):

I know that this report is not really helpful

Quite contrary - this benchmarks prove that controllable reproduction exists. I've rebased patches for PG11. Can you please benchmark them (without extending SLRU)?

Best regards, Andrey Borodin.

Attachments:

v1106-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-o.patchapplication/octet-stream; name=v1106-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-o.patch; x-unix-mode=0644Download
From dee5bf87314606e020a574b85cf1e9cbe066588d Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Tue, 27 Oct 2020 19:29:56 +0300
Subject: [PATCH v1106 1/4] Use shared lock in GetMultiXactIdMembers for
 offsets and members

Previously the read of multixact required exclusive control locks for both
offsets and members SLRUs.  This could lead to the excessive lock contention.
This commit we makes multixacts SLRU take advantage of SimpleLruReadPage_ReadOnly
similar to clog, commit_ts and subtrans.

In order to evade extra reacquiring of CLRU lock, we teach
SimpleLruReadPage_ReadOnly() to take into account the current lock mode and
report resulting lock mode back.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/clog.c      |  3 ++-
 src/backend/access/transam/commit_ts.c |  3 ++-
 src/backend/access/transam/multixact.c | 21 ++++++++++++++-------
 src/backend/access/transam/slru.c      | 23 +++++++++++++++++------
 src/backend/access/transam/subtrans.c  |  3 ++-
 src/backend/commands/async.c           |  6 ++++--
 src/backend/storage/lmgr/lwlock.c      |  3 +++
 src/backend/storage/lmgr/predicate.c   |  4 +++-
 src/include/access/slru.h              |  8 ++++----
 src/include/storage/lwlock.h           |  2 ++
 10 files changed, 53 insertions(+), 23 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index a8d1080f17..bdfbd10f96 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -640,10 +640,11 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	int			lsnindex;
 	char	   *byteptr;
 	XidStatus	status;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(ClogCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(ClogCtl, pageno, xid, &lockmode);
 	byteptr = ClogCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 6c4911d9bc..d7b6f583e1 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -288,6 +288,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	CommitTimestampEntry entry;
 	TransactionId oldestCommitTsXid;
 	TransactionId newestCommitTsXid;
+	LWLockMode	lockmode = LW_NONE;
 
 	if (!TransactionIdIsValid(xid))
 		ereport(ERROR,
@@ -342,7 +343,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, &lockmode);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 365daf153a..5ca10a139a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1216,6 +1216,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	MultiXactId tmpMXact;
 	MultiXactOffset nextOffset;
 	MultiXactMember *ptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
 
@@ -1319,12 +1320,13 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1356,7 +1358,8 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+												tmpMXact, &lockmode);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1380,8 +1383,7 @@ retry:
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
-
+	lockmode = LW_NONE;
 	truelength = 0;
 	prev_pageno = -1;
 	for (i = 0; i < length; i++, offset++)
@@ -1397,7 +1399,8 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno,
+												multi, &lockmode);
 			prev_pageno = pageno;
 		}
 
@@ -1420,6 +1423,7 @@ retry:
 		truelength++;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactMemberControlLock);
 
 	/*
@@ -2723,6 +2727,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 	int			entryno;
 	int			slotno;
 	MultiXactOffset *offptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(MultiXactState->finishedStartup);
 
@@ -2743,10 +2748,12 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetControlLock);
 
 	*result = offset;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index cfe9513827..f86950eb51 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -460,17 +460,23 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
- * It is unspecified whether the lock will be shared or exclusive.
+ * Control lock must be held in *lock_mode mode, which may be LW_NONE.  Control
+ * lock will be held at exit in at least shared mode.  Resulting control lock
+ * mode is set to *lock_mode.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid,
+						   LWLockMode *lock_mode)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (*lock_mode == LW_NONE)
+	{
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
+		*lock_mode = LW_SHARED;
+	}
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -486,8 +492,13 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
-	LWLockRelease(shared->ControlLock);
-	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+	if (*lock_mode != LW_EXCLUSIVE)
+	{
+		Assert(*lock_mode == LW_NONE);
+		LWLockRelease(shared->ControlLock);
+		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+		*lock_mode = LW_EXCLUSIVE;
+	}
 
 	return SimpleLruReadPage(ctl, pageno, true, xid);
 }
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index ef63b6d98a..440a21415a 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -113,6 +113,7 @@ SubTransGetParent(TransactionId xid)
 	int			slotno;
 	TransactionId *ptr;
 	TransactionId parent;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* Can't ask about stuff that might not be around anymore */
 	Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
@@ -123,7 +124,7 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, &lockmode);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 7f4e11bd90..4ebc069a5d 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -1834,6 +1834,7 @@ asyncQueueReadAllNotifications(void)
 			int			curoffset = QUEUE_POS_OFFSET(pos);
 			int			slotno;
 			int			copysize;
+			LWLockMode	lockmode = LW_NONE;
 
 			/*
 			 * We copy the data from SLRU into a local buffer, so as to avoid
@@ -1842,7 +1843,7 @@ asyncQueueReadAllNotifications(void)
 			 * of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(AsyncCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, &lockmode);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
@@ -1859,7 +1860,8 @@ asyncQueueReadAllNotifications(void)
 				   AsyncCtl->shared->page_buffer[slotno] + curoffset,
 				   copysize);
 			/* Release lock that we got from SimpleLruReadPage_ReadOnly() */
-			LWLockRelease(AsyncCtlLock);
+			Assert(lockmode != LW_NONE);
+			LWLockRelease(AsyncCtl);
 
 			/*
 			 * Process messages up to the stop position, end of page, or an
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 5aae233995..066dbb8ccf 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -982,6 +982,8 @@ LWLockWakeup(LWLock *lock)
 static void
 LWLockQueueSelf(LWLock *lock, LWLockMode mode)
 {
+	Assert(mode != LW_NONE);
+
 	/*
 	 * If we don't have a PGPROC structure, there's no way to wait. This
 	 * should never occur, since MyProc should only be null during shared
@@ -1742,6 +1744,7 @@ LWLockRelease(LWLock *lock)
 		elog(ERROR, "lock %s is not held", T_NAME(lock));
 
 	mode = held_lwlocks[i].mode;
+	Assert(mode == LW_EXCLUSIVE || mode == LW_SHARED);
 
 	num_held_lwlocks--;
 	for (; i < num_held_lwlocks; i++)
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 002d040ba6..9513fd915b 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -908,6 +908,7 @@ OldSerXidGetMinConflictCommitSeqNo(TransactionId xid)
 	TransactionId tailXid;
 	SerCommitSeqNo val;
 	int			slotno;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(TransactionIdIsValid(xid));
 
@@ -930,8 +931,9 @@ OldSerXidGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(OldSerXidSlruCtl,
-										OldSerXidPage(xid), xid);
+										OldSerXidPage(xid), xid, &lockmode);
 	val = OldSerXidValue(slotno, xid);
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(OldSerXidLock);
 	return val;
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 0e89e48c97..51a3df62e0 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -141,10 +141,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
 extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 			  LWLock *ctllock, const char *subdir, int tranche_id);
 extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
-				  TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-						   TransactionId xid);
+extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+							  TransactionId xid);
+extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+									   TransactionId xid, LWLockMode *lock_mode);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruFlush(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index c21bfe2f66..3263c0fe62 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -131,6 +131,8 @@ extern PGDLLIMPORT int NamedLWLockTrancheRequests;
 
 typedef enum LWLockMode
 {
+	LW_NONE,					/* Not a lock mode. Indicates that there is no
+								 * lock. */
 	LW_EXCLUSIVE,
 	LW_SHARED,
 	LW_WAIT_UNTIL_FREE			/* A special mode used in PGPROC->lwlockMode,
-- 
2.24.3 (Apple Git-128)

v1106-0002-Make-MultiXact-local-cache-size-configurable.patchapplication/octet-stream; name=v1106-0002-Make-MultiXact-local-cache-size-configurable.patch; x-unix-mode=0644Download
From 649c5c25349c32aecf02fad46197234af95f9860 Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 03:44:50 +0300
Subject: [PATCH v1106 2/4] Make MultiXact local cache size configurable

---
 doc/src/sgml/config.sgml               | 37 ++++++++++++++++++++++++++
 src/backend/access/transam/multixact.c |  2 +-
 src/backend/utils/init/globals.c       |  2 ++
 src/backend/utils/misc/guc.c           | 10 +++++++
 src/include/miscadmin.h                |  2 ++
 5 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 3570b422be..15fb2f2bde 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1637,6 +1637,43 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+     <varlistentry id="guc-logical-decoding-work-mem" xreflabel="logical_decoding_work_mem">
+      <term><varname>logical_decoding_work_mem</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>logical_decoding_work_mem</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the maximum amount of memory to be used by logical decoding,
+        before some of the decoded changes are written to local disk. This
+        limits the amount of memory used by logical streaming replication
+        connections. It defaults to 64 megabytes (<literal>64MB</literal>).
+        Since each replication connection only uses a single buffer of this size,
+        and an installation normally doesn't have many such connections
+        concurrently (as limited by <varname>max_wal_senders</varname>), it's
+        safe to set this value significantly higher than <varname>work_mem</varname>,
+        reducing the amount of decoded changes written to disk.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-local-cache-entries" xreflabel="multixact_local-cache-entries">
+      <term><varname>multixact_local_cache_entries</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_local_cache_entries</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded
+        by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while
+        lower values make cache lookup faster.
+        It defaults to 256.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 5ca10a139a..6203be0aa3 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1591,7 +1591,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
 	qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator);
 
 	dlist_push_head(&MXactCache, &entry->node);
-	if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
+	if (MXactCacheMembers++ >= multixact_local_cache_entries)
 	{
 		dlist_node *node;
 		mXactCacheEnt *entry;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index f7d6617a13..22af834150 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -147,3 +147,5 @@ int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
 
 double		vacuum_cleanup_index_scale_factor;
+
+int         multixact_local_cache_entries = 256;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 710344c72b..b54a063782 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2026,6 +2026,16 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM,
+			gettext_noop("Sets the number of cached MultiXact by backend."),
+			NULL
+		},
+		&multixact_local_cache_entries,
+		256, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 8024145535..11c3c8e6c5 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -161,6 +161,8 @@ extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
 
+extern PGDLLIMPORT int multixact_local_cache_entries;
+
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
 extern PGDLLIMPORT struct Port *MyProcPort;
-- 
2.24.3 (Apple Git-128)

v1106-0003-Add-conditional-variable-to-wait-for-next-Mult.patchapplication/octet-stream; name=v1106-0003-Add-conditional-variable-to-wait-for-next-Mult.patch; x-unix-mode=0644Download
From 38dc550f363c1c8878fbf06d5616614a36112fac Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 01:55:31 +0300
Subject: [PATCH v1106 3/4] Add conditional variable to wait for next MultXact
 offset in corner case

GetMultiXactIdMembers() has a corner case, when the next multixact offset is
not yet set.  In this case GetMultiXactIdMembers() has to sleep till this offset
is set.  Currently the sleeping is implemented in naive way using pg_sleep()
and retry.  This commit implements sleeping with conditional variable, which
provides more efficient way for waiting till the event.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/multixact.c | 35 ++++++++++++++++++++++++--
 src/backend/postmaster/pgstat.c        |  3 +++
 src/include/pgstat.h                   |  3 ++-
 3 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 6203be0aa3..5d2bbb1ca6 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,13 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	/*
+	 * Conditional variable for waiting till the filling of the next multixact
+	 * will be finished.  See GetMultiXactIdMembers() and RecordNewMultiXact()
+	 * for details.
+	 */
+	ConditionVariable nextoffCV;
+
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -871,6 +879,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetControlLock);
 
+	/*
+	 * Let everybody know the offset of this mxid is recorded now.  The
+	 * waiters are waiting for the offset of the mxid next of the target to
+	 * know the number of members of the target mxid, so we don't need to wait
+	 * for members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoffCV);
+
 	LWLockAcquire(MultiXactMemberControlLock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1368,9 +1384,23 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the
+			 * offset. Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoffCV);
+
+			/*
+			 * We don't have to recheck if multixact was filled in during
+			 * ConditionVariablePrepareToSleep(), because we were holding
+			 * MultiXactOffsetSLRULock.
+			 */
 			LWLockRelease(MultiXactOffsetControlLock);
-			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoffCV,
+								   WAIT_EVENT_WAIT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1849,6 +1879,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoffCV);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 4895354a28..8a8b9a4eef 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3730,6 +3730,9 @@ pgstat_get_wait_ipc(WaitEventIPC w)
 		case WAIT_EVENT_SYNC_REP:
 			event_name = "SyncRep";
 			break;
+		case WAIT_EVENT_WAIT_NEXT_MXMEMBERS:
+			event_name = "MultiXactWaitNextMembers";
+			break;
 			/* no default case, so that compiler will warn */
 	}
 
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 58e2e71c6f..e89d946669 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -832,7 +832,8 @@ typedef enum
 	WAIT_EVENT_REPLICATION_ORIGIN_DROP,
 	WAIT_EVENT_REPLICATION_SLOT_DROP,
 	WAIT_EVENT_SAFE_SNAPSHOT,
-	WAIT_EVENT_SYNC_REP
+	WAIT_EVENT_SYNC_REP,
+	WAIT_EVENT_WAIT_NEXT_MXMEMBERS
 } WaitEventIPC;
 
 /* ----------
-- 
2.24.3 (Apple Git-128)

v1106-0004-Add-GUCs-to-tune-MultiXact-SLRUs.patchapplication/octet-stream; name=v1106-0004-Add-GUCs-to-tune-MultiXact-SLRUs.patch; x-unix-mode=0644Download
From e273a508592236dbf5c60417b5878961c2483bca Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sat, 9 May 2020 16:42:07 +0500
Subject: [PATCH v1106 4/4] Add GUCs to tune MultiXact SLRUs

---
 doc/src/sgml/config.sgml               | 31 ++++++++++++++++++++++++++
 src/backend/access/transam/multixact.c |  8 +++----
 src/backend/utils/init/globals.c       |  2 ++
 src/backend/utils/misc/guc.c           | 22 ++++++++++++++++++
 src/include/access/multixact.h         |  4 ----
 src/include/miscadmin.h                |  2 ++
 6 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 15fb2f2bde..44ebacc713 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1673,6 +1673,37 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-slru-buffers" xreflabel="multixact_offsets_slru_buffers">
+      <term><varname>multixact_offsets_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact offsets. MultiXact offsets
+        are used to store informaion about offsets of multiple row lockers (caused by SELECT FOR UPDATE and others).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-slru-buffers" xreflabel="multixact_members_slru_buffers">
+      <term><varname>multixact_members_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact members. MultiXact members
+        are used to store informaion about XIDs of multiple row lockers. Tipically <varname>multixact_members_slru_buffers</varname>
+        is twice more than <varname>multixact_offsets_slru_buffers</varname>.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 5d2bbb1ca6..31324714b8 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1844,8 +1844,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_slru_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_slru_buffers, 0));
 
 	return size;
 }
@@ -1861,11 +1861,11 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "multixact_offset", NUM_MXACTOFFSET_BUFFERS, 0,
+				  "multixact_offset", multixact_offsets_slru_buffers, 0,
 				  MultiXactOffsetControlLock, "pg_multixact/offsets",
 				  LWTRANCHE_MXACTOFFSET_BUFFERS);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "multixact_member", NUM_MXACTMEMBER_BUFFERS, 0,
+				  "multixact_member", multixact_members_slru_buffers, 0,
 				  MultiXactMemberControlLock, "pg_multixact/members",
 				  LWTRANCHE_MXACTMEMBER_BUFFERS);
 
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 22af834150..5a8517f8eb 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -149,3 +149,5 @@ bool		VacuumCostActive = false;
 double		vacuum_cleanup_index_scale_factor;
 
 int         multixact_local_cache_entries = 256;
+int			multixact_offsets_slru_buffers = 8;
+int			multixact_members_slru_buffers = 16;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index b54a063782..578452d757 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2036,6 +2036,28 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 18fe380c5f..6e14fb7b29 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -28,10 +28,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MXACTOFFSET_BUFFERS		8
-#define NUM_MXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 11c3c8e6c5..e3fd0a264d 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -160,6 +160,8 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
 
 extern PGDLLIMPORT int multixact_local_cache_entries;
 
-- 
2.24.3 (Apple Git-128)

#36Gilles Darold
gilles@darold.net
In reply to: Andrey Borodin (#35)
Re: MultiXact\SLRU buffers configuration

Hi Andrey,

Thanks for the backport. I have issue with the first patch "Use shared
lock in GetMultiXactIdMembers for offsets and members"
(v1106-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-o.patch) the
applications are not working anymore when I'm applying it. Also PG
regression tests are failing too on several part.

test insert_conflict              ... ok
test create_function_1            ... FAILED
test create_type                  ... FAILED
test create_table                 ... FAILED
test create_function_2            ... FAILED
test copy                         ... FAILED
test copyselect                   ... ok
test copydml                      ... ok
test create_misc                  ... FAILED
test create_operator              ... FAILED
test create_procedure             ... ok
test create_index                 ... FAILED
test index_including              ... ok
test create_view                  ... FAILED
test create_aggregate             ... ok
test create_function_3            ... ok
test create_cast                  ... ok
test constraints                  ... FAILED
test triggers                     ... FAILED
test inherit                      ...
^C

This is also where I left my last try to back port for PG11, I will try
to fix it again but it could take time to have it working.

Best regards,

--
Gilles Darold

Le 08/12/2020 à 18:52, Andrey Borodin a écrit :

Show quoted text

Hi Gilles!

Many thanks for your message!

8 дек. 2020 г., в 21:05, Gilles Darold <gilles@darold.net> написал(а):

I know that this report is not really helpful

Quite contrary - this benchmarks prove that controllable reproduction exists. I've rebased patches for PG11. Can you please benchmark them (without extending SLRU)?

Best regards, Andrey Borodin.

#37Gilles Darold
gilles@darold.net
In reply to: Gilles Darold (#36)
Re: MultiXact\SLRU buffers configuration

Le 09/12/2020 à 11:51, Gilles Darold a écrit :

Also PG regression tests are failing too on several part.

Forget this, I have not run the regression tests in the right repository:

...

=======================
 All 189 tests passed.
=======================

I'm looking why the application is failing.

--
Gilles Darold
http://www.darold.net/

#38Gilles Darold
gilles@darold.net
In reply to: Andrey Borodin (#35)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

Le 08/12/2020 à 18:52, Andrey Borodin a écrit :

Hi Gilles!

Many thanks for your message!

8 дек. 2020 г., в 21:05, Gilles Darold <gilles@darold.net> написал(а):

I know that this report is not really helpful

Quite contrary - this benchmarks prove that controllable reproduction exists. I've rebased patches for PG11. Can you please benchmark them (without extending SLRU)?

Best regards, Andrey Borodin.

Hi,

Running tests yesterday with the patches has reported log of failures
with error on INSERT and UPDATE statements:

ERROR:  lock MultiXactOffsetControlLock is not held

After a patch review this morning I think I have found what's going
wrong. In patch
v6-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patch I think
there is a missing reinitialisation of the lockmode variable to LW_NONE
inside the retry loop after the call to LWLockRelease() in
src/backend/access/transam/multixact.c:1392:GetMultiXactIdMembers().
I've attached a new version of the patch for master that include the fix
I'm using now with PG11 and with which everything works very well now.

I'm running more tests to see the impact on the performances to play
with multixact_offsets_slru_buffers, multixact_members_slru_buffers and
multixact_local_cache_entries. I will reports the results later today.

--
Gilles Darold
http://www.darold.net/

Attachments:

v7-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchtext/x-patch; charset=UTF-8; name=v7-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patchDownload
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 034349aa7b..4c372065de 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -640,10 +640,11 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	int			lsnindex;
 	char	   *byteptr;
 	XidStatus	status;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid, &lockmode);
 	byteptr = XactCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
@@ -651,6 +652,7 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	lsnindex = GetLSNIndex(slotno, xid);
 	*lsn = XactCtl->shared->group_lsn[lsnindex];
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(XactSLRULock);
 
 	return status;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 2fe551f17e..2699de033d 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -288,6 +288,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	CommitTimestampEntry entry;
 	TransactionId oldestCommitTsXid;
 	TransactionId newestCommitTsXid;
+	LWLockMode	lockmode = LW_NONE;
 
 	if (!TransactionIdIsValid(xid))
 		ereport(ERROR,
@@ -342,7 +343,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, &lockmode);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
@@ -352,6 +353,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	if (nodeid)
 		*nodeid = entry.nodeid;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(CommitTsSLRULock);
 	return *ts != 0;
 }
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index eb8de7cf32..56bdd04364 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1237,6 +1237,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	MultiXactId tmpMXact;
 	MultiXactOffset nextOffset;
 	MultiXactMember *ptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
 
@@ -1340,12 +1341,13 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1377,7 +1379,8 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+												tmpMXact, &lockmode);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1387,6 +1390,7 @@ retry:
 		{
 			/* Corner case 2: next multixact is still being filled in */
 			LWLockRelease(MultiXactOffsetSLRULock);
+			lockmode = LW_NONE;
 			CHECK_FOR_INTERRUPTS();
 			pg_usleep(1000L);
 			goto retry;
@@ -1395,14 +1399,14 @@ retry:
 		length = nextMXOffset - offset;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember));
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
-
+	lockmode = LW_NONE;
 	truelength = 0;
 	prev_pageno = -1;
 	for (i = 0; i < length; i++, offset++)
@@ -1418,7 +1422,8 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno,
+												multi, &lockmode);
 			prev_pageno = pageno;
 		}
 
@@ -1441,6 +1446,7 @@ retry:
 		truelength++;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactMemberSLRULock);
 
 	/*
@@ -2733,6 +2739,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 	int			entryno;
 	int			slotno;
 	MultiXactOffset *offptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(MultiXactState->finishedStartup);
 
@@ -2749,10 +2756,12 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	*result = offset;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index cec17cb2ae..e271b37d7b 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -487,17 +487,23 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
- * It is unspecified whether the lock will be shared or exclusive.
+ * Control lock must be held in *lock_mode mode, which may be LW_NONE.  Control
+ * lock will be held at exit in at least shared mode.  Resulting control lock
+ * mode is set to *lock_mode.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid,
+						   LWLockMode *lock_mode)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (*lock_mode == LW_NONE)
+	{
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
+		*lock_mode = LW_SHARED;
+	}
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -517,8 +523,13 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
-	LWLockRelease(shared->ControlLock);
-	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+	if (*lock_mode != LW_EXCLUSIVE)
+	{
+		Assert(*lock_mode == LW_NONE);
+		LWLockRelease(shared->ControlLock);
+		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+		*lock_mode = LW_EXCLUSIVE;
+	}
 
 	return SimpleLruReadPage(ctl, pageno, true, xid);
 }
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 0111e867c7..7bb1543189 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -113,6 +113,7 @@ SubTransGetParent(TransactionId xid)
 	int			slotno;
 	TransactionId *ptr;
 	TransactionId parent;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* Can't ask about stuff that might not be around anymore */
 	Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
@@ -123,12 +124,13 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, &lockmode);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
 	parent = *ptr;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SubtransSLRULock);
 
 	return parent;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index c0763c63e2..ef1dbbe53d 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2011,6 +2011,7 @@ asyncQueueReadAllNotifications(void)
 			int			curoffset = QUEUE_POS_OFFSET(pos);
 			int			slotno;
 			int			copysize;
+			LWLockMode	lockmode = LW_NONE;
 
 			/*
 			 * We copy the data from SLRU into a local buffer, so as to avoid
@@ -2019,7 +2020,7 @@ asyncQueueReadAllNotifications(void)
 			 * part of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(NotifyCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, &lockmode);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
@@ -2036,6 +2037,7 @@ asyncQueueReadAllNotifications(void)
 				   NotifyCtl->shared->page_buffer[slotno] + curoffset,
 				   copysize);
 			/* Release lock that we got from SimpleLruReadPage_ReadOnly() */
+			Assert(lockmode != LW_NONE);
 			LWLockRelease(NotifySLRULock);
 
 			/*
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 108e652179..ad1dcc7140 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -1067,6 +1067,8 @@ LWLockWakeup(LWLock *lock)
 static void
 LWLockQueueSelf(LWLock *lock, LWLockMode mode)
 {
+	Assert(mode != LW_NONE);
+
 	/*
 	 * If we don't have a PGPROC structure, there's no way to wait. This
 	 * should never occur, since MyProc should only be null during shared
@@ -1827,6 +1829,7 @@ LWLockRelease(LWLock *lock)
 		elog(ERROR, "lock %s is not held", T_NAME(lock));
 
 	mode = held_lwlocks[i].mode;
+	Assert(mode == LW_EXCLUSIVE || mode == LW_SHARED);
 
 	num_held_lwlocks--;
 	for (; i < num_held_lwlocks; i++)
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8a365b400c..a4df90a8ae 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -924,6 +924,7 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	TransactionId tailXid;
 	SerCommitSeqNo val;
 	int			slotno;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(TransactionIdIsValid(xid));
 
@@ -946,8 +947,9 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(SerialSlruCtl,
-										SerialPage(xid), xid);
+										SerialPage(xid), xid, &lockmode);
 	val = SerialValue(slotno, xid);
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SerialSLRULock);
 	return val;
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index b39b43504d..4b66d3b592 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -142,7 +142,7 @@ extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 							  TransactionId xid);
 extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-									   TransactionId xid);
+									   TransactionId xid, LWLockMode *lock_mode);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index af9b41795d..e680c6397a 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -129,6 +129,8 @@ extern PGDLLIMPORT int NamedLWLockTrancheRequests;
 
 typedef enum LWLockMode
 {
+	LW_NONE,					/* Not a lock mode. Indicates that there is no
+								 * lock. */
 	LW_EXCLUSIVE,
 	LW_SHARED,
 	LW_WAIT_UNTIL_FREE			/* A special mode used in PGPROC->lwWaitMode,
#39Gilles Darold
gilles@darold.net
In reply to: Gilles Darold (#38)
Re: MultiXact\SLRU buffers configuration

Le 10/12/2020 à 15:45, Gilles Darold a écrit :

Le 08/12/2020 à 18:52, Andrey Borodin a écrit :

Hi Gilles!

Many thanks for your message!

8 дек. 2020 г., в 21:05, Gilles Darold<gilles@darold.net> написал(а):

I know that this report is not really helpful

Quite contrary - this benchmarks prove that controllable reproduction exists. I've rebased patches for PG11. Can you please benchmark them (without extending SLRU)?

Best regards, Andrey Borodin.

Hi,

Running tests yesterday with the patches has reported log of failures
with error on INSERT and UPDATE statements:

ERROR:  lock MultiXactOffsetControlLock is not held

After a patch review this morning I think I have found what's going
wrong. In patch
v6-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patch I
think there is a missing reinitialisation of the lockmode variable to
LW_NONE inside the retry loop after the call to LWLockRelease() in
src/backend/access/transam/multixact.c:1392:GetMultiXactIdMembers().
I've attached a new version of the patch for master that include the
fix I'm using now with PG11 and with which everything works very well now.

I'm running more tests to see the impact on the performances to play
with multixact_offsets_slru_buffers, multixact_members_slru_buffers
and multixact_local_cache_entries. I will reports the results later today.

Hi,

Sorry for the delay, I have done some further tests to try to reach the
limit without bottlenecks on multixact or shared buffers. The tests was
done on a Microsoft Asure machine with 2TB of RAM and 4 sockets Intel
Xeon Platinum 8280M (128 cpu). PG configuration:

    max_connections = 4096
    shared_buffers = 64GB
    max_prepared_transactions = 2048
    work_mem = 256MB
    maintenance_work_mem = 2GB
    wal_level = minimal
    synchronous_commit = off
    commit_delay = 1000
    commit_siblings = 10
    checkpoint_timeout = 1h
    max_wal_size = 32GB
    checkpoint_completion_target = 0.9

I have tested with several values for the different buffer's variables
starting from:

    multixact_offsets_slru_buffers = 64
    multixact_members_slru_buffers = 128
    multixact_local_cache_entries = 256

to the values with the best performances we achieve with this test to
avoid MultiXactOffsetControlLock or MultiXactMemberControlLock:

    multixact_offsets_slru_buffers = 128
    multixact_members_slru_buffers = 512
    multixact_local_cache_entries = 1024

Also shared_buffers have been increased up to 256GB to avoid
buffer_mapping contention.

Our last best test reports the following wait events:

     event_type |           event            |    sum
    ------------+----------------------------+-----------
     Client     | ClientRead                 | 321690211
     LWLock     | buffer_content             |   2970016
     IPC        | ProcArrayGroupUpdate       |   2317388
     LWLock     | ProcArrayLock              |   1445828
     LWLock     | WALWriteLock               |   1187606
     LWLock     | SubtransControlLock        |    972889
     Lock       | transactionid              |    840560
     Lock       | relation                   |    587600
     Activity   | LogicalLauncherMain        |    529599
     Activity   | AutoVacuumMain             |    528097

At this stage I don't think we can have better performances by tuning
these buffers at least with PG11.

About performances gain related to the patch for shared lock in
GetMultiXactIdMembers unfortunately I can not see a difference with or
without this patch, it could be related to our particular benchmark. But
clearly the patch on multixact buffers should be committed as this is
really helpfull to be able to tuned PG when multixact bottlenecks are found.

Best regards,

--
Gilles Darold
LzLabs GmbH
https://www.lzlabs.com/

#40Gilles Darold
gilles@darold.net
In reply to: Gilles Darold (#39)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

Le 11/12/2020 à 18:50, Gilles Darold a écrit :

Le 10/12/2020 à 15:45, Gilles Darold a écrit :

Le 08/12/2020 à 18:52, Andrey Borodin a écrit :

Hi Gilles!

Many thanks for your message!

8 дек. 2020 г., в 21:05, Gilles Darold <gilles@darold.net> написал(а):

I know that this report is not really helpful

Quite contrary - this benchmarks prove that controllable reproduction exists. I've rebased patches for PG11. Can you please benchmark them (without extending SLRU)?

Best regards, Andrey Borodin.

Hi,

Running tests yesterday with the patches has reported log of failures
with error on INSERT and UPDATE statements:

ERROR:  lock MultiXactOffsetControlLock is not held

After a patch review this morning I think I have found what's going
wrong. In patch
v6-0001-Use-shared-lock-in-GetMultiXactIdMembers-for-offs.patch I
think there is a missing reinitialisation of the lockmode variable to
LW_NONE inside the retry loop after the call to LWLockRelease() in
src/backend/access/transam/multixact.c:1392:GetMultiXactIdMembers().
I've attached a new version of the patch for master that include the
fix I'm using now with PG11 and with which everything works very well
now.

I'm running more tests to see the impact on the performances to play
with multixact_offsets_slru_buffers, multixact_members_slru_buffers
and multixact_local_cache_entries. I will reports the results later
today.

Hi,

Sorry for the delay, I have done some further tests to try to reach
the limit without bottlenecks on multixact or shared buffers. The
tests was done on a Microsoft Asure machine with 2TB of RAM and 4
sockets Intel Xeon Platinum 8280M (128 cpu). PG configuration:

    max_connections = 4096
    shared_buffers = 64GB
    max_prepared_transactions = 2048
    work_mem = 256MB
    maintenance_work_mem = 2GB
    wal_level = minimal
    synchronous_commit = off
    commit_delay = 1000
    commit_siblings = 10
    checkpoint_timeout = 1h
    max_wal_size = 32GB
    checkpoint_completion_target = 0.9

I have tested with several values for the different buffer's variables
starting from:

    multixact_offsets_slru_buffers = 64
    multixact_members_slru_buffers = 128
    multixact_local_cache_entries = 256

to the values with the best performances we achieve with this test to
avoid MultiXactOffsetControlLock or MultiXactMemberControlLock:

    multixact_offsets_slru_buffers = 128
    multixact_members_slru_buffers = 512
    multixact_local_cache_entries = 1024

Also shared_buffers have been increased up to 256GB to avoid
buffer_mapping contention.

Our last best test reports the following wait events:

     event_type |           event            |    sum
    ------------+----------------------------+-----------
     Client     | ClientRead                 | 321690211
     LWLock     | buffer_content             |   2970016
     IPC        | ProcArrayGroupUpdate       |   2317388
     LWLock     | ProcArrayLock              |   1445828
     LWLock     | WALWriteLock               |   1187606
     LWLock     | SubtransControlLock        |    972889
     Lock       | transactionid              |    840560
     Lock       | relation                   |    587600
     Activity   | LogicalLauncherMain        |    529599
     Activity   | AutoVacuumMain             |    528097

At this stage I don't think we can have better performances by tuning
these buffers at least with PG11.

About performances gain related to the patch for shared lock in
GetMultiXactIdMembers unfortunately I can not see a difference with or
without this patch, it could be related to our particular benchmark.
But clearly the patch on multixact buffers should be committed as this
is really helpfull to be able to tuned PG when multixact bottlenecks
are found.

I've done more review on these patches.

1) as reported in my previous message patch 0001 looks useless as it
doesn't allow measurable performances gain.

2) In patch 0004 there is two typo: s/informaion/information/ will fix them

3) the GUC are missing in the postgresql.conf.sample file, see patch in
attachment for a proposal.

Best regards,

--
Gilles Darold
LzLabs GmbH
https://www.lzlabs.com/

Attachments:

postgresql_conf_multixact_buffers_GUCs.patchtext/x-patch; charset=UTF-8; name=postgresql_conf_multixact_buffers_GUCs.patchDownload
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index b7fb2ec1fe..1fb33809ee 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -189,6 +189,14 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - MultiXact Buffers -
+
+#multixact_offsets_slru_buffers = 8	# memory used for MultiXact offsets
+					# (change requires restart)
+#multixact_members_slru_buffers = 16	# memory used for MultiXact members
+					# (change requires restart)
+#multixact_local_cache_entries = 256	# number of cached MultiXact by backend
+					# (change requires restart)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
#41Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Gilles Darold (#40)
Re: MultiXact\SLRU buffers configuration

13 дек. 2020 г., в 14:17, Gilles Darold <gilles@darold.net> написал(а):

I've done more review on these patches.

Thanks, Gilles! I'll incorporate all your fixes to patchset.
Can you also benchmark conditional variable sleep? The patch "Add conditional variable to wait for next MultXact offset in corner case"?
The problem manifests on Standby when Primary is heavily loaded with MultiXactOffsetControlLock.

Thanks!

Best regards, Andrey Borodin.

#42Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Andrey Borodin (#41)
4 attachment(s)
Re: MultiXact\SLRU buffers configuration

13 дек. 2020 г., в 22:24, Andrey Borodin <x4mmm@yandex-team.ru> написал(а):

13 дек. 2020 г., в 14:17, Gilles Darold <gilles@darold.net> написал(а):

I've done more review on these patches.

Thanks, Gilles! I'll incorporate all your fixes to patchset.

PFA patches.
Also, I've noted that patch "Add conditional variable to wait for next MultXact offset in corner case" removes CHECK_FOR_INTERRUPTS();, I'm not sure it's correct.

Thanks!

Best regards, Andrey Borodin.

Attachments:

v8-0004-Add-GUCs-to-tune-MultiXact-SLRUs.patchapplication/octet-stream; name=v8-0004-Add-GUCs-to-tune-MultiXact-SLRUs.patch; x-unix-mode=0644Download
From 122fcbf0a0e38d6ba7880b22ec093aa8bb8011e4 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sat, 9 May 2020 16:42:07 +0500
Subject: [PATCH v8 4/4] Add GUCs to tune MultiXact SLRUs

---
 doc/src/sgml/config.sgml                      | 31 +++++++++++++++++++
 src/backend/access/transam/multixact.c        |  8 ++---
 src/backend/utils/init/globals.c              |  2 ++
 src/backend/utils/misc/guc.c                  | 22 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |  8 +++++
 src/include/access/multixact.h                |  4 ---
 src/include/miscadmin.h                       |  2 ++
 7 files changed, 69 insertions(+), 8 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index d9c27daa49..fab9715e83 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1860,6 +1860,37 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-slru-buffers" xreflabel="multixact_offsets_slru_buffers">
+      <term><varname>multixact_offsets_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact offsets. MultiXact offsets
+        are used to store information about offsets of multiple row lockers (caused by SELECT FOR UPDATE and others).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-slru-buffers" xreflabel="multixact_members_slru_buffers">
+      <term><varname>multixact_members_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact members. MultiXact members
+        are used to store information about XIDs of multiple row lockers. Tipically <varname>multixact_members_slru_buffers</varname>
+        is twice more than <varname>multixact_offsets_slru_buffers</varname>.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index ffd35c2aea..76b4ad75bc 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1867,8 +1867,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_slru_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_slru_buffers, 0));
 
 	return size;
 }
@@ -1884,12 +1884,12 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_slru_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_members_slru_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 9ca71933dc..a5ec7bfe88 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -151,3 +151,5 @@ bool		VacuumCostActive = false;
 double		vacuum_cleanup_index_scale_factor;
 
 int         multixact_local_cache_entries = 256;
+int			multixact_offsets_slru_buffers = 8;
+int			multixact_members_slru_buffers = 16;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index ae2a3e1304..d86d34b4a5 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2257,6 +2257,28 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index b7fb2ec1fe..1fb33809ee 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -189,6 +189,14 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - MultiXact Buffers -
+
+#multixact_offsets_slru_buffers = 8	# memory used for MultiXact offsets
+					# (change requires restart)
+#multixact_members_slru_buffers = 16	# memory used for MultiXact members
+					# (change requires restart)
+#multixact_local_cache_entries = 256	# number of cached MultiXact by backend
+					# (change requires restart)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 9a30380901..630ceaea4d 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 01af61c963..ef8abea84d 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -161,6 +161,8 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
 
 extern PGDLLIMPORT int multixact_local_cache_entries;
 
-- 
2.24.3 (Apple Git-128)

v8-0003-Add-conditional-variable-to-wait-for-next-MultXac.patchapplication/octet-stream; name=v8-0003-Add-conditional-variable-to-wait-for-next-MultXac.patch; x-unix-mode=0644Download
From 2706550cd4fc9ef53b8fa09d7414e88a31ea6e0e Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 01:55:31 +0300
Subject: [PATCH v8 3/4] Add conditional variable to wait for next MultXact
 offset in corner case

GetMultiXactIdMembers() has a corner case, when the next multixact offset is
not yet set.  In this case GetMultiXactIdMembers() has to sleep till this offset
is set.  Currently the sleeping is implemented in naive way using pg_sleep()
and retry.  This commit implements sleeping with conditional variable, which
provides more efficient way for waiting till the event.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/multixact.c | 35 ++++++++++++++++++++++++--
 src/backend/postmaster/pgstat.c        |  2 ++
 src/include/pgstat.h                   |  1 +
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 171e2ab681..ffd35c2aea 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,13 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	/*
+	 * Conditional variable for waiting till the filling of the next multixact
+	 * will be finished.  See GetMultiXactIdMembers() and RecordNewMultiXact()
+	 * for details.
+	 */
+	ConditionVariable nextoffCV;
+
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -892,6 +900,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
 
+	/*
+	 * Let everybody know the offset of this mxid is recorded now.  The
+	 * waiters are waiting for the offset of the mxid next of the target to
+	 * know the number of members of the target mxid, so we don't need to wait
+	 * for members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoffCV);
+
 	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1389,10 +1405,24 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the
+			 * offset. Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoffCV);
+
+			/*
+			 * We don't have to recheck if multixact was filled in during
+			 * ConditionVariablePrepareToSleep(), because we were holding
+			 * MultiXactOffsetSLRULock.
+			 */
 			LWLockRelease(MultiXactOffsetSLRULock);
 			lockmode = LW_NONE;
-			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoffCV,
+								   WAIT_EVENT_WAIT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1874,6 +1904,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoffCV);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 7c75a25d21..20879fc90e 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -4041,6 +4041,8 @@ pgstat_get_wait_ipc(WaitEventIPC w)
 			break;
 		case WAIT_EVENT_XACT_GROUP_UPDATE:
 			event_name = "XactGroupUpdate";
+		case WAIT_EVENT_WAIT_NEXT_MXMEMBERS:
+			event_name = "MultiXactWaitNextMembers";
 			break;
 			/* no default case, so that compiler will warn */
 	}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 5954068dec..630ddcf1a5 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -964,6 +964,7 @@ typedef enum
 	WAIT_EVENT_REPLICATION_SLOT_DROP,
 	WAIT_EVENT_SAFE_SNAPSHOT,
 	WAIT_EVENT_SYNC_REP,
+	WAIT_EVENT_WAIT_NEXT_MXMEMBERS,
 	WAIT_EVENT_XACT_GROUP_UPDATE
 } WaitEventIPC;
 
-- 
2.24.3 (Apple Git-128)

v8-0002-Make-MultiXact-local-cache-size-configurable.patchapplication/octet-stream; name=v8-0002-Make-MultiXact-local-cache-size-configurable.patch; x-unix-mode=0644Download
From 25f78196b00d5489924cb09e802ddda48c410d8d Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Mon, 26 Oct 2020 03:44:50 +0300
Subject: [PATCH v8 2/4] Make MultiXact local cache size configurable

---
 doc/src/sgml/config.sgml               | 16 ++++++++++++++++
 src/backend/access/transam/multixact.c |  2 +-
 src/backend/utils/init/globals.c       |  2 ++
 src/backend/utils/misc/guc.c           | 10 ++++++++++
 src/include/miscadmin.h                |  2 ++
 5 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 4b60382778..d9c27daa49 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1845,6 +1845,22 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-multixact-local-cache-entries" xreflabel="multixact_local-cache-entries">
+      <term><varname>multixact_local_cache_entries</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_local_cache_entries</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded
+        by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while
+        lower values make cache lookup faster.
+        It defaults to 256.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 56bdd04364..171e2ab681 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1614,7 +1614,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
 	qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator);
 
 	dlist_push_head(&MXactCache, &entry->node);
-	if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
+	if (MXactCacheMembers++ >= multixact_local_cache_entries)
 	{
 		dlist_node *node;
 		mXactCacheEnt *entry;
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 6ab8216839..9ca71933dc 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -149,3 +149,5 @@ int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
 
 double		vacuum_cleanup_index_scale_factor;
+
+int         multixact_local_cache_entries = 256;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index dabcbb0736..ae2a3e1304 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2247,6 +2247,16 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM,
+			gettext_noop("Sets the number of cached MultiXact by backend."),
+			NULL
+		},
+		&multixact_local_cache_entries,
+		256, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 72e3352398..01af61c963 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,8 @@ extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
 
+extern PGDLLIMPORT int multixact_local_cache_entries;
+
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
 extern PGDLLIMPORT TimestampTz MyStartTimestamp;
-- 
2.24.3 (Apple Git-128)

v8-0001-Use-shared-lock-in-GetMultiXactIdMembers-for.patchapplication/octet-stream; name=v8-0001-Use-shared-lock-in-GetMultiXactIdMembers-for.patch; x-unix-mode=0644Download
From 4c8c7d0f24fdce994412b6c104d72659cf6fc14f Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 14 Dec 2020 11:24:46 +0500
Subject: [PATCH v8 1/4] Use shared lock in GetMultiXactIdMembers for  offsets
 and members

Previously the read of multixact required exclusive control locks for both
offsets and members SLRUs.  This could lead to the excessive lock contention.
This commit we makes multixacts SLRU take advantage of SimpleLruReadPage_ReadOnly
similar to clog, commit_ts and subtrans.

In order to evade extra reacquiring of CLRU lock, we teach
SimpleLruReadPage_ReadOnly() to take into account the current lock mode and
report resulting lock mode back.

Discussion: https://postgr.es/m/a7f1c4e1-1015-92a4-2bd4-6736bd13d03e%40postgrespro.ru#c496c4e75fc0605094a0e1f763e6a6ec
Author: Andrey Borodin
Reviewed-by: Kyotaro Horiguchi, Daniel Gustafsson
Reviewed-by: Anastasia Lubennikova, Alexander Korotkov
---
 src/backend/access/transam/clog.c      |  4 +++-
 src/backend/access/transam/commit_ts.c |  4 +++-
 src/backend/access/transam/multixact.c | 23 ++++++++++++++++-------
 src/backend/access/transam/slru.c      | 23 +++++++++++++++++------
 src/backend/access/transam/subtrans.c  |  4 +++-
 src/backend/commands/async.c           |  4 +++-
 src/backend/storage/lmgr/lwlock.c      |  3 +++
 src/backend/storage/lmgr/predicate.c   |  4 +++-
 src/include/access/slru.h              |  2 +-
 src/include/storage/lwlock.h           |  2 ++
 10 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 034349aa7b..4c372065de 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -640,10 +640,11 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	int			lsnindex;
 	char	   *byteptr;
 	XidStatus	status;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(XactCtl, pageno, xid, &lockmode);
 	byteptr = XactCtl->shared->page_buffer[slotno] + byteno;
 
 	status = (*byteptr >> bshift) & CLOG_XACT_BITMASK;
@@ -651,6 +652,7 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	lsnindex = GetLSNIndex(slotno, xid);
 	*lsn = XactCtl->shared->group_lsn[lsnindex];
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(XactSLRULock);
 
 	return status;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 2fe551f17e..2699de033d 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -288,6 +288,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	CommitTimestampEntry entry;
 	TransactionId oldestCommitTsXid;
 	TransactionId newestCommitTsXid;
+	LWLockMode	lockmode = LW_NONE;
 
 	if (!TransactionIdIsValid(xid))
 		ereport(ERROR,
@@ -342,7 +343,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	}
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(CommitTsCtl, pageno, xid, &lockmode);
 	memcpy(&entry,
 		   CommitTsCtl->shared->page_buffer[slotno] +
 		   SizeOfCommitTimestampEntry * entryno,
@@ -352,6 +353,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
 	if (nodeid)
 		*nodeid = entry.nodeid;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(CommitTsSLRULock);
 	return *ts != 0;
 }
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index eb8de7cf32..56bdd04364 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1237,6 +1237,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	MultiXactId tmpMXact;
 	MultiXactOffset nextOffset;
 	MultiXactMember *ptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
 
@@ -1340,12 +1341,13 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
 	 * time on every multixact creation.
 	 */
 retry:
-	LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
 
 	pageno = MultiXactIdToOffsetPage(multi);
 	entryno = MultiXactIdToOffsetEntry(multi);
 
-	slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, multi);
+	/* lock is acquired by SimpleLruReadPage_ReadOnly */
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
@@ -1377,7 +1379,8 @@ retry:
 		entryno = MultiXactIdToOffsetEntry(tmpMXact);
 
 		if (pageno != prev_pageno)
-			slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, true, tmpMXact);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+												tmpMXact, &lockmode);
 
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
@@ -1387,6 +1390,7 @@ retry:
 		{
 			/* Corner case 2: next multixact is still being filled in */
 			LWLockRelease(MultiXactOffsetSLRULock);
+			lockmode = LW_NONE;
 			CHECK_FOR_INTERRUPTS();
 			pg_usleep(1000L);
 			goto retry;
@@ -1395,14 +1399,14 @@ retry:
 		length = nextMXOffset - offset;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember));
 	*members = ptr;
 
 	/* Now get the members themselves. */
-	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
-
+	lockmode = LW_NONE;
 	truelength = 0;
 	prev_pageno = -1;
 	for (i = 0; i < length; i++, offset++)
@@ -1418,7 +1422,8 @@ retry:
 
 		if (pageno != prev_pageno)
 		{
-			slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, true, multi);
+			slotno = SimpleLruReadPage_ReadOnly(MultiXactMemberCtl, pageno,
+												multi, &lockmode);
 			prev_pageno = pageno;
 		}
 
@@ -1441,6 +1446,7 @@ retry:
 		truelength++;
 	}
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactMemberSLRULock);
 
 	/*
@@ -2733,6 +2739,7 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 	int			entryno;
 	int			slotno;
 	MultiXactOffset *offptr;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(MultiXactState->finishedStartup);
 
@@ -2749,10 +2756,12 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
 		return false;
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
-	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno, multi);
+	slotno = SimpleLruReadPage_ReadOnly(MultiXactOffsetCtl, pageno,
+										multi, &lockmode);
 	offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 	offptr += entryno;
 	offset = *offptr;
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(MultiXactOffsetSLRULock);
 
 	*result = offset;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index cec17cb2ae..e271b37d7b 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -487,17 +487,23 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
  * Return value is the shared-buffer slot number now holding the page.
  * The buffer's LRU access info is updated.
  *
- * Control lock must NOT be held at entry, but will be held at exit.
- * It is unspecified whether the lock will be shared or exclusive.
+ * Control lock must be held in *lock_mode mode, which may be LW_NONE.  Control
+ * lock will be held at exit in at least shared mode.  Resulting control lock
+ * mode is set to *lock_mode.
  */
 int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid,
+						   LWLockMode *lock_mode)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
 
 	/* Try to find the page while holding only shared lock */
-	LWLockAcquire(shared->ControlLock, LW_SHARED);
+	if (*lock_mode == LW_NONE)
+	{
+		LWLockAcquire(shared->ControlLock, LW_SHARED);
+		*lock_mode = LW_SHARED;
+	}
 
 	/* See if page is already in a buffer */
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -517,8 +523,13 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
-	LWLockRelease(shared->ControlLock);
-	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+	if (*lock_mode != LW_EXCLUSIVE)
+	{
+		Assert(*lock_mode == LW_NONE);
+		LWLockRelease(shared->ControlLock);
+		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
+		*lock_mode = LW_EXCLUSIVE;
+	}
 
 	return SimpleLruReadPage(ctl, pageno, true, xid);
 }
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 0111e867c7..7bb1543189 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -113,6 +113,7 @@ SubTransGetParent(TransactionId xid)
 	int			slotno;
 	TransactionId *ptr;
 	TransactionId parent;
+	LWLockMode	lockmode = LW_NONE;
 
 	/* Can't ask about stuff that might not be around anymore */
 	Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
@@ -123,12 +124,13 @@ SubTransGetParent(TransactionId xid)
 
 	/* lock is acquired by SimpleLruReadPage_ReadOnly */
 
-	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid);
+	slotno = SimpleLruReadPage_ReadOnly(SubTransCtl, pageno, xid, &lockmode);
 	ptr = (TransactionId *) SubTransCtl->shared->page_buffer[slotno];
 	ptr += entryno;
 
 	parent = *ptr;
 
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SubtransSLRULock);
 
 	return parent;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index c0763c63e2..ef1dbbe53d 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2011,6 +2011,7 @@ asyncQueueReadAllNotifications(void)
 			int			curoffset = QUEUE_POS_OFFSET(pos);
 			int			slotno;
 			int			copysize;
+			LWLockMode	lockmode = LW_NONE;
 
 			/*
 			 * We copy the data from SLRU into a local buffer, so as to avoid
@@ -2019,7 +2020,7 @@ asyncQueueReadAllNotifications(void)
 			 * part of the page we will actually inspect.
 			 */
 			slotno = SimpleLruReadPage_ReadOnly(NotifyCtl, curpage,
-												InvalidTransactionId);
+												InvalidTransactionId, &lockmode);
 			if (curpage == QUEUE_POS_PAGE(head))
 			{
 				/* we only want to read as far as head */
@@ -2036,6 +2037,7 @@ asyncQueueReadAllNotifications(void)
 				   NotifyCtl->shared->page_buffer[slotno] + curoffset,
 				   copysize);
 			/* Release lock that we got from SimpleLruReadPage_ReadOnly() */
+			Assert(lockmode != LW_NONE);
 			LWLockRelease(NotifySLRULock);
 
 			/*
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 108e652179..ad1dcc7140 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -1067,6 +1067,8 @@ LWLockWakeup(LWLock *lock)
 static void
 LWLockQueueSelf(LWLock *lock, LWLockMode mode)
 {
+	Assert(mode != LW_NONE);
+
 	/*
 	 * If we don't have a PGPROC structure, there's no way to wait. This
 	 * should never occur, since MyProc should only be null during shared
@@ -1827,6 +1829,7 @@ LWLockRelease(LWLock *lock)
 		elog(ERROR, "lock %s is not held", T_NAME(lock));
 
 	mode = held_lwlocks[i].mode;
+	Assert(mode == LW_EXCLUSIVE || mode == LW_SHARED);
 
 	num_held_lwlocks--;
 	for (; i < num_held_lwlocks; i++)
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8a365b400c..a4df90a8ae 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -924,6 +924,7 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	TransactionId tailXid;
 	SerCommitSeqNo val;
 	int			slotno;
+	LWLockMode	lockmode = LW_NONE;
 
 	Assert(TransactionIdIsValid(xid));
 
@@ -946,8 +947,9 @@ SerialGetMinConflictCommitSeqNo(TransactionId xid)
 	 * but will return with that lock held, which must then be released.
 	 */
 	slotno = SimpleLruReadPage_ReadOnly(SerialSlruCtl,
-										SerialPage(xid), xid);
+										SerialPage(xid), xid, &lockmode);
 	val = SerialValue(slotno, xid);
+	Assert(lockmode != LW_NONE);
 	LWLockRelease(SerialSLRULock);
 	return val;
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index b39b43504d..4b66d3b592 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -142,7 +142,7 @@ extern int	SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int	SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 							  TransactionId xid);
 extern int	SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-									   TransactionId xid);
+									   TransactionId xid, LWLockMode *lock_mode);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
 extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index af9b41795d..e680c6397a 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -129,6 +129,8 @@ extern PGDLLIMPORT int NamedLWLockTrancheRequests;
 
 typedef enum LWLockMode
 {
+	LW_NONE,					/* Not a lock mode. Indicates that there is no
+								 * lock. */
 	LW_EXCLUSIVE,
 	LW_SHARED,
 	LW_WAIT_UNTIL_FREE			/* A special mode used in PGPROC->lwWaitMode,
-- 
2.24.3 (Apple Git-128)

#43Gilles Darold
gilles@darold.net
In reply to: Andrey Borodin (#41)
Re: MultiXact\SLRU buffers configuration

Le 13/12/2020 à 18:24, Andrey Borodin a écrit :

13 дек. 2020 г., в 14:17, Gilles Darold <gilles@darold.net> написал(а):

I've done more review on these patches.

Thanks, Gilles! I'll incorporate all your fixes to patchset.
Can you also benchmark conditional variable sleep? The patch "Add conditional variable to wait for next MultXact offset in corner case"?
The problem manifests on Standby when Primary is heavily loaded with MultiXactOffsetControlLock.

Thanks!

Best regards, Andrey Borodin.

Hi Andrey,

Sorry for the response delay, we have run several others tests trying to
figure out the performances gain per patch but unfortunately we have
very heratic results. With the same parameters and patches the test
doesn't returns the same results following the day or the hour of the
day. This is very frustrating and I suppose that this is related to the
Azure architecture. The only thing that I am sure is that we had the
best performances results with all patches and

multixact_offsets_slru_buffers = 256
multixact_members_slru_buffers = 512
multixact_local_cache_entries = 4096

but I can not say if all or part of the patches are improving the
performances. My feeling is that performances gain related to patches 1
(shared lock) and 3 (conditional variable) do not have much to do with
the performances gain compared to just tuning the multixact buffers.
This is when the multixact contention is observed but perhaps they are
delaying the contention. It's all the more frustrating that we had a
test case to reproduce the contention but not the architecture apparently.

Can't do much more at this point.

Best regards,

--
Gilles Darold
LzLabs GmbH
http://www.lzlabs.com/

#44Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Gilles Darold (#43)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

23 дек. 2020 г., в 21:31, Gilles Darold <gilles@darold.net> написал(а):

Sorry for the response delay, we have run several others tests trying to figure out the performances gain per patch but unfortunately we have very heratic results. With the same parameters and patches the test doesn't returns the same results following the day or the hour of the day. This is very frustrating and I suppose that this is related to the Azure architecture. The only thing that I am sure is that we had the best performances results with all patches and

multixact_offsets_slru_buffers = 256
multixact_members_slru_buffers = 512
multixact_local_cache_entries = 4096

but I can not say if all or part of the patches are improving the performances. My feeling is that performances gain related to patches 1 (shared lock) and 3 (conditional variable) do not have much to do with the performances gain compared to just tuning the multixact buffers. This is when the multixact contention is observed but perhaps they are delaying the contention. It's all the more frustrating that we had a test case to reproduce the contention but not the architecture apparently.

Hi! Thanks for the input.
I think we have a consensus here that configuring SLRU size is beneficial for MultiXacts.
There is proposal in nearby thread [0]/messages/by-id/20210115220744.GA24457@alvherre.pgsql on changing default value of commit_ts SLRU buffers.
In my experience from time to time there can be problems with subtransactions cured by extending subtrans SLRU.

Let's make all SLRUs configurable?
PFA patch with draft of these changes.

Best regards, Andrey Borodin.

[0]: /messages/by-id/20210115220744.GA24457@alvherre.pgsql

Attachments:

v9-0001-Make-all-SLRU-buffer-sizes-configurable.patchapplication/octet-stream; name=v9-0001-Make-all-SLRU-buffer-sizes-configurable.patch; x-unix-mode=0644Download
From 1b488106f7dfc142f219bb8ba0a0c5d2b6b94ba5 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v9] Make all SLRU buffer sizes configurable

---
 doc/src/sgml/config.sgml                      | 101 ++++++++++++++++++
 src/backend/access/transam/clog.c             |   6 ++
 src/backend/access/transam/commit_ts.c        |   5 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  77 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |  16 +++
 src/include/access/multixact.h                |   4 -
 src/include/access/subtrans.h                 |   3 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   8 ++
 src/include/storage/predicate.h               |   4 -
 15 files changed, 233 insertions(+), 29 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 4df1405d2e..5b24b435f3 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1852,6 +1852,107 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-slru-buffers" xreflabel="multixact_offsets_slru_buffers">
+      <term><varname>multixact_offsets_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact offsets. MultiXact offsets
+        are used to store information about offsets of multiple row lockers (caused by SELECT FOR UPDATE and others).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-slru-buffers" xreflabel="multixact_members_slru_buffers">
+      <term><varname>multixact_members_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact members. MultiXact members
+        are used to store information about XIDs of multiple row lockers. Tipically <varname>multixact_members_slru_buffers</varname>
+        is twice more than <varname>multixact_offsets_slru_buffers</varname>.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_slru_buffers">
+      <term><varname>subtrans_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for subtransactions.
+        It defaults to 256 kilobytes (<literal>256KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_slru_buffers">
+      <term><varname>notify_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for asincronous notifications (NOTIFY, LISTEN).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_slru_buffers">
+      <term><varname>serial_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for predicate locks.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-clog-buffers" xreflabel="clog_slru_buffers">
+      <term><varname>clog_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>clog_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for CLOG.
+        It defaults to 0, in this case CLOG size is taken as <varname>shared_buffers</varname> / 512.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_slru_buffers">
+      <term><varname>commit_ts_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for commit timestamps.
+        It defaults to 0, in this case CLOG size is taken as <varname>shared_buffers</varname> / 512.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..e57106b374 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -659,6 +659,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
+ * If values is confugured via GUC - just use given value. Otherwise
+ * apply following euristics.
+ *
  * On larger multi-processor systems, it is possible to have many CLOG page
  * requests in flight at one time which could lead to disk access for CLOG
  * page if the required page is not found in memory.  Testing revealed that we
@@ -675,6 +678,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 Size
 CLOGShmemBuffers(void)
 {
+	/* consider 0 and 1 as unset GUC */
+	if (clog_slru_buffers > 1)
+		return clog_slru_buffers;
 	return Min(128, Max(4, NBuffers / 512));
 }
 
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 48e8d66286..7de3bca63d 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -530,7 +530,10 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* consider 0 and 1 as unset GUC */
+	if (commit_ts_slru_buffers > 1)
+		return commit_ts_slru_buffers;
+	return Min(16, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 7dcfa02323..dd7dd19ff4 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_slru_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_slru_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_slru_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_slru_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..0c24353d3a 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_slru_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_slru_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 42b232d98b..a7dd92add0 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_slru_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_slru_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_slru_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_slru_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 074df5b38c..ad6d800dbd 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_slru_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_slru_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index a5976ad5b1..88e785c246 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -150,3 +150,11 @@ int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
 
 double		vacuum_cleanup_index_scale_factor;
+
+int			multixact_offsets_slru_buffers = 8;
+int			multixact_members_slru_buffers = 16;
+int			subtrans_slru_buffers = 32;
+int			notify_slru_buffers = 8;
+int			serial_slru_buffers = 16;
+int			clog_slru_buffers = 0;
+int			commit_ts_slru_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index eafdb1118e..d30f85bff8 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2269,6 +2269,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for substrnsactions SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_slru_buffers,
+		32, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for asyncronous notifications SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for predicate locks SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"clog_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit log SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_slru_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"commit_ts_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit timestamps SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_slru_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index db6db376eb..e88271c048 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -189,6 +189,22 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers -
+
+#multixact_offsets_slru_buffers = 8	# memory used for MultiXact offsets
+					# (change requires restart)
+#multixact_members_slru_buffers = 16	# memory used for MultiXact members
+					# (change requires restart)
+#subtrans_slru_buffers = 32			# memory used for subtransactions
+					# (change requires restart)
+#notify_slru_buffers = 8			# memory used for asynchronous notifications
+					# (change requires restart)
+#serial_slru_buffers = 16			# memory used for predicate locks
+					# (change requires restart)
+#clog_slru_buffers = 0				# memory used for CLOG
+					# (change requires restart)
+#commit_ts_slru_buffers = 0			# memory used for commit timestamps
+					# (change requires restart)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..ca0999056e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,9 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
-
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
 extern TransactionId SubTransGetTopmostTransaction(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 1bdc97e308..51c7ec8d68 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,14 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int subtrans_slru_buffers;
+extern PGDLLIMPORT int notify_slru_buffers;
+extern PGDLLIMPORT int serial_slru_buffers;
+extern PGDLLIMPORT int clog_slru_buffers;
+extern PGDLLIMPORT int commit_ts_slru_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.24.3 (Apple Git-128)

#45Gilles Darold
gilles@darold.net
In reply to: Andrey Borodin (#44)
Re: MultiXact\SLRU buffers configuration

Le 15/02/2021 à 18:17, Andrey Borodin a écrit :

23 дек. 2020 г., в 21:31, Gilles Darold <gilles@darold.net> написал(а):

Sorry for the response delay, we have run several others tests trying to figure out the performances gain per patch but unfortunately we have very heratic results. With the same parameters and patches the test doesn't returns the same results following the day or the hour of the day. This is very frustrating and I suppose that this is related to the Azure architecture. The only thing that I am sure is that we had the best performances results with all patches and

multixact_offsets_slru_buffers = 256
multixact_members_slru_buffers = 512
multixact_local_cache_entries = 4096

but I can not say if all or part of the patches are improving the performances. My feeling is that performances gain related to patches 1 (shared lock) and 3 (conditional variable) do not have much to do with the performances gain compared to just tuning the multixact buffers. This is when the multixact contention is observed but perhaps they are delaying the contention. It's all the more frustrating that we had a test case to reproduce the contention but not the architecture apparently.

Hi! Thanks for the input.
I think we have a consensus here that configuring SLRU size is beneficial for MultiXacts.
There is proposal in nearby thread [0] on changing default value of commit_ts SLRU buffers.
In my experience from time to time there can be problems with subtransactions cured by extending subtrans SLRU.

Let's make all SLRUs configurable?
PFA patch with draft of these changes.

Best regards, Andrey Borodin.

[0] /messages/by-id/20210115220744.GA24457@alvherre.pgsql

The patch doesn't apply anymore in master cause of error: patch failed:
src/backend/utils/init/globals.c:150

An other remark about this patch is that it should be mentionned in the
documentation (doc/src/sgml/config.sgml) that the new configuration
variables need a server restart, for example by adding "This parameter
can only be set at server start." like for shared_buffers. Patch on
postgresql.conf mention it.

And some typo to be fixed:

s/Tipically/Typically/

s/asincronous/asyncronous/

s/confugured/configured/

s/substrnsactions/substransactions/

--
Gilles Darold
LzLabs GmbH

#46Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Gilles Darold (#45)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

11 марта 2021 г., в 20:50, Gilles Darold <gilles@darold.net> написал(а):

The patch doesn't apply anymore in master cause of error: patch failed: src/backend/utils/init/globals.c:150

An other remark about this patch is that it should be mentionned in the documentation (doc/src/sgml/config.sgml) that the new configuration variables need a server restart, for example by adding "This parameter can only be set at server start." like for shared_buffers. Patch on postgresql.conf mention it.

And some typo to be fixed:

s/Tipically/Typically/

s/asincronous/asyncronous/

s/confugured/configured/

s/substrnsactions/substransactions/

Thanks, Gilles! Fixed.

Best regards, Andrey Borodin.

Attachments:

v10-0001-Make-all-SLRU-buffer-sizes-configurable.patchapplication/octet-stream; name=v10-0001-Make-all-SLRU-buffer-sizes-configurable.patch; x-unix-mode=0644Download
From 02c5d56a65a187b0795fac246a77f9cf3107ed3b Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v10] Make all SLRU buffer sizes configurable

---
 doc/src/sgml/config.sgml                      | 108 ++++++++++++++++++
 src/backend/access/transam/clog.c             |   6 +
 src/backend/access/transam/commit_ts.c        |   5 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  77 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |  16 +++
 src/include/access/multixact.h                |   4 -
 src/include/access/subtrans.h                 |   3 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   8 ++
 src/include/storage/predicate.h               |   4 -
 15 files changed, 240 insertions(+), 29 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index a218d78bef..eb7f8f3c49 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1886,6 +1886,114 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-slru-buffers" xreflabel="multixact_offsets_slru_buffers">
+      <term><varname>multixact_offsets_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact offsets. MultiXact offsets
+        are used to store information about offsets of multiple row lockers (caused by SELECT FOR UPDATE and others).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-slru-buffers" xreflabel="multixact_members_slru_buffers">
+      <term><varname>multixact_members_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact members. MultiXact members
+        are used to store information about XIDs of multiple row lockers. Typically <varname>multixact_members_slru_buffers</varname>
+        is twice more than <varname>multixact_offsets_slru_buffers</varname>.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_slru_buffers">
+      <term><varname>subtrans_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for subtransactions.
+        It defaults to 256 kilobytes (<literal>256KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_slru_buffers">
+      <term><varname>notify_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for asyncronous notifications (NOTIFY, LISTEN).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_slru_buffers">
+      <term><varname>serial_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for predicate locks.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-clog-buffers" xreflabel="clog_slru_buffers">
+      <term><varname>clog_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>clog_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for CLOG.
+        It defaults to 0, in this case CLOG size is taken as <varname>shared_buffers</varname> / 512.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_slru_buffers">
+      <term><varname>commit_ts_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for commit timestamps.
+        It defaults to 0, in this case CLOG size is taken as <varname>shared_buffers</varname> / 512.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..e1d34aa361 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -659,6 +659,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
+ * If values is configured via GUC - just use given value. Otherwise
+ * apply following euristics.
+ *
  * On larger multi-processor systems, it is possible to have many CLOG page
  * requests in flight at one time which could lead to disk access for CLOG
  * page if the required page is not found in memory.  Testing revealed that we
@@ -675,6 +678,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 Size
 CLOGShmemBuffers(void)
 {
+	/* consider 0 and 1 as unset GUC */
+	if (clog_slru_buffers > 1)
+		return clog_slru_buffers;
 	return Min(128, Max(4, NBuffers / 512));
 }
 
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 48e8d66286..7de3bca63d 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -530,7 +530,10 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* consider 0 and 1 as unset GUC */
+	if (commit_ts_slru_buffers > 1)
+		return commit_ts_slru_buffers;
+	return Min(16, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1f9f1a1fa1..370c01e72b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_slru_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_slru_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_slru_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_slru_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..0c24353d3a 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_slru_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_slru_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 4b16fb5682..f5c5592057 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_slru_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_slru_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_slru_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_slru_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d493aeef0f..fad8cc572e 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_slru_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_slru_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 73e0a672ae..f163ca17e9 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -148,3 +148,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_slru_buffers = 8;
+int			multixact_members_slru_buffers = 16;
+int			subtrans_slru_buffers = 32;
+int			notify_slru_buffers = 8;
+int			serial_slru_buffers = 16;
+int			clog_slru_buffers = 0;
+int			commit_ts_slru_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 855076b1fd..080b3a9b35 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2279,6 +2279,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for substransactions SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_slru_buffers,
+		32, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for asyncronous notifications SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for predicate locks SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"clog_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit log SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_slru_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"commit_ts_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit timestamps SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_slru_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index f46c2dd7a8..9ee7d17e8b 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -190,6 +190,22 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers -
+
+#multixact_offsets_slru_buffers = 8	# memory used for MultiXact offsets
+					# (change requires restart)
+#multixact_members_slru_buffers = 16	# memory used for MultiXact members
+					# (change requires restart)
+#subtrans_slru_buffers = 32			# memory used for subtransactions
+					# (change requires restart)
+#notify_slru_buffers = 8			# memory used for asynchronous notifications
+					# (change requires restart)
+#serial_slru_buffers = 16			# memory used for predicate locks
+					# (change requires restart)
+#clog_slru_buffers = 0				# memory used for CLOG
+					# (change requires restart)
+#commit_ts_slru_buffers = 0			# memory used for commit timestamps
+					# (change requires restart)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..ca0999056e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,9 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
-
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
 extern TransactionId SubTransGetTopmostTransaction(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 54693e047a..ca88b20ffa 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,14 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int subtrans_slru_buffers;
+extern PGDLLIMPORT int notify_slru_buffers;
+extern PGDLLIMPORT int serial_slru_buffers;
+extern PGDLLIMPORT int clog_slru_buffers;
+extern PGDLLIMPORT int commit_ts_slru_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.24.3 (Apple Git-128)

#47Gilles Darold
gilles@darold.net
In reply to: Andrey Borodin (#46)
Re: MultiXact\SLRU buffers configuration

Le 12/03/2021 à 13:44, Andrey Borodin a écrit :

11 марта 2021 г., в 20:50, Gilles Darold <gilles@darold.net> написал(а):

The patch doesn't apply anymore in master cause of error: patch failed: src/backend/utils/init/globals.c:150

An other remark about this patch is that it should be mentionned in the documentation (doc/src/sgml/config.sgml) that the new configuration variables need a server restart, for example by adding "This parameter can only be set at server start." like for shared_buffers. Patch on postgresql.conf mention it.

And some typo to be fixed:

s/Tipically/Typically/

s/asincronous/asyncronous/

s/confugured/configured/

s/substrnsactions/substransactions/

Thanks, Gilles! Fixed.

Best regards, Andrey Borodin.

Hi Andrey,

I found two problems in this patch, first in src/include/miscadmin.h
multixact_members_slru_buffers is declared twice:

 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;  <---------
+extern PGDLLIMPORT int subtrans_slru_buffers;

In file src/backend/access/transam/multixact.c the second variable
should be multixact_buffers_slru_buffers and not
multixact_offsets_slru_buffers.

@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
        MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;

        SimpleLruInit(MultiXactOffsetCtl,
-                                 "MultiXactOffset",
NUM_MULTIXACTOFFSET_BUFFERS, 0,
+                                 "MultiXactOffset",
multixact_offsets_slru_buffers, 0,
                                  MultiXactOffsetSLRULock,
"pg_multixact/offsets",
                                  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
                                  SYNC_HANDLER_MULTIXACT_OFFSET);
        SlruPagePrecedesUnitTests(MultiXactOffsetCtl,
MULTIXACT_OFFSETS_PER_PAGE);
        SimpleLruInit(MultiXactMemberCtl,
-                                 "MultiXactMember",
NUM_MULTIXACTMEMBER_BUFFERS, 0,
+                                 "MultiXactMember",
multixact_offsets_slru_buffers, 0,    <------------------
                                  MultiXactMemberSLRULock,
"pg_multixact/members",
                                  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
                                  SYNC_HANDLER_MULTIXACT_MEMBER);

Please fix them so that I can end the review.

--
Gilles Darold
LzLabs GmbH
http://www.lzlabs.com/

#48Thomas Munro
thomas.munro@gmail.com
In reply to: Andrey Borodin (#46)
2 attachment(s)
Re: MultiXact\SLRU buffers configuration

Hi Andrey,

On Sat, Mar 13, 2021 at 1:44 AM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

[v10]

+int            multixact_offsets_slru_buffers = 8;
+int            multixact_members_slru_buffers = 16;
+int            subtrans_slru_buffers = 32;
+int            notify_slru_buffers = 8;
+int            serial_slru_buffers = 16;
+int            clog_slru_buffers = 0;
+int            commit_ts_slru_buffers = 0;

I don't think we should put "slru" (the name of the buffer replacement
algorithm, implementation detail) in the GUC names.

+ It defaults to 0, in this case CLOG size is taken as
<varname>shared_buffers</varname> / 512.

We already know that increasing the number of CLOG buffers above the
current number hurts as the linear search begins to dominate
(according to the commit message for 5364b357), and it doesn't seem
great to ship a new feature that melts your CPU when you turn it up.
Perhaps, to ship this, we need to introduce a buffer mapping table? I
have attached a "one coffee" attempt at that, on top of your v10 patch
(unmodified), for discussion. It survives basic testing but I don't
know how it performs.

Attachments:

v10-0001-Make-all-SLRU-buffer-sizes-configurable.patchtext/x-patch; charset=US-ASCII; name=v10-0001-Make-all-SLRU-buffer-sizes-configurable.patchDownload
From 4817d16cfb6704d43a7bef12648e753d239c809c Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v10 1/2] Make all SLRU buffer sizes configurable

---
 doc/src/sgml/config.sgml                      | 108 ++++++++++++++++++
 src/backend/access/transam/clog.c             |   6 +
 src/backend/access/transam/commit_ts.c        |   5 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  77 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |  16 +++
 src/include/access/multixact.h                |   4 -
 src/include/access/subtrans.h                 |   3 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   8 ++
 src/include/storage/predicate.h               |   4 -
 15 files changed, 240 insertions(+), 29 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index ddc6d789d8..0adcf0efaf 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1886,6 +1886,114 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-slru-buffers" xreflabel="multixact_offsets_slru_buffers">
+      <term><varname>multixact_offsets_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact offsets. MultiXact offsets
+        are used to store information about offsets of multiple row lockers (caused by SELECT FOR UPDATE and others).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-slru-buffers" xreflabel="multixact_members_slru_buffers">
+      <term><varname>multixact_members_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact members. MultiXact members
+        are used to store information about XIDs of multiple row lockers. Typically <varname>multixact_members_slru_buffers</varname>
+        is twice more than <varname>multixact_offsets_slru_buffers</varname>.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_slru_buffers">
+      <term><varname>subtrans_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for subtransactions.
+        It defaults to 256 kilobytes (<literal>256KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_slru_buffers">
+      <term><varname>notify_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for asyncronous notifications (NOTIFY, LISTEN).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_slru_buffers">
+      <term><varname>serial_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for predicate locks.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-clog-buffers" xreflabel="clog_slru_buffers">
+      <term><varname>clog_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>clog_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for CLOG.
+        It defaults to 0, in this case CLOG size is taken as <varname>shared_buffers</varname> / 512.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_slru_buffers">
+      <term><varname>commit_ts_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for commit timestamps.
+        It defaults to 0, in this case CLOG size is taken as <varname>shared_buffers</varname> / 512.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..e1d34aa361 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -659,6 +659,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
+ * If values is configured via GUC - just use given value. Otherwise
+ * apply following euristics.
+ *
  * On larger multi-processor systems, it is possible to have many CLOG page
  * requests in flight at one time which could lead to disk access for CLOG
  * page if the required page is not found in memory.  Testing revealed that we
@@ -675,6 +678,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 Size
 CLOGShmemBuffers(void)
 {
+	/* consider 0 and 1 as unset GUC */
+	if (clog_slru_buffers > 1)
+		return clog_slru_buffers;
 	return Min(128, Max(4, NBuffers / 512));
 }
 
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 48e8d66286..7de3bca63d 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -530,7 +530,10 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* consider 0 and 1 as unset GUC */
+	if (commit_ts_slru_buffers > 1)
+		return commit_ts_slru_buffers;
+	return Min(16, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1f9f1a1fa1..370c01e72b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_slru_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_slru_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_slru_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_slru_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..0c24353d3a 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_slru_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_slru_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 4b16fb5682..f5c5592057 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_slru_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_slru_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_slru_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_slru_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d493aeef0f..fad8cc572e 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_slru_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_slru_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 73e0a672ae..f163ca17e9 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -148,3 +148,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_slru_buffers = 8;
+int			multixact_members_slru_buffers = 16;
+int			subtrans_slru_buffers = 32;
+int			notify_slru_buffers = 8;
+int			serial_slru_buffers = 16;
+int			clog_slru_buffers = 0;
+int			commit_ts_slru_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 0c5dc4d3e8..b65a4ae9ce 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2305,6 +2305,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for substransactions SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_slru_buffers,
+		32, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for asyncronous notifications SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for predicate locks SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"clog_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit log SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_slru_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"commit_ts_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit timestamps SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_slru_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index b234a6bfe6..308fd565d3 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -190,6 +190,22 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers -
+
+#multixact_offsets_slru_buffers = 8	# memory used for MultiXact offsets
+					# (change requires restart)
+#multixact_members_slru_buffers = 16	# memory used for MultiXact members
+					# (change requires restart)
+#subtrans_slru_buffers = 32			# memory used for subtransactions
+					# (change requires restart)
+#notify_slru_buffers = 8			# memory used for asynchronous notifications
+					# (change requires restart)
+#serial_slru_buffers = 16			# memory used for predicate locks
+					# (change requires restart)
+#clog_slru_buffers = 0				# memory used for CLOG
+					# (change requires restart)
+#commit_ts_slru_buffers = 0			# memory used for commit timestamps
+					# (change requires restart)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..ca0999056e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,9 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
-
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
 extern TransactionId SubTransGetTopmostTransaction(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 013850ac28..3d9f585fb9 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,14 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int subtrans_slru_buffers;
+extern PGDLLIMPORT int notify_slru_buffers;
+extern PGDLLIMPORT int serial_slru_buffers;
+extern PGDLLIMPORT int clog_slru_buffers;
+extern PGDLLIMPORT int commit_ts_slru_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.30.1

v10-0002-Add-buffer-mapping-table-for-SLRUs.patchtext/x-patch; charset=US-ASCII; name=v10-0002-Add-buffer-mapping-table-for-SLRUs.patchDownload
From 692d03167f4124e6daabdb8d4a72ff0b494efe96 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 25 Mar 2021 10:11:31 +1300
Subject: [PATCH v10 2/2] Add buffer mapping table for SLRUs.

---
 src/backend/access/transam/slru.c | 87 ++++++++++++++++++++++++++++---
 src/include/access/slru.h         |  2 +
 2 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82149ad782..2d6e84266e 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -58,6 +58,8 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "utils/dynahash.h"
+#include "utils/hsearch.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -79,6 +81,12 @@ typedef struct SlruWriteAllData
 
 typedef struct SlruWriteAllData *SlruWriteAll;
 
+typedef struct SlruMappingTableEntry
+{
+	int			pageno;
+	int			slotno;
+} SlruMappingTableEntry;
+
 /*
  * Populate a file tag describing a segment file.  We only use the segment
  * number, since we can derive everything else we need by having separate
@@ -146,6 +154,9 @@ static int	SlruSelectLRUPage(SlruCtl ctl, int pageno);
 static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+static void	SlruMappingAdd(SlruCtl ctl, int pageno, int slotno);
+static void	SlruMappingRemove(SlruCtl ctl, int pageno);
+static int	SlruMappingFind(SlruCtl ctl, int pageno);
 
 /*
  * Initialization of shared memory
@@ -168,7 +179,8 @@ SimpleLruShmemSize(int nslots, int nlsns)
 	if (nlsns > 0)
 		sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
 
-	return BUFFERALIGN(sz) + BLCKSZ * nslots;
+	return BUFFERALIGN(sz) + BLCKSZ * nslots +
+		hash_estimate_size(nslots, sizeof(SlruMappingTableEntry));
 }
 
 /*
@@ -187,6 +199,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 			  LWLock *ctllock, const char *subdir, int tranche_id,
 			  SyncRequestHandler sync_handler)
 {
+	char		mapping_table_name[SHMEM_INDEX_KEYSIZE];
+	HASHCTL		mapping_table_info;
+	HTAB	   *mapping_table;
 	SlruShared	shared;
 	bool		found;
 
@@ -258,11 +273,21 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 	else
 		Assert(found);
 
+	/* Create or find the buffer mapping table. */
+	memset(&mapping_table_info, 0, sizeof(mapping_table_info));
+	mapping_table_info.keysize = sizeof(int);
+	mapping_table_info.entrysize = sizeof(SlruMappingTableEntry);
+	snprintf(mapping_table_name, sizeof(mapping_table_name),
+			 "%s Mapping Table", name);
+	mapping_table = ShmemInitHash(mapping_table_name, nslots, nslots,
+								  &mapping_table_info, HASH_ELEM | HASH_BLOBS);
+
 	/*
 	 * Initialize the unshared control struct, including directory path. We
 	 * assume caller set PagePrecedes.
 	 */
 	ctl->shared = shared;
+	ctl->mapping_table = mapping_table;
 	ctl->sync_handler = sync_handler;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
@@ -289,6 +314,9 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 		   shared->page_number[slotno] == pageno);
 
 	/* Mark the slot as containing this page */
+	if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+		SlruMappingRemove(ctl, shared->page_number[slotno]);
+	SlruMappingAdd(ctl, pageno, slotno);
 	shared->page_number[slotno] = pageno;
 	shared->page_status[slotno] = SLRU_PAGE_VALID;
 	shared->page_dirty[slotno] = true;
@@ -362,7 +390,10 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 		{
 			/* indeed, the I/O must have failed */
 			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
+			{
+				SlruMappingRemove(ctl, shared->page_number[slotno]);
 				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			}
 			else				/* write_in_progress */
 			{
 				shared->page_status[slotno] = SLRU_PAGE_VALID;
@@ -436,6 +467,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 				!shared->page_dirty[slotno]));
 
 		/* Mark the slot read-busy */
+		SlruMappingAdd(ctl, pageno, slotno);
 		shared->page_number[slotno] = pageno;
 		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
 		shared->page_dirty[slotno] = false;
@@ -459,7 +491,13 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
 			   !shared->page_dirty[slotno]);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		if (ok)
+			shared->page_status[slotno] = SLRU_PAGE_VALID;
+		else
+		{
+			SlruMappingRemove(ctl, pageno);
+			shared->page_status[slotno] =  SLRU_PAGE_EMPTY;
+		}
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -1029,11 +1067,12 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		slotno = SlruMappingFind(ctl, pageno);
+		if (slotno >= 0)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
-				return slotno;
+			Assert(shared->page_number[slotno] == pageno);
+			Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+			return slotno;
 		}
 
 		/*
@@ -1266,6 +1305,7 @@ restart:;
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1348,6 +1388,7 @@ restart:
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1609,3 +1650,37 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
 	errno = save_errno;
 	return result;
 }
+
+static int
+SlruMappingFind(SlruCtl ctl, int pageno)
+{
+	SlruMappingTableEntry *mapping;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_FIND, NULL);
+	if (mapping)
+		return mapping->pageno;
+
+	return -1;
+}
+
+static void
+SlruMappingAdd(SlruCtl ctl, int pageno, int slotno)
+{
+	SlruMappingTableEntry *mapping;
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_ENTER, &found);
+	mapping->slotno = slotno;
+
+	Assert(!found);
+}
+
+static void
+SlruMappingRemove(SlruCtl ctl, int pageno)
+{
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	hash_search(ctl->mapping_table, &pageno, HASH_REMOVE, &found);
+
+	Assert(found);
+}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index dd52e8cec7..8aa3efc0ee 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -16,6 +16,7 @@
 #include "access/xlogdefs.h"
 #include "storage/lwlock.h"
 #include "storage/sync.h"
+#include "utils/hsearch.h"
 
 
 /*
@@ -110,6 +111,7 @@ typedef SlruSharedData *SlruShared;
 typedef struct SlruCtlData
 {
 	SlruShared	shared;
+	HTAB	   *mapping_table;
 
 	/*
 	 * Which sync handler function to use when handing sync requests over to
-- 
2.30.1

#49Thomas Munro
thomas.munro@gmail.com
In reply to: Thomas Munro (#48)
2 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Thu, Mar 25, 2021 at 10:31 AM Thomas Munro <thomas.munro@gmail.com> wrote:

We already know that increasing the number of CLOG buffers above the
current number hurts as the linear search begins to dominate
(according to the commit message for 5364b357), and it doesn't seem
great to ship a new feature that melts your CPU when you turn it up.
Perhaps, to ship this, we need to introduce a buffer mapping table? I
have attached a "one coffee" attempt at that, on top of your v10 patch
(unmodified), for discussion. It survives basic testing but I don't
know how it performs.

Hrrr... Cfbot showed an assertion failure. Here's the two coffee
version with a couple of silly mistakes fixed.

Attachments:

v11-0001-Make-all-SLRU-buffer-sizes-configurable.patchtext/x-patch; charset=US-ASCII; name=v11-0001-Make-all-SLRU-buffer-sizes-configurable.patchDownload
From 4817d16cfb6704d43a7bef12648e753d239c809c Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v11 1/2] Make all SLRU buffer sizes configurable

---
 doc/src/sgml/config.sgml                      | 108 ++++++++++++++++++
 src/backend/access/transam/clog.c             |   6 +
 src/backend/access/transam/commit_ts.c        |   5 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  77 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |  16 +++
 src/include/access/multixact.h                |   4 -
 src/include/access/subtrans.h                 |   3 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   8 ++
 src/include/storage/predicate.h               |   4 -
 15 files changed, 240 insertions(+), 29 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index ddc6d789d8..0adcf0efaf 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1886,6 +1886,114 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-slru-buffers" xreflabel="multixact_offsets_slru_buffers">
+      <term><varname>multixact_offsets_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact offsets. MultiXact offsets
+        are used to store information about offsets of multiple row lockers (caused by SELECT FOR UPDATE and others).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-slru-buffers" xreflabel="multixact_members_slru_buffers">
+      <term><varname>multixact_members_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for MultiXact members. MultiXact members
+        are used to store information about XIDs of multiple row lockers. Typically <varname>multixact_members_slru_buffers</varname>
+        is twice more than <varname>multixact_offsets_slru_buffers</varname>.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_slru_buffers">
+      <term><varname>subtrans_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for subtransactions.
+        It defaults to 256 kilobytes (<literal>256KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_slru_buffers">
+      <term><varname>notify_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for asyncronous notifications (NOTIFY, LISTEN).
+        It defaults to 64 kilobytes (<literal>64KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_slru_buffers">
+      <term><varname>serial_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for predicate locks.
+        It defaults to 128 kilobytes (<literal>128KB</literal>).
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-clog-buffers" xreflabel="clog_slru_buffers">
+      <term><varname>clog_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>clog_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for CLOG.
+        It defaults to 0, in this case CLOG size is taken as <varname>shared_buffers</varname> / 512.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_slru_buffers">
+      <term><varname>commit_ts_slru_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_slru_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used for commit timestamps.
+        It defaults to 0, in this case CLOG size is taken as <varname>shared_buffers</varname> / 512.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..e1d34aa361 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -659,6 +659,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
+ * If values is configured via GUC - just use given value. Otherwise
+ * apply following euristics.
+ *
  * On larger multi-processor systems, it is possible to have many CLOG page
  * requests in flight at one time which could lead to disk access for CLOG
  * page if the required page is not found in memory.  Testing revealed that we
@@ -675,6 +678,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 Size
 CLOGShmemBuffers(void)
 {
+	/* consider 0 and 1 as unset GUC */
+	if (clog_slru_buffers > 1)
+		return clog_slru_buffers;
 	return Min(128, Max(4, NBuffers / 512));
 }
 
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 48e8d66286..7de3bca63d 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -530,7 +530,10 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* consider 0 and 1 as unset GUC */
+	if (commit_ts_slru_buffers > 1)
+		return commit_ts_slru_buffers;
+	return Min(16, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1f9f1a1fa1..370c01e72b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_slru_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_slru_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_slru_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_slru_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..0c24353d3a 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_slru_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_slru_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 4b16fb5682..f5c5592057 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_slru_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_slru_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_slru_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_slru_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d493aeef0f..fad8cc572e 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_slru_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_slru_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 73e0a672ae..f163ca17e9 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -148,3 +148,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_slru_buffers = 8;
+int			multixact_members_slru_buffers = 16;
+int			subtrans_slru_buffers = 32;
+int			notify_slru_buffers = 8;
+int			serial_slru_buffers = 16;
+int			clog_slru_buffers = 0;
+int			commit_ts_slru_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 0c5dc4d3e8..b65a4ae9ce 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2305,6 +2305,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for substransactions SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_slru_buffers,
+		32, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for asyncronous notifications SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_slru_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for predicate locks SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_slru_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"clog_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit log SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_slru_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"commit_ts_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit timestamps SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_slru_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index b234a6bfe6..308fd565d3 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -190,6 +190,22 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers -
+
+#multixact_offsets_slru_buffers = 8	# memory used for MultiXact offsets
+					# (change requires restart)
+#multixact_members_slru_buffers = 16	# memory used for MultiXact members
+					# (change requires restart)
+#subtrans_slru_buffers = 32			# memory used for subtransactions
+					# (change requires restart)
+#notify_slru_buffers = 8			# memory used for asynchronous notifications
+					# (change requires restart)
+#serial_slru_buffers = 16			# memory used for predicate locks
+					# (change requires restart)
+#clog_slru_buffers = 0				# memory used for CLOG
+					# (change requires restart)
+#commit_ts_slru_buffers = 0			# memory used for commit timestamps
+					# (change requires restart)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..ca0999056e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,9 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
-
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
 extern TransactionId SubTransGetTopmostTransaction(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 013850ac28..3d9f585fb9 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,14 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int multixact_members_slru_buffers;
+extern PGDLLIMPORT int subtrans_slru_buffers;
+extern PGDLLIMPORT int notify_slru_buffers;
+extern PGDLLIMPORT int serial_slru_buffers;
+extern PGDLLIMPORT int clog_slru_buffers;
+extern PGDLLIMPORT int commit_ts_slru_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.30.1

v11-0002-Add-buffer-mapping-table-for-SLRUs.patchtext/x-patch; charset=US-ASCII; name=v11-0002-Add-buffer-mapping-table-for-SLRUs.patchDownload
From 65600b53939c34abf43e62f3f59be5671c43d301 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 25 Mar 2021 10:11:31 +1300
Subject: [PATCH v11 2/2] Add buffer mapping table for SLRUs.

---
 src/backend/access/transam/slru.c | 87 ++++++++++++++++++++++++++++---
 src/include/access/slru.h         |  2 +
 2 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82149ad782..487585bb60 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -58,6 +58,8 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "utils/dynahash.h"
+#include "utils/hsearch.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -79,6 +81,12 @@ typedef struct SlruWriteAllData
 
 typedef struct SlruWriteAllData *SlruWriteAll;
 
+typedef struct SlruMappingTableEntry
+{
+	int			pageno;
+	int			slotno;
+} SlruMappingTableEntry;
+
 /*
  * Populate a file tag describing a segment file.  We only use the segment
  * number, since we can derive everything else we need by having separate
@@ -146,6 +154,9 @@ static int	SlruSelectLRUPage(SlruCtl ctl, int pageno);
 static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+static void	SlruMappingAdd(SlruCtl ctl, int pageno, int slotno);
+static void	SlruMappingRemove(SlruCtl ctl, int pageno);
+static int	SlruMappingFind(SlruCtl ctl, int pageno);
 
 /*
  * Initialization of shared memory
@@ -168,7 +179,8 @@ SimpleLruShmemSize(int nslots, int nlsns)
 	if (nlsns > 0)
 		sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
 
-	return BUFFERALIGN(sz) + BLCKSZ * nslots;
+	return BUFFERALIGN(sz) + BLCKSZ * nslots +
+		hash_estimate_size(nslots, sizeof(SlruMappingTableEntry));
 }
 
 /*
@@ -187,6 +199,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 			  LWLock *ctllock, const char *subdir, int tranche_id,
 			  SyncRequestHandler sync_handler)
 {
+	char		mapping_table_name[SHMEM_INDEX_KEYSIZE];
+	HASHCTL		mapping_table_info;
+	HTAB	   *mapping_table;
 	SlruShared	shared;
 	bool		found;
 
@@ -258,11 +273,21 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 	else
 		Assert(found);
 
+	/* Create or find the buffer mapping table. */
+	memset(&mapping_table_info, 0, sizeof(mapping_table_info));
+	mapping_table_info.keysize = sizeof(int);
+	mapping_table_info.entrysize = sizeof(SlruMappingTableEntry);
+	snprintf(mapping_table_name, sizeof(mapping_table_name),
+			 "%s Mapping Table", name);
+	mapping_table = ShmemInitHash(mapping_table_name, nslots, nslots,
+								  &mapping_table_info, HASH_ELEM | HASH_BLOBS);
+
 	/*
 	 * Initialize the unshared control struct, including directory path. We
 	 * assume caller set PagePrecedes.
 	 */
 	ctl->shared = shared;
+	ctl->mapping_table = mapping_table;
 	ctl->sync_handler = sync_handler;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
@@ -289,6 +314,9 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 		   shared->page_number[slotno] == pageno);
 
 	/* Mark the slot as containing this page */
+	if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+		SlruMappingRemove(ctl, shared->page_number[slotno]);
+	SlruMappingAdd(ctl, pageno, slotno);
 	shared->page_number[slotno] = pageno;
 	shared->page_status[slotno] = SLRU_PAGE_VALID;
 	shared->page_dirty[slotno] = true;
@@ -362,7 +390,10 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 		{
 			/* indeed, the I/O must have failed */
 			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
+			{
+				SlruMappingRemove(ctl, shared->page_number[slotno]);
 				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			}
 			else				/* write_in_progress */
 			{
 				shared->page_status[slotno] = SLRU_PAGE_VALID;
@@ -436,6 +467,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 				!shared->page_dirty[slotno]));
 
 		/* Mark the slot read-busy */
+		SlruMappingAdd(ctl, pageno, slotno);
 		shared->page_number[slotno] = pageno;
 		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
 		shared->page_dirty[slotno] = false;
@@ -459,7 +491,13 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
 			   !shared->page_dirty[slotno]);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		if (ok)
+			shared->page_status[slotno] = SLRU_PAGE_VALID;
+		else
+		{
+			SlruMappingRemove(ctl, pageno);
+			shared->page_status[slotno] =  SLRU_PAGE_EMPTY;
+		}
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -1029,11 +1067,12 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		slotno = SlruMappingFind(ctl, pageno);
+		if (slotno >= 0)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
-				return slotno;
+			Assert(shared->page_number[slotno] == pageno);
+			Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+			return slotno;
 		}
 
 		/*
@@ -1266,6 +1305,7 @@ restart:;
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1348,6 +1388,7 @@ restart:
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1609,3 +1650,37 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
 	errno = save_errno;
 	return result;
 }
+
+static int
+SlruMappingFind(SlruCtl ctl, int pageno)
+{
+	SlruMappingTableEntry *mapping;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_FIND, NULL);
+	if (mapping)
+		return mapping->slotno;
+
+	return -1;
+}
+
+static void
+SlruMappingAdd(SlruCtl ctl, int pageno, int slotno)
+{
+	SlruMappingTableEntry *mapping;
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_ENTER, &found);
+	mapping->slotno = slotno;
+
+	Assert(!found);
+}
+
+static void
+SlruMappingRemove(SlruCtl ctl, int pageno)
+{
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	hash_search(ctl->mapping_table, &pageno, HASH_REMOVE, &found);
+
+	Assert(found);
+}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index dd52e8cec7..8aa3efc0ee 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -16,6 +16,7 @@
 #include "access/xlogdefs.h"
 #include "storage/lwlock.h"
 #include "storage/sync.h"
+#include "utils/hsearch.h"
 
 
 /*
@@ -110,6 +111,7 @@ typedef SlruSharedData *SlruShared;
 typedef struct SlruCtlData
 {
 	SlruShared	shared;
+	HTAB	   *mapping_table;
 
 	/*
 	 * Which sync handler function to use when handing sync requests over to
-- 
2.30.1

#50Thomas Munro
thomas.munro@gmail.com
In reply to: Thomas Munro (#49)
2 attachment(s)
Re: MultiXact\SLRU buffers configuration

Hi Andrey, all,

I propose some changes, and I'm attaching a new version:

I renamed the GUCs as clog_buffers etc (no "_slru_"). I fixed some
copy/paste mistakes where the different GUCs were mixed up. I made
some changes to the .conf.sample. I rewrote the documentation so that
it states the correct unit and defaults, and refers to the
subdirectories that are cached by these buffers instead of trying to
give a new definition of each of the SLRUs.

Do you like those changes?

Some things I thought about but didn't change:

I'm not entirely sure if we should use the internal and historical
names well known to hackers (CLOG), or the visible directory names (I
mean, we could use pg_xact_buffers instead of clog_buffers). I am not
sure why these GUCs need to be PGDLLIMPORT, but I see that NBuffers is
like that.

I wanted to do some very simple smoke testing of CLOG sizes on my
local development machine:

pgbench -i -s1000 postgres
pgbench -t4000000 -c8 -j8 -Mprepared postgres

I disabled autovacuum after running that just to be sure it wouldn't
interfere with my experiment:

alter table pgbench_accounts set (autovacuum_enabled = off);

Then I shut the cluster down and made a copy, so I could do some
repeated experiments from the same initial conditions each time. At
this point I had 30 files 0000-001E under pg_xact, holding 256kB = ~1
million transactions each. It'd take ~960 buffers to cache it all.
So how long does VACUUM FREEZE pgbench_accounts take?

I tested with just the 0001 patch, and also with the 0002 patch
(improved version, attached):

clog_buffers=128: 0001=2:28.499, 0002=2:17:891
clog_buffers=1024: 0001=1:38.485, 0002=1:29.701

I'm sure the speedup of the 0002 patch can be amplified by increasing
the number of transactions referenced in the table OR number of
clog_buffers, considering that the linear search produces
O(transactions * clog_buffers) work. That was 32M transactions and
8MB of CLOG, but I bet if you double both of those numbers once or
twice things start to get hot. I don't see why you shouldn't be able
to opt to cache literally all of CLOG if you want (something like 50MB
assuming default autovacuum_freeze_max_age, scale to taste, up to
512MB for the theoretical maximum useful value).

I'm not saying the 0002 patch is bug-free yet though, it's a bit finickity.

Attachments:

v12-0001-Make-all-SLRU-buffer-sizes-configurable.patchtext/x-patch; charset=US-ASCII; name=v12-0001-Make-all-SLRU-buffer-sizes-configurable.patchDownload
From e7a8b9a0e27de80bab13f004b4d7e3fa1da677c4 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v12 1/2] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 137 ++++++++++++++++++
 src/backend/access/transam/clog.c             |   6 +
 src/backend/access/transam/commit_ts.c        |   5 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 +
 src/backend/utils/misc/guc.c                  |  77 ++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/multixact.h                |   4 -
 src/include/access/subtrans.h                 |   3 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 15 files changed, 261 insertions(+), 29 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index ddc6d789d8..f1112bfa9c 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1886,6 +1886,143 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-clog-buffers" xreflabel="clog_buffers">
+      <term><varname>clog_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>clog_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not more than 128 or
+        fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not more than 128 or
+        fewer than 16 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..0318e8ff59 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -659,6 +659,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
+ * If values is configured via GUC - just use given value. Otherwise
+ * apply following euristics.
+ *
  * On larger multi-processor systems, it is possible to have many CLOG page
  * requests in flight at one time which could lead to disk access for CLOG
  * page if the required page is not found in memory.  Testing revealed that we
@@ -675,6 +678,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 Size
 CLOGShmemBuffers(void)
 {
+	/* consider 0 and 1 as unset GUC */
+	if (clog_buffers > 1)
+		return clog_buffers;
 	return Min(128, Max(4, NBuffers / 512));
 }
 
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 268bdba339..0d2632b90e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -530,7 +530,10 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* consider 0 and 1 as unset GUC */
+	if (commit_ts_buffers > 1)
+		return commit_ts_buffers;
+	return Min(16, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1f9f1a1fa1..21787765e2 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..785f2520fd 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 4b16fb5682..de17f52cd7 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d493aeef0f..b1f4f1651d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 73e0a672ae..e90275be6c 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -148,3 +148,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			clog_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 0c5dc4d3e8..003bc820d2 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2305,6 +2305,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for substransactions SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for asyncronous notifications SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for predicate locks SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"clog_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit log SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&clog_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit timestamps SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index b234a6bfe6..1b8515989b 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -190,6 +190,15 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers (change requires restart) -
+
+#clog_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_nofity
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..ca0999056e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,9 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
-
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
 extern TransactionId SubTransGetTopmostTransaction(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 013850ac28..9c325b4312 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int clog_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.30.1

v12-0002-Add-buffer-mapping-table-for-SLRUs.patchtext/x-patch; charset=US-ASCII; name=v12-0002-Add-buffer-mapping-table-for-SLRUs.patchDownload
From 98092b5b4e7a9a11a5bbd50c36ad8f635fdfab6f Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 25 Mar 2021 10:11:31 +1300
Subject: [PATCH v12 2/2] Add buffer mapping table for SLRUs.

Instead of doing a linear search for the buffer holding a given page
number, use a hash table.

Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 src/backend/access/transam/slru.c | 111 +++++++++++++++++++++++++-----
 src/include/access/slru.h         |   2 +
 2 files changed, 96 insertions(+), 17 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82149ad782..f823c2a0c8 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -58,6 +58,8 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "utils/dynahash.h"
+#include "utils/hsearch.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -79,6 +81,12 @@ typedef struct SlruWriteAllData
 
 typedef struct SlruWriteAllData *SlruWriteAll;
 
+typedef struct SlruMappingTableEntry
+{
+	int			pageno;
+	int			slotno;
+} SlruMappingTableEntry;
+
 /*
  * Populate a file tag describing a segment file.  We only use the segment
  * number, since we can derive everything else we need by having separate
@@ -146,6 +154,9 @@ static int	SlruSelectLRUPage(SlruCtl ctl, int pageno);
 static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+static void	SlruMappingAdd(SlruCtl ctl, int pageno, int slotno);
+static void	SlruMappingRemove(SlruCtl ctl, int pageno);
+static int	SlruMappingFind(SlruCtl ctl, int pageno);
 
 /*
  * Initialization of shared memory
@@ -168,7 +179,8 @@ SimpleLruShmemSize(int nslots, int nlsns)
 	if (nlsns > 0)
 		sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
 
-	return BUFFERALIGN(sz) + BLCKSZ * nslots;
+	return BUFFERALIGN(sz) + BLCKSZ * nslots +
+		hash_estimate_size(nslots, sizeof(SlruMappingTableEntry));
 }
 
 /*
@@ -187,6 +199,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 			  LWLock *ctllock, const char *subdir, int tranche_id,
 			  SyncRequestHandler sync_handler)
 {
+	char		mapping_table_name[SHMEM_INDEX_KEYSIZE];
+	HASHCTL		mapping_table_info;
+	HTAB	   *mapping_table;
 	SlruShared	shared;
 	bool		found;
 
@@ -258,11 +273,21 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 	else
 		Assert(found);
 
+	/* Create or find the buffer mapping table. */
+	memset(&mapping_table_info, 0, sizeof(mapping_table_info));
+	mapping_table_info.keysize = sizeof(int);
+	mapping_table_info.entrysize = sizeof(SlruMappingTableEntry);
+	snprintf(mapping_table_name, sizeof(mapping_table_name),
+			 "%s Mapping Table", name);
+	mapping_table = ShmemInitHash(mapping_table_name, nslots, nslots,
+								  &mapping_table_info, HASH_ELEM | HASH_BLOBS);
+
 	/*
 	 * Initialize the unshared control struct, including directory path. We
 	 * assume caller set PagePrecedes.
 	 */
 	ctl->shared = shared;
+	ctl->mapping_table = mapping_table;
 	ctl->sync_handler = sync_handler;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
@@ -289,6 +314,9 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 		   shared->page_number[slotno] == pageno);
 
 	/* Mark the slot as containing this page */
+	if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+		SlruMappingRemove(ctl, shared->page_number[slotno]);
+	SlruMappingAdd(ctl, pageno, slotno);
 	shared->page_number[slotno] = pageno;
 	shared->page_status[slotno] = SLRU_PAGE_VALID;
 	shared->page_dirty[slotno] = true;
@@ -362,7 +390,10 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 		{
 			/* indeed, the I/O must have failed */
 			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
+			{
+				SlruMappingRemove(ctl, shared->page_number[slotno]);
 				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			}
 			else				/* write_in_progress */
 			{
 				shared->page_status[slotno] = SLRU_PAGE_VALID;
@@ -436,6 +467,9 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 				!shared->page_dirty[slotno]));
 
 		/* Mark the slot read-busy */
+		if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
+		SlruMappingAdd(ctl, pageno, slotno);
 		shared->page_number[slotno] = pageno;
 		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
 		shared->page_dirty[slotno] = false;
@@ -459,7 +493,13 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
 			   !shared->page_dirty[slotno]);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		if (ok)
+			shared->page_status[slotno] = SLRU_PAGE_VALID;
+		else
+		{
+			SlruMappingRemove(ctl, pageno);
+			shared->page_status[slotno] =  SLRU_PAGE_EMPTY;
+		}
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -500,20 +540,20 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	slotno = SlruMappingFind(ctl, pageno);
+	if (slotno >= 0 &&
+		shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
 	{
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
-			shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
-		{
-			/* See comments for SlruRecentlyUsed macro */
-			SlruRecentlyUsed(shared, slotno);
+		Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+		Assert(shared->page_number[slotno] == pageno);
 
-			/* update the stats counter of pages found in the SLRU */
-			pgstat_count_slru_page_hit(shared->slru_stats_idx);
+		/* See comments for SlruRecentlyUsed macro */
+		SlruRecentlyUsed(shared, slotno);
 
-			return slotno;
-		}
+		/* update the stats counter of pages found in the SLRU */
+		pgstat_count_slru_page_hit(shared->slru_stats_idx);
+
+		return slotno;
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
@@ -1029,11 +1069,12 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		slotno = SlruMappingFind(ctl, pageno);
+		if (slotno >= 0)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
-				return slotno;
+			Assert(shared->page_number[slotno] == pageno);
+			Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+			return slotno;
 		}
 
 		/*
@@ -1266,6 +1307,7 @@ restart:;
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1348,6 +1390,7 @@ restart:
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1609,3 +1652,37 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
 	errno = save_errno;
 	return result;
 }
+
+static int
+SlruMappingFind(SlruCtl ctl, int pageno)
+{
+	SlruMappingTableEntry *mapping;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_FIND, NULL);
+	if (mapping)
+		return mapping->slotno;
+
+	return -1;
+}
+
+static void
+SlruMappingAdd(SlruCtl ctl, int pageno, int slotno)
+{
+	SlruMappingTableEntry *mapping;
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_ENTER, &found);
+	mapping->slotno = slotno;
+
+	Assert(!found);
+}
+
+static void
+SlruMappingRemove(SlruCtl ctl, int pageno)
+{
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	hash_search(ctl->mapping_table, &pageno, HASH_REMOVE, &found);
+
+	Assert(found);
+}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index dd52e8cec7..8aa3efc0ee 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -16,6 +16,7 @@
 #include "access/xlogdefs.h"
 #include "storage/lwlock.h"
 #include "storage/sync.h"
+#include "utils/hsearch.h"
 
 
 /*
@@ -110,6 +111,7 @@ typedef SlruSharedData *SlruShared;
 typedef struct SlruCtlData
 {
 	SlruShared	shared;
+	HTAB	   *mapping_table;
 
 	/*
 	 * Which sync handler function to use when handing sync requests over to
-- 
2.30.1

#51Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thomas Munro (#50)
Re: MultiXact\SLRU buffers configuration

Hi Thomas, Gilles, all!

Thanks for reviewing this!

25 марта 2021 г., в 02:31, Thomas Munro <thomas.munro@gmail.com> написал(а):

I don't think we should put "slru" (the name of the buffer replacement
algorithm, implementation detail) in the GUC names.

+1

+ It defaults to 0, in this case CLOG size is taken as
<varname>shared_buffers</varname> / 512.

We already know that increasing the number of CLOG buffers above the
current number hurts as the linear search begins to dominate

Uh, my intent was to copy original approach of CLOG SLRU size, I just missed that Min(,) thing in shared_buffers logic.

26 марта 2021 г., в 08:46, Thomas Munro <thomas.munro@gmail.com> написал(а):

Hi Andrey, all,

I propose some changes, and I'm attaching a new version:

I renamed the GUCs as clog_buffers etc (no "_slru_"). I fixed some
copy/paste mistakes where the different GUCs were mixed up. I made
some changes to the .conf.sample. I rewrote the documentation so that
it states the correct unit and defaults, and refers to the
subdirectories that are cached by these buffers instead of trying to
give a new definition of each of the SLRUs.

Do you like those changes?

Yes!

Some things I thought about but didn't change:

I'm not entirely sure if we should use the internal and historical
names well known to hackers (CLOG), or the visible directory names (I
mean, we could use pg_xact_buffers instead of clog_buffers).

While it is good idea to make notes about directory name, I think the real naming criteria is to help find this GUC when user encounters wait events in pg_stat_activity. I think there is no CLOG mentions in docs [0]https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW, only XactBuffer, XactSLRU et c.

I'm not saying the 0002 patch is bug-free yet though, it's a bit finickity.

I think the idea of speeding up linear search is really really good for scaling SLRUs. It's not even about improving normal performance of the cluster, but it's important from preventing pathological degradation under certain circumstances. Bigger cache really saves SLAs :) I'll look into the patch more closely this weekend. Thank you!

Best regards, Andrey Borodin.

[0]: https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW

#52Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Andrey Borodin (#51)
Re: MultiXact\SLRU buffers configuration

26 марта 2021 г., в 11:00, Andrey Borodin <x4mmm@yandex-team.ru> написал(а):

I'm not saying the 0002 patch is bug-free yet though, it's a bit finickity.

I think the idea of speeding up linear search is really really good for scaling SLRUs. It's not even about improving normal performance of the cluster, but it's important from preventing pathological degradation under certain circumstances. Bigger cache really saves SLAs :) I'll look into the patch more closely this weekend. Thank you!

Some thoughts on HashTable patch:
1. Can we allocate bigger hashtable to reduce probability of collisions?
2. Can we use specialised hashtable for this case? I'm afraid hash_search() does comparable number of CPU cycles as simple cycle from 0 to 128. We could inline everything and avoid hashp->hash(keyPtr, hashp->keysize) call. I'm not insisting on special hash though, just an idea.
3. pageno in SlruMappingTableEntry seems to be unused.

Thanks!

Best regards, Andrey Borodin.

#53Thomas Munro
thomas.munro@gmail.com
In reply to: Andrey Borodin (#52)
5 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Sat, Mar 27, 2021 at 4:52 AM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

Some thoughts on HashTable patch:
1. Can we allocate bigger hashtable to reduce probability of collisions?

Yeah, good idea, might require some study.

2. Can we use specialised hashtable for this case? I'm afraid hash_search() does comparable number of CPU cycles as simple cycle from 0 to 128. We could inline everything and avoid hashp->hash(keyPtr, hashp->keysize) call. I'm not insisting on special hash though, just an idea.

I tried really hard to not fall into this rabbit h.... [hack hack
hack], OK, here's a first attempt to use simplehash, Andres's
steampunk macro-based robinhood template that we're already using for
several other things, and murmurhash which is inlineable and
branch-free. I had to tweak it to support "in-place" creation and
fixed size (in other words, no allocators, for use in shared memory).
Then I was annoyed that I had to add a "status" member to our struct,
so I tried to fix that. Definitely needs more work to think about
failure modes when running out of memory, how much spare space you
need, etc.

I have not experimented with this much beyond hacking until the tests
pass, but it *should* be more efficient...

3. pageno in SlruMappingTableEntry seems to be unused.

It's the key (dynahash uses the first N bytes of your struct as the
key, but in this new simplehash version it's more explicit).

Attachments:

v13-0001-Make-all-SLRU-buffer-sizes-configurable.patchapplication/x-patch; name=v13-0001-Make-all-SLRU-buffer-sizes-configurable.patchDownload
From 5f5d4ed8ae2808766ac1fd48f68602ef530e3833 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v13 1/5] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 137 ++++++++++++++++++
 src/backend/access/transam/clog.c             |   6 +
 src/backend/access/transam/commit_ts.c        |   5 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 +
 src/backend/utils/misc/guc.c                  |  77 ++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/multixact.h                |   4 -
 src/include/access/subtrans.h                 |   3 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 15 files changed, 261 insertions(+), 29 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index ddc6d789d8..f1112bfa9c 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1886,6 +1886,143 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-clog-buffers" xreflabel="clog_buffers">
+      <term><varname>clog_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>clog_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to used to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not more than 128 or
+        fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to be used to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not more than 128 or
+        fewer than 16 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..0318e8ff59 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -659,6 +659,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
+ * If values is configured via GUC - just use given value. Otherwise
+ * apply following euristics.
+ *
  * On larger multi-processor systems, it is possible to have many CLOG page
  * requests in flight at one time which could lead to disk access for CLOG
  * page if the required page is not found in memory.  Testing revealed that we
@@ -675,6 +678,9 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 Size
 CLOGShmemBuffers(void)
 {
+	/* consider 0 and 1 as unset GUC */
+	if (clog_buffers > 1)
+		return clog_buffers;
 	return Min(128, Max(4, NBuffers / 512));
 }
 
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 268bdba339..0d2632b90e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -530,7 +530,10 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* consider 0 and 1 as unset GUC */
+	if (commit_ts_buffers > 1)
+		return commit_ts_buffers;
+	return Min(16, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1f9f1a1fa1..21787765e2 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..785f2520fd 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 4b16fb5682..de17f52cd7 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d493aeef0f..b1f4f1651d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 73e0a672ae..e90275be6c 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -148,3 +148,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			clog_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 0c5dc4d3e8..003bc820d2 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2305,6 +2305,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for substransactions SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for asyncronous notifications SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for predicate locks SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"clog_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit log SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&clog_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for commit timestamps SLRU."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, INT_MAX / 2,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index b234a6bfe6..1b8515989b 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -190,6 +190,15 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers (change requires restart) -
+
+#clog_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_nofity
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..ca0999056e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,9 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
-
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
 extern TransactionId SubTransGetTopmostTransaction(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 013850ac28..9c325b4312 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int clog_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.30.1

v13-0002-Make-simplehash-easy-to-use-in-shmem.patchapplication/x-patch; name=v13-0002-Make-simplehash-easy-to-use-in-shmem.patchDownload
From 3441027b9ac2f135dea7ec155503be9d6331dfc1 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 27 Mar 2021 08:34:58 +1300
Subject: [PATCH v13 2/5] Make simplehash easy to use in shmem.

Allow "in-place" creation of a simplehash hash table of fixed size,
suitable for use in shared memory.  No calling out to allocators, and no
ability to grow.
---
 src/include/lib/simplehash.h | 56 +++++++++++++++++++++++++++++++++---
 1 file changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.h
index 395be1ca9a..32d3fa58fe 100644
--- a/src/include/lib/simplehash.h
+++ b/src/include/lib/simplehash.h
@@ -120,6 +120,7 @@
 #define SH_ALLOCATE SH_MAKE_NAME(allocate)
 #define SH_FREE SH_MAKE_NAME(free)
 #define SH_STAT SH_MAKE_NAME(stat)
+#define SH_ESTIMATE_SIZE SH_MAKE_NAME(estimate_size)
 
 /* internal helper functions (no externally visible prototypes) */
 #define SH_COMPUTE_PARAMETERS SH_MAKE_NAME(compute_parameters)
@@ -153,16 +154,22 @@ typedef struct SH_TYPE
 	/* boundary after which to grow hashtable */
 	uint32		grow_threshold;
 
+#ifndef SH_IN_PLACE
 	/* hash buckets */
 	SH_ELEMENT_TYPE *data;
+#endif
 
-#ifndef SH_RAW_ALLOCATOR
+#if !defined(SH_RAW_ALLOCATOR) && !defined(SH_IN_PLACE)
 	/* memory context to use for allocations */
 	MemoryContext ctx;
 #endif
 
 	/* user defined data, useful for callbacks */
 	void	   *private_data;
+
+#ifdef SH_IN_PLACE
+	SH_ELEMENT_TYPE data[FLEXIBLE_ARRAY_MEMBER];
+#endif
 }			SH_TYPE;
 
 typedef enum SH_STATUS
@@ -182,6 +189,11 @@ typedef struct SH_ITERATOR
 #ifdef SH_RAW_ALLOCATOR
 /* <prefix>_hash <prefix>_create(uint32 nelements, void *private_data) */
 SH_SCOPE	SH_TYPE *SH_CREATE(uint32 nelements, void *private_data);
+#elif defined(SH_IN_PLACE)
+/* size_t <prefix>_estimate_size(uint32 nelements) */
+SH_SCOPE	size_t SH_ESTIMATE_SIZE(uint32 nelements);
+/* void <prefix>_create(<prefix>_hash *place, uint32 nelements, void *private_data) */
+SH_SCOPE	void SH_CREATE(SH_TYPE *place, uint32 nelements, void *private_data);
 #else
 /*
  * <prefix>_hash <prefix>_create(MemoryContext ctx, uint32 nelements,
@@ -191,14 +203,18 @@ SH_SCOPE	SH_TYPE *SH_CREATE(MemoryContext ctx, uint32 nelements,
 							   void *private_data);
 #endif
 
+#ifndef SH_IN_PLACE
 /* void <prefix>_destroy(<prefix>_hash *tb) */
 SH_SCOPE void SH_DESTROY(SH_TYPE * tb);
+#endif
 
 /* void <prefix>_reset(<prefix>_hash *tb) */
 SH_SCOPE void SH_RESET(SH_TYPE * tb);
 
+#ifndef SH_IN_PLACE
 /* void <prefix>_grow(<prefix>_hash *tb) */
 SH_SCOPE void SH_GROW(SH_TYPE * tb, uint32 newsize);
+#endif
 
 /* <element> *<prefix>_insert(<prefix>_hash *tb, <key> key, bool *found) */
 SH_SCOPE	SH_ELEMENT_TYPE *SH_INSERT(SH_TYPE * tb, SH_KEY_TYPE key, bool *found);
@@ -241,7 +257,7 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
 /* generate implementation of the hash table */
 #ifdef SH_DEFINE
 
-#ifndef SH_RAW_ALLOCATOR
+#if !defined(SH_RAW_ALLOCATOR) && !defined(SH_IN_PLACE)
 #include "utils/memutils.h"
 #endif
 
@@ -383,11 +399,13 @@ SH_ENTRY_HASH(SH_TYPE * tb, SH_ELEMENT_TYPE * entry)
 #endif
 }
 
+#ifndef SH_IN_PLACE
 /* default memory allocator function */
 static inline void *SH_ALLOCATE(SH_TYPE * type, Size size);
 static inline void SH_FREE(SH_TYPE * type, void *pointer);
+#endif
 
-#ifndef SH_USE_NONDEFAULT_ALLOCATOR
+#if !defined(SH_USE_NONDEFAULT_ALLOCATOR) && !defined(SH_IN_PLACE)
 
 /* default memory allocator function */
 static inline void *
@@ -410,6 +428,22 @@ SH_FREE(SH_TYPE * type, void *pointer)
 
 #endif
 
+#ifdef SH_IN_PLACE
+/*
+ * Compute the amount of memory required for a fixed sized in-place hash table.
+ */
+SH_SCOPE	size_t
+SH_ESTIMATE_SIZE(uint32 nelements)
+{
+	size_t		size;
+
+	size = Max(nelements, 2);
+	size = pg_nextpower2_64(size);
+
+	return offsetof(SH_TYPE, data) + sizeof(SH_ELEMENT_TYPE) * size;
+}
+#endif
+
 /*
  * Create a hash table with enough space for `nelements` distinct members.
  * Memory for the hash table is allocated from the passed-in context.  If
@@ -422,6 +456,9 @@ SH_FREE(SH_TYPE * type, void *pointer)
 #ifdef SH_RAW_ALLOCATOR
 SH_SCOPE	SH_TYPE *
 SH_CREATE(uint32 nelements, void *private_data)
+#elif defined(SH_IN_PLACE)
+SH_SCOPE	void
+SH_CREATE(SH_TYPE *place, uint32 nelements, void *private_data)
 #else
 SH_SCOPE	SH_TYPE *
 SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
@@ -432,6 +469,8 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
 
 #ifdef SH_RAW_ALLOCATOR
 	tb = SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
+#elif defined(SH_IN_PLACE)
+	tb = place;
 #else
 	tb = MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
 	tb->ctx = ctx;
@@ -443,11 +482,15 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
 
 	SH_COMPUTE_PARAMETERS(tb, size);
 
+#if defined(SH_IN_PLACE)
+	memset(&tb->data, 0, sizeof(SH_ELEMENT_TYPE) * tb->size);
+#else
 	tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
-
 	return tb;
+#endif
 }
 
+#ifndef SH_IN_PLACE
 /* destroy a previously created hash table */
 SH_SCOPE void
 SH_DESTROY(SH_TYPE * tb)
@@ -455,6 +498,7 @@ SH_DESTROY(SH_TYPE * tb)
 	SH_FREE(tb, tb->data);
 	pfree(tb);
 }
+#endif
 
 /* reset the contents of a previously created hash table */
 SH_SCOPE void
@@ -464,6 +508,7 @@ SH_RESET(SH_TYPE * tb)
 	tb->members = 0;
 }
 
+#ifndef SH_IN_PLACE
 /*
  * Grow a hash table to at least `newsize` buckets.
  *
@@ -576,6 +621,7 @@ SH_GROW(SH_TYPE * tb, uint32 newsize)
 
 	SH_FREE(tb, olddata);
 }
+#endif
 
 /*
  * This is a separate static inline function, so it can be reliably be inlined
@@ -592,6 +638,7 @@ SH_INSERT_HASH_INTERNAL(SH_TYPE * tb, SH_KEY_TYPE key, uint32 hash, bool *found)
 restart:
 	insertdist = 0;
 
+#ifndef SH_IN_PLACE
 	/*
 	 * We do the grow check even if the key is actually present, to avoid
 	 * doing the check inside the loop. This also lets us avoid having to
@@ -614,6 +661,7 @@ restart:
 		SH_GROW(tb, tb->size * 2);
 		/* SH_STAT(tb); */
 	}
+#endif
 
 	/* perform insert, start bucket search at optimal location */
 	data = tb->data;
-- 
2.30.1

v13-0003-Support-intrusive-status-flag-in-simplehash.patchapplication/x-patch; name=v13-0003-Support-intrusive-status-flag-in-simplehash.patchDownload
From 3bbaf8d558e1e405217e17d1a502ff68556b21e3 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 27 Mar 2021 09:04:56 +1300
Subject: [PATCH v13 3/5] Support intrusive status flag in simplehash.

Before, you had to include a "status" member in the element type, which
simplehash.h could use to detect free space.  Allow the user to specify
a special key value to use instead, for more compact representation.
---
 src/include/lib/simplehash.h | 66 ++++++++++++++++++++++++++----------
 1 file changed, 48 insertions(+), 18 deletions(-)

diff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.h
index 32d3fa58fe..05c7ca8a47 100644
--- a/src/include/lib/simplehash.h
+++ b/src/include/lib/simplehash.h
@@ -131,6 +131,8 @@
 #define SH_ENTRY_HASH SH_MAKE_NAME(entry_hash)
 #define SH_INSERT_HASH_INTERNAL SH_MAKE_NAME(insert_hash_internal)
 #define SH_LOOKUP_HASH_INTERNAL SH_MAKE_NAME(lookup_hash_internal)
+#define SH_ENTRY_IS_EMPTY SH_MAKE_NAME(entry_is_empty)
+#define SH_SET_ENTRY_EMPTY SH_MAKE_NAME(set_entry_empty)
 
 /* generate forward declarations necessary to use the hash table */
 #ifdef SH_DECLARE
@@ -172,11 +174,13 @@ typedef struct SH_TYPE
 #endif
 }			SH_TYPE;
 
+#ifndef SH_IS_EMPTY_KEY
 typedef enum SH_STATUS
 {
 	SH_STATUS_EMPTY = 0x00,
 	SH_STATUS_IN_USE = 0x01
 } SH_STATUS;
+#endif
 
 typedef struct SH_ITERATOR
 {
@@ -309,6 +313,26 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
 
 #endif
 
+static inline bool
+SH_ENTRY_IS_EMPTY(SH_TYPE * tb, SH_ELEMENT_TYPE * entry)
+{
+#ifdef SH_IS_EMPTY_KEY
+	return SH_IS_EMPTY_KEY(tb, entry->SH_KEY);
+#else
+	return entry->status == SH_STATUS_EMPTY;
+#endif
+}
+
+static inline void
+SH_SET_ENTRY_EMPTY(SH_TYPE * tb, SH_ELEMENT_TYPE *entry)
+{
+#ifdef SH_EMPTY_KEY
+	entry->SH_KEY = SH_EMPTY_KEY(tb);
+#else
+	entry->status = SH_STATUS_EMPTY;
+#endif
+}
+
 /*
  * Compute sizing parameters for hashtable. Called when creating and growing
  * the hashtable.
@@ -483,7 +507,7 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
 	SH_COMPUTE_PARAMETERS(tb, size);
 
 #if defined(SH_IN_PLACE)
-	memset(&tb->data, 0, sizeof(SH_ELEMENT_TYPE) * tb->size);
+	SH_RESET(tb);
 #else
 	tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
 	return tb;
@@ -504,7 +528,12 @@ SH_DESTROY(SH_TYPE * tb)
 SH_SCOPE void
 SH_RESET(SH_TYPE * tb)
 {
+#ifdef SH_EMPTY_KEY
+	for (size_t i = 0; i < tb->size; ++i)
+		tb->data[i].SH_KEY = SH_EMPTY_KEY(tb);
+#else
 	memset(tb->data, 0, sizeof(SH_ELEMENT_TYPE) * tb->size);
+#endif
 	tb->members = 0;
 }
 
@@ -675,14 +704,17 @@ restart:
 		SH_ELEMENT_TYPE *entry = &data[curelem];
 
 		/* any empty bucket can directly be used */
-		if (entry->status == SH_STATUS_EMPTY)
+		if (SH_ENTRY_IS_EMPTY(tb, entry))
 		{
 			tb->members++;
 			entry->SH_KEY = key;
 #ifdef SH_STORE_HASH
 			SH_GET_HASH(tb, entry) = hash;
 #endif
+#ifndef SH_IS_EMPTY_KEY
 			entry->status = SH_STATUS_IN_USE;
+#endif
+			Assert(!SH_ENTRY_IS_EMPTY(tb, entry));
 			*found = false;
 			return entry;
 		}
@@ -697,7 +729,7 @@ restart:
 
 		if (SH_COMPARE_KEYS(tb, hash, key, entry))
 		{
-			Assert(entry->status == SH_STATUS_IN_USE);
+			Assert(!SH_ENTRY_IS_EMPTY(tb, entry));
 			*found = true;
 			return entry;
 		}
@@ -721,7 +753,7 @@ restart:
 				emptyelem = SH_NEXT(tb, emptyelem, startelem);
 				emptyentry = &data[emptyelem];
 
-				if (emptyentry->status == SH_STATUS_EMPTY)
+				if (SH_ENTRY_IS_EMPTY(tb, emptyentry))
 				{
 					lastentry = emptyentry;
 					break;
@@ -770,7 +802,10 @@ restart:
 #ifdef SH_STORE_HASH
 			SH_GET_HASH(tb, entry) = hash;
 #endif
+#ifndef SH_IS_EMPTY_KEY
 			entry->status = SH_STATUS_IN_USE;
+#endif
+			Assert(!SH_ENTRY_IS_EMPTY(tb, entry));
 			*found = false;
 			return entry;
 		}
@@ -833,12 +868,8 @@ SH_LOOKUP_HASH_INTERNAL(SH_TYPE * tb, SH_KEY_TYPE key, uint32 hash)
 	{
 		SH_ELEMENT_TYPE *entry = &tb->data[curelem];
 
-		if (entry->status == SH_STATUS_EMPTY)
-		{
+		if (SH_ENTRY_IS_EMPTY(tb, entry))
 			return NULL;
-		}
-
-		Assert(entry->status == SH_STATUS_IN_USE);
 
 		if (SH_COMPARE_KEYS(tb, hash, key, entry))
 			return entry;
@@ -891,11 +922,10 @@ SH_DELETE(SH_TYPE * tb, SH_KEY_TYPE key)
 	{
 		SH_ELEMENT_TYPE *entry = &tb->data[curelem];
 
-		if (entry->status == SH_STATUS_EMPTY)
+		if (SH_ENTRY_IS_EMPTY(tb, entry))
 			return false;
 
-		if (entry->status == SH_STATUS_IN_USE &&
-			SH_COMPARE_KEYS(tb, hash, key, entry))
+		if (SH_COMPARE_KEYS(tb, hash, key, entry))
 		{
 			SH_ELEMENT_TYPE *lastentry = entry;
 
@@ -917,9 +947,9 @@ SH_DELETE(SH_TYPE * tb, SH_KEY_TYPE key)
 				curelem = SH_NEXT(tb, curelem, startelem);
 				curentry = &tb->data[curelem];
 
-				if (curentry->status != SH_STATUS_IN_USE)
+				if (SH_ENTRY_IS_EMPTY(tb, curentry))
 				{
-					lastentry->status = SH_STATUS_EMPTY;
+					SH_SET_ENTRY_EMPTY(tb, lastentry);
 					break;
 				}
 
@@ -929,7 +959,7 @@ SH_DELETE(SH_TYPE * tb, SH_KEY_TYPE key)
 				/* current is at optimal position, done */
 				if (curoptimal == curelem)
 				{
-					lastentry->status = SH_STATUS_EMPTY;
+					SH_SET_ENTRY_EMPTY(tb, lastentry);
 					break;
 				}
 
@@ -966,7 +996,7 @@ SH_START_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
 	{
 		SH_ELEMENT_TYPE *entry = &tb->data[i];
 
-		if (entry->status != SH_STATUS_IN_USE)
+		if (SH_ENTRY_IS_EMPTY(tb, entry))
 		{
 			startelem = i;
 			break;
@@ -1027,7 +1057,7 @@ SH_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
 
 		if ((iter->cur & tb->sizemask) == (iter->end & tb->sizemask))
 			iter->done = true;
-		if (elem->status == SH_STATUS_IN_USE)
+		if (!SH_ENTRY_IS_EMPTY(tb, elem))
 		{
 			return elem;
 		}
@@ -1063,7 +1093,7 @@ SH_STAT(SH_TYPE * tb)
 
 		elem = &tb->data[i];
 
-		if (elem->status != SH_STATUS_IN_USE)
+		if (SH_ENTRY_IS_EMPTY(tb, elem))
 			continue;
 
 		hash = SH_ENTRY_HASH(tb, elem);
-- 
2.30.1

v13-0004-Add-buffer-mapping-table-for-SLRUs.patchapplication/x-patch; name=v13-0004-Add-buffer-mapping-table-for-SLRUs.patchDownload
From 970504d304af469e494de6ca83123caf1a683ecf Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 25 Mar 2021 10:11:31 +1300
Subject: [PATCH v13 4/5] Add buffer mapping table for SLRUs.

Instead of doing a linear search for the buffer holding a given page
number, use a hash table.

Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 src/backend/access/transam/slru.c | 111 +++++++++++++++++++++++++-----
 src/include/access/slru.h         |   2 +
 2 files changed, 96 insertions(+), 17 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82149ad782..f823c2a0c8 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -58,6 +58,8 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "utils/dynahash.h"
+#include "utils/hsearch.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -79,6 +81,12 @@ typedef struct SlruWriteAllData
 
 typedef struct SlruWriteAllData *SlruWriteAll;
 
+typedef struct SlruMappingTableEntry
+{
+	int			pageno;
+	int			slotno;
+} SlruMappingTableEntry;
+
 /*
  * Populate a file tag describing a segment file.  We only use the segment
  * number, since we can derive everything else we need by having separate
@@ -146,6 +154,9 @@ static int	SlruSelectLRUPage(SlruCtl ctl, int pageno);
 static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+static void	SlruMappingAdd(SlruCtl ctl, int pageno, int slotno);
+static void	SlruMappingRemove(SlruCtl ctl, int pageno);
+static int	SlruMappingFind(SlruCtl ctl, int pageno);
 
 /*
  * Initialization of shared memory
@@ -168,7 +179,8 @@ SimpleLruShmemSize(int nslots, int nlsns)
 	if (nlsns > 0)
 		sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
 
-	return BUFFERALIGN(sz) + BLCKSZ * nslots;
+	return BUFFERALIGN(sz) + BLCKSZ * nslots +
+		hash_estimate_size(nslots, sizeof(SlruMappingTableEntry));
 }
 
 /*
@@ -187,6 +199,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 			  LWLock *ctllock, const char *subdir, int tranche_id,
 			  SyncRequestHandler sync_handler)
 {
+	char		mapping_table_name[SHMEM_INDEX_KEYSIZE];
+	HASHCTL		mapping_table_info;
+	HTAB	   *mapping_table;
 	SlruShared	shared;
 	bool		found;
 
@@ -258,11 +273,21 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 	else
 		Assert(found);
 
+	/* Create or find the buffer mapping table. */
+	memset(&mapping_table_info, 0, sizeof(mapping_table_info));
+	mapping_table_info.keysize = sizeof(int);
+	mapping_table_info.entrysize = sizeof(SlruMappingTableEntry);
+	snprintf(mapping_table_name, sizeof(mapping_table_name),
+			 "%s Mapping Table", name);
+	mapping_table = ShmemInitHash(mapping_table_name, nslots, nslots,
+								  &mapping_table_info, HASH_ELEM | HASH_BLOBS);
+
 	/*
 	 * Initialize the unshared control struct, including directory path. We
 	 * assume caller set PagePrecedes.
 	 */
 	ctl->shared = shared;
+	ctl->mapping_table = mapping_table;
 	ctl->sync_handler = sync_handler;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
@@ -289,6 +314,9 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 		   shared->page_number[slotno] == pageno);
 
 	/* Mark the slot as containing this page */
+	if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+		SlruMappingRemove(ctl, shared->page_number[slotno]);
+	SlruMappingAdd(ctl, pageno, slotno);
 	shared->page_number[slotno] = pageno;
 	shared->page_status[slotno] = SLRU_PAGE_VALID;
 	shared->page_dirty[slotno] = true;
@@ -362,7 +390,10 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 		{
 			/* indeed, the I/O must have failed */
 			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
+			{
+				SlruMappingRemove(ctl, shared->page_number[slotno]);
 				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			}
 			else				/* write_in_progress */
 			{
 				shared->page_status[slotno] = SLRU_PAGE_VALID;
@@ -436,6 +467,9 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 				!shared->page_dirty[slotno]));
 
 		/* Mark the slot read-busy */
+		if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
+		SlruMappingAdd(ctl, pageno, slotno);
 		shared->page_number[slotno] = pageno;
 		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
 		shared->page_dirty[slotno] = false;
@@ -459,7 +493,13 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
 			   !shared->page_dirty[slotno]);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		if (ok)
+			shared->page_status[slotno] = SLRU_PAGE_VALID;
+		else
+		{
+			SlruMappingRemove(ctl, pageno);
+			shared->page_status[slotno] =  SLRU_PAGE_EMPTY;
+		}
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -500,20 +540,20 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	slotno = SlruMappingFind(ctl, pageno);
+	if (slotno >= 0 &&
+		shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
 	{
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
-			shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
-		{
-			/* See comments for SlruRecentlyUsed macro */
-			SlruRecentlyUsed(shared, slotno);
+		Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+		Assert(shared->page_number[slotno] == pageno);
 
-			/* update the stats counter of pages found in the SLRU */
-			pgstat_count_slru_page_hit(shared->slru_stats_idx);
+		/* See comments for SlruRecentlyUsed macro */
+		SlruRecentlyUsed(shared, slotno);
 
-			return slotno;
-		}
+		/* update the stats counter of pages found in the SLRU */
+		pgstat_count_slru_page_hit(shared->slru_stats_idx);
+
+		return slotno;
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
@@ -1029,11 +1069,12 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		slotno = SlruMappingFind(ctl, pageno);
+		if (slotno >= 0)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
-				return slotno;
+			Assert(shared->page_number[slotno] == pageno);
+			Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+			return slotno;
 		}
 
 		/*
@@ -1266,6 +1307,7 @@ restart:;
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1348,6 +1390,7 @@ restart:
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1609,3 +1652,37 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
 	errno = save_errno;
 	return result;
 }
+
+static int
+SlruMappingFind(SlruCtl ctl, int pageno)
+{
+	SlruMappingTableEntry *mapping;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_FIND, NULL);
+	if (mapping)
+		return mapping->slotno;
+
+	return -1;
+}
+
+static void
+SlruMappingAdd(SlruCtl ctl, int pageno, int slotno)
+{
+	SlruMappingTableEntry *mapping;
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_ENTER, &found);
+	mapping->slotno = slotno;
+
+	Assert(!found);
+}
+
+static void
+SlruMappingRemove(SlruCtl ctl, int pageno)
+{
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	hash_search(ctl->mapping_table, &pageno, HASH_REMOVE, &found);
+
+	Assert(found);
+}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index dd52e8cec7..8aa3efc0ee 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -16,6 +16,7 @@
 #include "access/xlogdefs.h"
 #include "storage/lwlock.h"
 #include "storage/sync.h"
+#include "utils/hsearch.h"
 
 
 /*
@@ -110,6 +111,7 @@ typedef SlruSharedData *SlruShared;
 typedef struct SlruCtlData
 {
 	SlruShared	shared;
+	HTAB	   *mapping_table;
 
 	/*
 	 * Which sync handler function to use when handing sync requests over to
-- 
2.30.1

v13-0005-fixup-use-simplehash-instead-of-dynahash.patchapplication/x-patch; name=v13-0005-fixup-use-simplehash-instead-of-dynahash.patchDownload
From ef3c1e45a1f869544280f65d1eeba8544b028735 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 27 Mar 2021 09:07:22 +1300
Subject: [PATCH v13 5/5] fixup: use simplehash instead of dynahash

---
 src/backend/access/transam/slru.c | 41 ++++++++++++++++++++-----------
 src/include/access/slru.h         |  4 ++-
 2 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index f823c2a0c8..ba9c0efc81 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -54,12 +54,11 @@
 #include "access/slru.h"
 #include "access/transam.h"
 #include "access/xlog.h"
+#include "common/hashfn.h"
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
-#include "utils/dynahash.h"
-#include "utils/hsearch.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -85,8 +84,24 @@ typedef struct SlruMappingTableEntry
 {
 	int			pageno;
 	int			slotno;
+	char		status;
 } SlruMappingTableEntry;
 
+/* Instantiate specialized hash table routines. */
+#define SH_PREFIX smte
+#define SH_ELEMENT_TYPE SlruMappingTableEntry
+#define SH_KEY_TYPE int
+#define SH_KEY pageno
+#define SH_HASH_KEY(table, key) murmurhash32(key)
+#define SH_EQUAL(table, a, b) a == b
+#define SH_IS_EMPTY_KEY(table, pageno) pageno == -1
+#define SH_EMPTY_KEY(table) -1
+#define SH_DECLARE
+#define SH_DEFINE
+#define SH_SCOPE static inline
+#define SH_IN_PLACE
+#include "lib/simplehash.h"
+
 /*
  * Populate a file tag describing a segment file.  We only use the segment
  * number, since we can derive everything else we need by having separate
@@ -179,8 +194,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
 	if (nlsns > 0)
 		sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
 
-	return BUFFERALIGN(sz) + BLCKSZ * nslots +
-		hash_estimate_size(nslots, sizeof(SlruMappingTableEntry));
+	return BUFFERALIGN(sz) + BLCKSZ * nslots + smte_estimate_size(nslots);
 }
 
 /*
@@ -200,8 +214,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 			  SyncRequestHandler sync_handler)
 {
 	char		mapping_table_name[SHMEM_INDEX_KEYSIZE];
-	HASHCTL		mapping_table_info;
-	HTAB	   *mapping_table;
+	smte_hash  *mapping_table;
 	SlruShared	shared;
 	bool		found;
 
@@ -274,13 +287,13 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 		Assert(found);
 
 	/* Create or find the buffer mapping table. */
-	memset(&mapping_table_info, 0, sizeof(mapping_table_info));
-	mapping_table_info.keysize = sizeof(int);
-	mapping_table_info.entrysize = sizeof(SlruMappingTableEntry);
 	snprintf(mapping_table_name, sizeof(mapping_table_name),
 			 "%s Mapping Table", name);
-	mapping_table = ShmemInitHash(mapping_table_name, nslots, nslots,
-								  &mapping_table_info, HASH_ELEM | HASH_BLOBS);
+	mapping_table = ShmemInitStruct(mapping_table_name,
+									smte_estimate_size(nslots),
+									&found);
+	if (!found)
+		smte_create(mapping_table, nslots, NULL);
 
 	/*
 	 * Initialize the unshared control struct, including directory path. We
@@ -1658,7 +1671,7 @@ SlruMappingFind(SlruCtl ctl, int pageno)
 {
 	SlruMappingTableEntry *mapping;
 
-	mapping = hash_search(ctl->mapping_table, &pageno, HASH_FIND, NULL);
+	mapping = smte_lookup(ctl->mapping_table, pageno);
 	if (mapping)
 		return mapping->slotno;
 
@@ -1671,7 +1684,7 @@ SlruMappingAdd(SlruCtl ctl, int pageno, int slotno)
 	SlruMappingTableEntry *mapping;
 	bool		found PG_USED_FOR_ASSERTS_ONLY;
 
-	mapping = hash_search(ctl->mapping_table, &pageno, HASH_ENTER, &found);
+	mapping = smte_insert(ctl->mapping_table, pageno, &found);
 	mapping->slotno = slotno;
 
 	Assert(!found);
@@ -1682,7 +1695,7 @@ SlruMappingRemove(SlruCtl ctl, int pageno)
 {
 	bool		found PG_USED_FOR_ASSERTS_ONLY;
 
-	hash_search(ctl->mapping_table, &pageno, HASH_REMOVE, &found);
+	found = smte_delete(ctl->mapping_table, pageno);
 
 	Assert(found);
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 8aa3efc0ee..b3d28ff135 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -104,6 +104,8 @@ typedef struct SlruSharedData
 
 typedef SlruSharedData *SlruShared;
 
+struct smte_hash;
+
 /*
  * SlruCtlData is an unshared structure that points to the active information
  * in shared memory.
@@ -111,7 +113,7 @@ typedef SlruSharedData *SlruShared;
 typedef struct SlruCtlData
 {
 	SlruShared	shared;
-	HTAB	   *mapping_table;
+	struct smte_hash *mapping_table;
 
 	/*
 	 * Which sync handler function to use when handing sync requests over to
-- 
2.30.1

#54Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thomas Munro (#53)
Re: MultiXact\SLRU buffers configuration

27 марта 2021 г., в 01:26, Thomas Munro <thomas.munro@gmail.com> написал(а):

On Sat, Mar 27, 2021 at 4:52 AM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

Some thoughts on HashTable patch:
1. Can we allocate bigger hashtable to reduce probability of collisions?

Yeah, good idea, might require some study.

In a long run we always have this table filled with nslots. But the keys will be usually consecutive numbers (current working set of CLOG\Multis\etc). So in a happy hashing scenario collisions will only appear for some random backward jumps. I think just size = nslots * 2 will produce results which cannot be improved significantly.
And this reflects original growth strategy SH_GROW(tb, tb->size * 2).

2. Can we use specialised hashtable for this case? I'm afraid hash_search() does comparable number of CPU cycles as simple cycle from 0 to 128. We could inline everything and avoid hashp->hash(keyPtr, hashp->keysize) call. I'm not insisting on special hash though, just an idea.

I tried really hard to not fall into this rabbit h.... [hack hack
hack], OK, here's a first attempt to use simplehash,

Andres's
steampunk macro-based robinhood template

Sounds magnificent.

that we're already using for
several other things

I could not find much tests to be sure that we do not break something...

, and murmurhash which is inlineable and
branch-free.

I think pageno is a hash already. Why hash any further? And pages accessed together will have smaller access time due to colocation.

I had to tweak it to support "in-place" creation and
fixed size (in other words, no allocators, for use in shared memory).

We really need to have a test to know what happens when this structure goes out of memory, as you mentioned below. What would be apropriate place for simplehash tests?

Then I was annoyed that I had to add a "status" member to our struct,
so I tried to fix that.

Indeed, sizeof(SlruMappingTableEntry) == 9 seems strange. Will simplehash align it well?

Thanks!

Best regards, Andrey Borodin.

#55Thomas Munro
thomas.munro@gmail.com
In reply to: Andrey Borodin (#54)
Re: MultiXact\SLRU buffers configuration

On Sat, Mar 27, 2021 at 6:31 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

27 марта 2021 г., в 01:26, Thomas Munro <thomas.munro@gmail.com> написал(а):
, and murmurhash which is inlineable and
branch-free.

I think pageno is a hash already. Why hash any further? And pages accessed together will have smaller access time due to colocation.

Yeah, if clog_buffers is large enough then it's already a "perfect
hash", but if it's not then you might get some weird "harmonic"
effects (not sure if that's the right word), basically higher or lower
collision rate depending on coincidences in the data. If you apply a
hash, the collisions should be evenly spread out so at least it'll be
somewhat consistent. Does that make sense?

(At some point I figured out that the syscaches have lower collision
rates and perform better if you use oids directly instead of hashing
them... but then it's easy to create a pathological pattern of DDL
that turns your hash table into a linked list. Not sure what to think
about that.)

I had to tweak it to support "in-place" creation and
fixed size (in other words, no allocators, for use in shared memory).

We really need to have a test to know what happens when this structure goes out of memory, as you mentioned below. What would be apropriate place for simplehash tests?

Good questions. This has to be based on being guaranteed to have
enough space for all of the entries, so the question is really just
"how bad can performance get with different load factors". FWIW there
were some interesting cases with clustering when simplehash was first
used in the executor (see commits ab9f2c42 and parent) which required
some work on hashing quality to fix.

Then I was annoyed that I had to add a "status" member to our struct,
so I tried to fix that.

Indeed, sizeof(SlruMappingTableEntry) == 9 seems strange. Will simplehash align it well?

With that "intrusive status" patch, the size is back to 8. But I
think I made a mistake: I made it steal some key space to indicate
presence, but I think the presence test should really get access to
the whole entry so that you can encode it in more ways. For example,
with slotno == -1.

Alright, considering the date, if we want to get this into PostgreSQL
14 it's time to make some decisions.

1. Do we want customisable SLRU sizes in PG14?

+1 from me, we have multiple reports of performance gains from
increasing various different SLRUs, and it's easy to find workloads
that go faster.

One thought: it'd be nice if the user could *see* the current size,
when using the default. SHOW clog_buffers -> 0 isn't very helpful if
you want to increase it, but don't know what it's currently set to.
Not sure off the top of my head how best to do that.

2. What names do we want the GUCs to have? Here's what we have:

Proposed GUC Directory System views
clog_buffers pg_xact Xact
multixact_offsets_buffers pg_multixact/offsets MultiXactOffset
multixact_members_buffers pg_multixact/members MultiXactMember
notify_buffers pg_notify Notify
serial_buffers pg_serial Serial
subtrans_buffers pg_subtrans Subtrans
commit_ts_buffers pg_commit_ts CommitTs

By system views, I mean pg_stat_slru, pg_shmem_allocations and
pg_stat_activity (lock names add "SLRU" on the end).

Observations:

It seems obvious that "clog_buffers" should be renamed to "xact_buffers".
It's not clear whether the multixact GUCs should have the extra "s"
like the directories, or not, like the system views.
It see that we have "Shared Buffer Lookup Table" in
pg_shmem_allocations, so where I generated names like "Subtrans
Mapping Table" I should change that to "Lookup" to match.

3. What recommendations should we make about how to set it?

I think the answer depends partially on the next questions! I think
we should probably at least say something short about the pg_stat_slru
view (cache miss rate) and pg_stat_actitity view (waits on locks), and
how to tell if you might need to increase it. I think this probably
needs a new paragraph, separate from the docs for the individual GUC.

4. Do we want to ship the dynahash patch?

+0.9. The slight hesitation is that it's new code written very late
in the cycle, so it may still have bugs or unintended consequences,
and as you said, at small sizes the linear search must be faster than
the hash computation. Could you help test it, and try to break it?
Can we quantify the scaling effect for some interesting workloads, to
see at what size the dynahash beats the linear search, so that we can
make an informed decision? Of course, without a hash table, large
sizes will surely work badly, so it'd be tempting to restrict the size
you can set the GUC to.

If we do include the dynahash patch, then I think it would also be
reasonable to change the formula for the default, to make it higher on
large systems. The restriction to 128 buffers (= 1MB) doesn't make
much sense on a high frequency OLTP system with 128GB of shared
buffers or even 4GB. I think "unleashing better defaults" would
actually be bigger news than the GUC for typical users, because
they'll just see PG14 use a few extra MB and go faster without having
to learn about these obscure new settings.

5. Do we want to ship the simplehash patch?

-0.5. It's a bit too exciting for the last minute, so I'd be inclined
to wait until the next cycle to do some more research and testing. I
know it's a better idea in the long run.

#56Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thomas Munro (#55)
Re: MultiXact\SLRU buffers configuration

29 марта 2021 г., в 02:15, Thomas Munro <thomas.munro@gmail.com> написал(а):

On Sat, Mar 27, 2021 at 6:31 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

27 марта 2021 г., в 01:26, Thomas Munro <thomas.munro@gmail.com> написал(а):
, and murmurhash which is inlineable and
branch-free.

I think pageno is a hash already. Why hash any further? And pages accessed together will have smaller access time due to colocation.

Yeah, if clog_buffers is large enough then it's already a "perfect
hash", but if it's not then you might get some weird "harmonic"
effects (not sure if that's the right word), basically higher or lower
collision rate depending on coincidences in the data. If you apply a
hash, the collisions should be evenly spread out so at least it'll be
somewhat consistent. Does that make sense?

As far as I understand "Harmonic" effects only make sense if the distribution is unknown. Hash protects from "periodic" data when periods are equal to hash table size. I don't think we need to protect from this case, SLRU data is expected to be localised...
Cost of this protection is necessity to calculate murmur hash on each SLRU lookup. Probably, 10-100ns. Seems like not a big deal.

(At some point I figured out that the syscaches have lower collision
rates and perform better if you use oids directly instead of hashing
them... but then it's easy to create a pathological pattern of DDL
that turns your hash table into a linked list. Not sure what to think
about that.)

I had to tweak it to support "in-place" creation and
fixed size (in other words, no allocators, for use in shared memory).

We really need to have a test to know what happens when this structure goes out of memory, as you mentioned below. What would be apropriate place for simplehash tests?

Good questions. This has to be based on being guaranteed to have
enough space for all of the entries, so the question is really just
"how bad can performance get with different load factors". FWIW there
were some interesting cases with clustering when simplehash was first
used in the executor (see commits ab9f2c42 and parent) which required
some work on hashing quality to fix.

Interesting read, I didn't know much about simple hash, but seems like there is still many cases where it can be used for good. I always wondered why Postgres uses only Larson's linear hash.

Then I was annoyed that I had to add a "status" member to our struct,
so I tried to fix that.

Indeed, sizeof(SlruMappingTableEntry) == 9 seems strange. Will simplehash align it well?

With that "intrusive status" patch, the size is back to 8. But I
think I made a mistake: I made it steal some key space to indicate
presence, but I think the presence test should really get access to
the whole entry so that you can encode it in more ways. For example,
with slotno == -1.

Alright, considering the date, if we want to get this into PostgreSQL
14 it's time to make some decisions.

1. Do we want customisable SLRU sizes in PG14?

+1 from me, we have multiple reports of performance gains from
increasing various different SLRUs, and it's easy to find workloads
that go faster.

Yes, this is main point of this discussion. So +1 from me too.

One thought: it'd be nice if the user could *see* the current size,
when using the default. SHOW clog_buffers -> 0 isn't very helpful if
you want to increase it, but don't know what it's currently set to.
Not sure off the top of my head how best to do that.

Don't we expect that SHOW command indicate exactly same value as in config or SET command? If this convention does not exist - probably showing effective value is a good idea.

2. What names do we want the GUCs to have? Here's what we have:

Proposed GUC Directory System views
clog_buffers pg_xact Xact
multixact_offsets_buffers pg_multixact/offsets MultiXactOffset
multixact_members_buffers pg_multixact/members MultiXactMember
notify_buffers pg_notify Notify
serial_buffers pg_serial Serial
subtrans_buffers pg_subtrans Subtrans
commit_ts_buffers pg_commit_ts CommitTs

By system views, I mean pg_stat_slru, pg_shmem_allocations and
pg_stat_activity (lock names add "SLRU" on the end).

Observations:

It seems obvious that "clog_buffers" should be renamed to "xact_buffers".

+1

It's not clear whether the multixact GUCs should have the extra "s"
like the directories, or not, like the system views.

I think we show break the ties by native English speaker's ears or typing habits. I'm not a native speaker.

It see that we have "Shared Buffer Lookup Table" in
pg_shmem_allocations, so where I generated names like "Subtrans
Mapping Table" I should change that to "Lookup" to match.

3. What recommendations should we make about how to set it?

I think the answer depends partially on the next questions! I think
we should probably at least say something short about the pg_stat_slru
view (cache miss rate) and pg_stat_actitity view (waits on locks), and
how to tell if you might need to increase it. I think this probably
needs a new paragraph, separate from the docs for the individual GUC.

I can only suggest incident-driven approach.
1. Observe ridiculous amount of backends waiting on particular SLRU.
2. Double SLRU buffers for that SLRU.
3. Goto 1.
I don't think we should mention this approach in docs.

4. Do we want to ship the dynahash patch?

This patch allows to throw infinite amount of memory on a problem of SLRU waiting for IO. So the scale of improvement is much higher. Do I want that we ship this patch? Definitely. Does this change much? I don't know.

+0.9. The slight hesitation is that it's new code written very late
in the cycle, so it may still have bugs or unintended consequences,
and as you said, at small sizes the linear search must be faster than
the hash computation. Could you help test it, and try to break it?

I'll test it and try to break.

Can we quantify the scaling effect for some interesting workloads, to
see at what size the dynahash beats the linear search, so that we can
make an informed decision?

I think we cannot statistically distinguish linear search from hash search by means of SLRU. But we can create some synthetic benchmarks.

Of course, without a hash table, large
sizes will surely work badly, so it'd be tempting to restrict the size
you can set the GUC to.

If we do include the dynahash patch, then I think it would also be
reasonable to change the formula for the default, to make it higher on
large systems. The restriction to 128 buffers (= 1MB) doesn't make
much sense on a high frequency OLTP system with 128GB of shared
buffers or even 4GB. I think "unleashing better defaults" would
actually be bigger news than the GUC for typical users, because
they'll just see PG14 use a few extra MB and go faster without having
to learn about these obscure new settings.

I agree. I don't see why we would need to limit buffers to 128 in presence of hash search.

5. Do we want to ship the simplehash patch?

-0.5. It's a bit too exciting for the last minute, so I'd be inclined
to wait until the next cycle to do some more research and testing. I
know it's a better idea in the long run.

OK, obviously, it's safer decision.

My TODO list:
1. Try to break patch set v13-[0001-0004]
2. Think how to measure performance of linear search versus hash search in SLRU buffer mapping.

Thanks!

Best regards, Andrey Borodin.

#57Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Andrey Borodin (#56)
Re: MultiXact\SLRU buffers configuration

29 марта 2021 г., в 11:26, Andrey Borodin <x4mmm@yandex-team.ru> написал(а):

My TODO list:
1. Try to break patch set v13-[0001-0004]
2. Think how to measure performance of linear search versus hash search in SLRU buffer mapping.

Hi Thomas!
I'm still doing my homework. And to this moment all my catch is that "utils/dynahash.h" is not necessary.

I'm thinking about hashtables and measuring performance near optimum of linear search does not seem a good idea now.
It's impossible to prove that difference is statistically significant on all platforms. But even on one platform measurements are just too noisy.

Shared buffers lookup table is indeed very similar to this SLRU lookup table. And it does not try to use more memory than needed. I could not find pgbench-visible impact of growing shared buffer lookup table. Obviously, because it's not a bottleneck on regular workload. And it's hard to guess representative pathological workload.

In fact, this thread started with proposal to use reader-writer lock for multis (instead of exclusive lock), and this proposal encountered same problem. It's very hard to create stable reproduction of pathological workload when this lock is heavily contented. Many people observed the problem, but still there is no open repro.

I bet it will be hard to prove that simplehash is any better then HTAB. But if it is really better, shared buffers could benefit from the same technique.

I think its just fine to use HTAB with normal size, as long as shared buffers do so. But there we allocate slightly more space InitBufTable(NBuffers + NUM_BUFFER_PARTITIONS). Don't we need to allocate nslots + 1 ? It seems that we always do SlruMappingRemove() before SlruMappingAdd() and it is not necessary.

Thanks!

Best regards, Andrey Borodin.

#58Thomas Munro
thomas.munro@gmail.com
In reply to: Andrey Borodin (#57)
2 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Thu, Apr 1, 2021 at 10:09 AM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

29 марта 2021 г., в 11:26, Andrey Borodin <x4mmm@yandex-team.ru> написал(а):
My TODO list:
1. Try to break patch set v13-[0001-0004]
2. Think how to measure performance of linear search versus hash search in SLRU buffer mapping.

Hi Thomas!
I'm still doing my homework. And to this moment all my catch is that "utils/dynahash.h" is not necessary.

Thanks. Here's a new patch with that fixed, and also:

1. New names ("... Mapping Table" -> "... Lookup Table" in
pg_shmem_allocations view, "clog_buffers" -> "xact_buffers") and a
couple of typos fixed here and there.

2. Remove the cap of 128 buffers for xact_buffers as agreed. We
still need a cap though, to avoid a couple of kinds of overflow inside
slru.c, both when computing the default value and accepting a
user-provided number. I introduced SLRU_MAX_ALLOWED_BUFFERS to keep
it <= 1GB, and tested this on a 32 bit build with extreme block sizes.

Likewise, I removed the cap of 16 buffers for commit_ts_buffers, but
only if you have track_commit_timestamp enabled. It seems silly to
waste 1MB per 1GB of shared_buffers on a feature you're not using. So
the default is capped at 16 in that case to preserve existing
behaviour, but otherwise can be set very large if you want.

I think it's plausible that we'll want to make the multixact sizes
adaptive too, but I that might have to be a job for later. Likewise,
I am sure that substransaction-heavy workloads might be slower than
they need to be due to the current default, but I have not done the
research, With these new GUCs, people are free to experiment and
develop theories about what the defaults should be in v15.

3. In the special case of xact_buffers, there is a lower cap of
512MB, because there's no point trying to cache more xids than there
can be in existence, and that is computed by working backwards from
CLOG_XACTS_PER_PAGE etc. It's not possible to do the same sort of
thing for the other SLRUs without overflow problems, and it doesn't
seem worth trying to fix that right now (1GB of cached commit
timestamps ought to be enough for anyone™, while the theoretical
maximum is 10 bytes for 2b xids = 20GB).

To make this more explicit for people not following our discussion in
detail: with shared_buffers=0...512MB, the behaviour doesn't change.
But for shared_buffers=1GB you'll get twice as many xact_buffers as
today (2MB instead of being capped at 1MB), and it keeps scaling
linearly from there at 0.2%. In other words, all real world databases
will get a boost in this department.

4. Change the default for commit_ts_buffers back to shared_buffers /
1024 (with a minimum of 4), because I think you might have changed it
by a copy and paste error -- or did you intend to make the default
higher?

5. Improve descriptions for the GUCs, visible in pg_settings view, to
match the documentation for related wait events. So "for commit log
SLRU" -> "for the transaction status SLRU cache", and similar
corrections elsewhere. (I am tempted to try to find a better word
than "SLRU", which doesn't seem relevant to users, but for now
consistency is good.)

6. Added a callback so that SHOW xact_buffers and SHOW
commit_ts_buffers display the real size in effect (instead of "0" for
default).

I tried running with xact_buffers=1 and soon saw why you change it to
interpret 1 the same as 0; with 1 you hit buffer starvation and get
stuck. I wish there were some way to say "the default for this GUC is
0, but if it's not zero then it's got to be at least 4". I didn't
study the theoretical basis for the previous minimum value of 4, so I
think we should keep it that way, so that if you say 3 you get 4. I
thought it was better to express that like so:

/* Use configured value if provided. */
if (xact_buffers > 0)
return Max(4, xact_buffers);
return Min(CLOG_MAX_ALLOWED_BUFFERS, Max(4, NBuffers / 512));

I'm thinking about hashtables and measuring performance near optimum of linear search does not seem a good idea now.
It's impossible to prove that difference is statistically significant on all platforms. But even on one platform measurements are just too noisy.

Shared buffers lookup table is indeed very similar to this SLRU lookup table. And it does not try to use more memory than needed. I could not find pgbench-visible impact of growing shared buffer lookup table. Obviously, because it's not a bottleneck on regular workload. And it's hard to guess representative pathological workload.

Thanks for testing. I agree that it's a good idea to follow the main
buffer pool's approach for our first version of this. One small
difference is that the SLRU patch performs the hash computation while
it holds the lock. If we computed the hash first and used
hash_search_with_hash_value(), we could compute it before we obtain
the lock, like the main buffer pool.

If we computed the hash value first, we could also ignore the rule in
the documentation for hash_search_with_hash_value() that says that you
must calculate it with get_hash_value(), and just call the hash
function ourselves, so that it's fully inlinable. The same
opportunity exists for the main buffer pool. That'd get you one of
the micro-optimisations that simplehash.h offers. Whether it's worth
bothering with, I don't know.

In fact, this thread started with proposal to use reader-writer lock for multis (instead of exclusive lock), and this proposal encountered same problem. It's very hard to create stable reproduction of pathological workload when this lock is heavily contented. Many people observed the problem, but still there is no open repro.

I bet it will be hard to prove that simplehash is any better then HTAB. But if it is really better, shared buffers could benefit from the same technique.

Agreed, there are a lot of interesting future projects in this area,
when you compare the main buffer pool, these special buffer pools, and
maybe also the "shared relfilenode" pool patch I have proposed for v15
(CF entry 2933). All have mapping tables and buffer replacement
algorithms (why should they be different?), one has partitions, some
have atomic-based header locks, they interlock with WAL differently
(on page LSN, FPIs and checksum support), ... etc etc.

I think its just fine to use HTAB with normal size, as long as shared buffers do so. But there we allocate slightly more space InitBufTable(NBuffers + NUM_BUFFER_PARTITIONS). Don't we need to allocate nslots + 1 ? It seems that we always do SlruMappingRemove() before SlruMappingAdd() and it is not necessary.

Yeah, we never try to add more elements than allowed, because we have
a big lock around the mapping. The main buffer mapping table has a
more concurrent design and might temporarily have one extra entry per
partition.

Attachments:

v14-0001-Add-a-buffer-mapping-table-for-SLRUs.patchtext/x-patch; charset=US-ASCII; name=v14-0001-Add-a-buffer-mapping-table-for-SLRUs.patchDownload
From 05ce938fef85a5f23407d6977165319650b05d63 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 25 Mar 2021 10:11:31 +1300
Subject: [PATCH v14 1/2] Add a buffer mapping table for SLRUs.

Instead of doing a linear search for the buffer holding a given page
number, use a hash table.  This will allow us to increase the size of
these caches.

Reviewed-by: Andrey M. Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 src/backend/access/transam/slru.c | 110 +++++++++++++++++++++++++-----
 src/include/access/slru.h         |   2 +
 2 files changed, 95 insertions(+), 17 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82149ad782..a88e7a38a3 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -58,6 +58,7 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "utils/hsearch.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -79,6 +80,12 @@ typedef struct SlruWriteAllData
 
 typedef struct SlruWriteAllData *SlruWriteAll;
 
+typedef struct SlruMappingTableEntry
+{
+	int			pageno;
+	int			slotno;
+} SlruMappingTableEntry;
+
 /*
  * Populate a file tag describing a segment file.  We only use the segment
  * number, since we can derive everything else we need by having separate
@@ -146,6 +153,9 @@ static int	SlruSelectLRUPage(SlruCtl ctl, int pageno);
 static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+static void	SlruMappingAdd(SlruCtl ctl, int pageno, int slotno);
+static void	SlruMappingRemove(SlruCtl ctl, int pageno);
+static int	SlruMappingFind(SlruCtl ctl, int pageno);
 
 /*
  * Initialization of shared memory
@@ -168,7 +178,8 @@ SimpleLruShmemSize(int nslots, int nlsns)
 	if (nlsns > 0)
 		sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
 
-	return BUFFERALIGN(sz) + BLCKSZ * nslots;
+	return BUFFERALIGN(sz) + BLCKSZ * nslots +
+		hash_estimate_size(nslots, sizeof(SlruMappingTableEntry));
 }
 
 /*
@@ -187,6 +198,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 			  LWLock *ctllock, const char *subdir, int tranche_id,
 			  SyncRequestHandler sync_handler)
 {
+	char		mapping_table_name[SHMEM_INDEX_KEYSIZE];
+	HASHCTL		mapping_table_info;
+	HTAB	   *mapping_table;
 	SlruShared	shared;
 	bool		found;
 
@@ -258,11 +272,21 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 	else
 		Assert(found);
 
+	/* Create or find the buffer mapping table. */
+	memset(&mapping_table_info, 0, sizeof(mapping_table_info));
+	mapping_table_info.keysize = sizeof(int);
+	mapping_table_info.entrysize = sizeof(SlruMappingTableEntry);
+	snprintf(mapping_table_name, sizeof(mapping_table_name),
+			 "%s Lookup Table", name);
+	mapping_table = ShmemInitHash(mapping_table_name, nslots, nslots,
+								  &mapping_table_info, HASH_ELEM | HASH_BLOBS);
+
 	/*
 	 * Initialize the unshared control struct, including directory path. We
 	 * assume caller set PagePrecedes.
 	 */
 	ctl->shared = shared;
+	ctl->mapping_table = mapping_table;
 	ctl->sync_handler = sync_handler;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
@@ -289,6 +313,9 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 		   shared->page_number[slotno] == pageno);
 
 	/* Mark the slot as containing this page */
+	if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+		SlruMappingRemove(ctl, shared->page_number[slotno]);
+	SlruMappingAdd(ctl, pageno, slotno);
 	shared->page_number[slotno] = pageno;
 	shared->page_status[slotno] = SLRU_PAGE_VALID;
 	shared->page_dirty[slotno] = true;
@@ -362,7 +389,10 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 		{
 			/* indeed, the I/O must have failed */
 			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
+			{
+				SlruMappingRemove(ctl, shared->page_number[slotno]);
 				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			}
 			else				/* write_in_progress */
 			{
 				shared->page_status[slotno] = SLRU_PAGE_VALID;
@@ -436,6 +466,9 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 				!shared->page_dirty[slotno]));
 
 		/* Mark the slot read-busy */
+		if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
+		SlruMappingAdd(ctl, pageno, slotno);
 		shared->page_number[slotno] = pageno;
 		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
 		shared->page_dirty[slotno] = false;
@@ -459,7 +492,13 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
 			   !shared->page_dirty[slotno]);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		if (ok)
+			shared->page_status[slotno] = SLRU_PAGE_VALID;
+		else
+		{
+			SlruMappingRemove(ctl, pageno);
+			shared->page_status[slotno] =  SLRU_PAGE_EMPTY;
+		}
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -500,20 +539,20 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	slotno = SlruMappingFind(ctl, pageno);
+	if (slotno >= 0 &&
+		shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
 	{
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
-			shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
-		{
-			/* See comments for SlruRecentlyUsed macro */
-			SlruRecentlyUsed(shared, slotno);
+		Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+		Assert(shared->page_number[slotno] == pageno);
 
-			/* update the stats counter of pages found in the SLRU */
-			pgstat_count_slru_page_hit(shared->slru_stats_idx);
+		/* See comments for SlruRecentlyUsed macro */
+		SlruRecentlyUsed(shared, slotno);
 
-			return slotno;
-		}
+		/* update the stats counter of pages found in the SLRU */
+		pgstat_count_slru_page_hit(shared->slru_stats_idx);
+
+		return slotno;
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
@@ -1029,11 +1068,12 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		slotno = SlruMappingFind(ctl, pageno);
+		if (slotno >= 0)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
-				return slotno;
+			Assert(shared->page_number[slotno] == pageno);
+			Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+			return slotno;
 		}
 
 		/*
@@ -1266,6 +1306,7 @@ restart:;
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1348,6 +1389,7 @@ restart:
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1609,3 +1651,37 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
 	errno = save_errno;
 	return result;
 }
+
+static int
+SlruMappingFind(SlruCtl ctl, int pageno)
+{
+	SlruMappingTableEntry *mapping;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_FIND, NULL);
+	if (mapping)
+		return mapping->slotno;
+
+	return -1;
+}
+
+static void
+SlruMappingAdd(SlruCtl ctl, int pageno, int slotno)
+{
+	SlruMappingTableEntry *mapping;
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_ENTER, &found);
+	mapping->slotno = slotno;
+
+	Assert(!found);
+}
+
+static void
+SlruMappingRemove(SlruCtl ctl, int pageno)
+{
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	hash_search(ctl->mapping_table, &pageno, HASH_REMOVE, &found);
+
+	Assert(found);
+}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index dd52e8cec7..8aa3efc0ee 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -16,6 +16,7 @@
 #include "access/xlogdefs.h"
 #include "storage/lwlock.h"
 #include "storage/sync.h"
+#include "utils/hsearch.h"
 
 
 /*
@@ -110,6 +111,7 @@ typedef SlruSharedData *SlruShared;
 typedef struct SlruCtlData
 {
 	SlruShared	shared;
+	HTAB	   *mapping_table;
 
 	/*
 	 * Which sync handler function to use when handing sync requests over to
-- 
2.30.2

v14-0002-Make-all-SLRU-buffer-sizes-configurable.patchtext/x-patch; charset=US-ASCII; name=v14-0002-Make-all-SLRU-buffer-sizes-configurable.patchDownload
From edd07254e3f018ee3afe3f4251ab2cc0406d8b7a Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v14 2/2] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Remove the limits on xact_buffers and commit_ts_buffers.  The default
sizes for those caches are ~0.2% and ~0.1% of shared_buffers, as before,
but now there is no cap at 128 and 16 buffers respectively (unless
track_commit_timestamp is disabled, in the latter case, then we might as
well keep it tiny).  Sizes much larger than the old limits have been
shown to be useful on modern systems, and an earlier commit replaced a
linear search with a hash table to avoid problems with extreme cases.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 135 ++++++++++++++++++
 src/backend/access/transam/clog.c             |  23 ++-
 src/backend/access/transam/commit_ts.c        |  10 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  99 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/clog.h                     |  10 ++
 src/include/access/commit_ts.h                |   1 -
 src/include/access/multixact.h                |   4 -
 src/include/access/slru.h                     |   5 +
 src/include/access/subtrans.h                 |   2 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 18 files changed, 301 insertions(+), 46 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 701cb65cc7..58388f144f 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1886,6 +1886,141 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-xact-buffers" xreflabel="xact_buffers">
+      <term><varname>xact_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>xact_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to use to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 1024, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..dd2d7a5184 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -58,8 +58,8 @@
 
 /* We need two bits per xact, so four xacts fit in a byte */
 #define CLOG_BITS_PER_XACT	2
-#define CLOG_XACTS_PER_BYTE 4
-#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+StaticAssertDecl((CLOG_BITS_PER_XACT * CLOG_XACTS_PER_BYTE) == BITS_PER_BYTE,
+				 "CLOG_BITS_PER_XACT and CLOG_XACTS_PER_BYTE are inconsistent");
 #define CLOG_XACT_BITMASK	((1 << CLOG_BITS_PER_XACT) - 1)
 
 #define TransactionIdToPage(xid)	((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
@@ -659,23 +659,16 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
+ * By default, we'll use 2MB of for every 1GB of shared buffers, up to the
+ * theoretical maximum useful value, but always at least 4 buffers.
  */
 Size
 CLOGShmemBuffers(void)
 {
-	return Min(128, Max(4, NBuffers / 512));
+	/* Use configured value if provided. */
+	if (xact_buffers > 0)
+		return Max(4, xact_buffers);
+	return Min(CLOG_MAX_ALLOWED_BUFFERS, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 268bdba339..729a4b9212 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -524,13 +524,17 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 /*
  * Number of shared CommitTS buffers.
  *
- * We use a very similar logic as for the number of CLOG buffers; see comments
- * in CLOGShmemBuffers.
+ * By default, we'll use 1MB of for every 1GB of shared buffers, up to the
+ * maximum value that slru.c will allow, but always at least 4 buffers.
  */
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* Use configured value if provided. */
+	if (commit_ts_buffers > 0)
+		return Max(4, commit_ts_buffers);
+	return Min(track_commit_timestamp ? SLRU_MAX_ALLOWED_BUFFERS : 16,
+			   Max(4, NBuffers / 1024));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1f9f1a1fa1..21787765e2 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..785f2520fd 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 4b16fb5682..de17f52cd7 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d493aeef0f..b1f4f1651d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 73e0a672ae..3de58042d3 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -148,3 +148,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			xact_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 03daec9a08..e05f05ffea 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -29,9 +29,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -196,6 +198,8 @@ static const char *show_tcp_keepalives_idle(void);
 static const char *show_tcp_keepalives_interval(void);
 static const char *show_tcp_keepalives_count(void);
 static const char *show_tcp_user_timeout(void);
+static const char *show_xact_buffers(void);
+static const char *show_commit_ts_buffers(void);
 static bool check_maxconnections(int *newval, void **extra, GucSource source);
 static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
 static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
@@ -2315,6 +2319,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact offset SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact member SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the sub-transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the NOTIFY message SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the serializable transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"xact_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the transaction status SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&xact_buffers,
+		0, 0, CLOG_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_xact_buffers
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the size of the dedicated buffer pool used for the commit timestamp SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_commit_ts_buffers
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
@@ -11871,6 +11952,24 @@ show_tcp_user_timeout(void)
 	return nbuf;
 }
 
+static const char *
+show_xact_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CLOGShmemBuffers());
+	return nbuf;
+}
+
+static const char *
+show_commit_ts_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CommitTsShmemBuffers());
+	return nbuf;
+}
+
 static bool
 check_maxconnections(int *newval, void **extra, GucSource source)
 {
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 791d39cf07..a380d063da 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -190,6 +190,15 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers (change requires restart) -
+
+#xact_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_notify
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 39b8e4afa8..739a292f7f 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -15,6 +15,16 @@
 #include "storage/sync.h"
 #include "lib/stringinfo.h"
 
+/*
+ * Don't allow xact_buffers to be set higher than could possibly be useful or
+ * SLRU would allow.
+ */
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+#define CLOG_MAX_ALLOWED_BUFFERS \
+	Min(SLRU_MAX_ALLOWED_BUFFERS, \
+		(((MaxTransactionId / 2) + (CLOG_XACTS_PER_PAGE - 1)) / CLOG_XACTS_PER_PAGE))
+
 /*
  * Possible transaction statuses --- note that all-zeroes is the initial
  * state.
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 750369104a..e4cf988609 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -17,7 +17,6 @@
 #include "storage/sync.h"
 #include "utils/guc.h"
 
-
 extern PGDLLIMPORT bool track_commit_timestamp;
 
 extern bool check_track_commit_timestamp(bool *newval, void **extra,
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 8aa3efc0ee..97ea837646 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -18,6 +18,11 @@
 #include "storage/sync.h"
 #include "utils/hsearch.h"
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
 
 /*
  * Define SLRU segment size.  A page is the same BLCKSZ as is used everywhere
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..64fa86938e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,8 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 013850ac28..eb2c1f18f3 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -162,6 +162,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int xact_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.30.2

#59Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thomas Munro (#58)
Re: MultiXact\SLRU buffers configuration

1 апр. 2021 г., в 06:40, Thomas Munro <thomas.munro@gmail.com> написал(а):

2. Remove the cap of 128 buffers for xact_buffers as agreed. We
still need a cap though, to avoid a couple of kinds of overflow inside
slru.c, both when computing the default value and accepting a
user-provided number. I introduced SLRU_MAX_ALLOWED_BUFFERS to keep
it <= 1GB, and tested this on a 32 bit build with extreme block sizes.

BTW we do not document maximum values right now.
I was toying around with big values. For example if we set different big xact_buffers we can get something like
FATAL: not enough shared memory for data structure "Notify" (72768 bytes requested)
FATAL: not enough shared memory for data structure "Async Queue Control" (2492 bytes requested)
FATAL: not enough shared memory for data structure "Checkpointer Data" (393280 bytes requested)

But never anything about xact_buffers. I don't think it's important, though.

Likewise, I removed the cap of 16 buffers for commit_ts_buffers, but
only if you have track_commit_timestamp enabled.

Is there a reason to leave 16 pages if commit_ts is disabled? They might be useful for some artefacts of previously enabled commit_ts?

4. Change the default for commit_ts_buffers back to shared_buffers /
1024 (with a minimum of 4), because I think you might have changed it
by a copy and paste error -- or did you intend to make the default
higher?

I changed default due to some experiments with /messages/by-id/20210115220744.GA24457@alvherre.pgsql
In fact most important part of that thread was removing the cap, which is done by the patchset now.

Thanks!

Best regards, Andrey Borodin.

#60Thomas Munro
thomas.munro@gmail.com
In reply to: Andrey Borodin (#59)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Sun, Apr 4, 2021 at 7:57 AM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

I was toying around with big values. For example if we set different big

xact_buffers we can get something like

FATAL: not enough shared memory for data structure "Notify" (72768 bytes

requested)

FATAL: not enough shared memory for data structure "Async Queue Control"

(2492 bytes requested)

FATAL: not enough shared memory for data structure "Checkpointer Data"

(393280 bytes requested)

But never anything about xact_buffers. I don't think it's important,

though.

I had added the hash table size in SimpleLruShmemSize(), but then
SimpleLruInit() passed that same value in when allocating the struct, so
the struct was oversized. Oops. Fixed.

Likewise, I removed the cap of 16 buffers for commit_ts_buffers, but
only if you have track_commit_timestamp enabled.

Is there a reason to leave 16 pages if commit_ts is disabled? They might

be useful for some artefacts of previously enabled commit_ts?

Alvaro, do you have an opinion on that?

The remaining thing that bothers me about this patch set is that there is
still a linear search in the replacement algorithm, and it runs with an
exclusive lock. That creates a serious problem for large caches that still
aren't large enough. I wonder if we can do something to improve that
situation in the time we have. I considered a bunch of ideas but could
only find one that fits with slru.c's simplistic locking while tracking
recency. What do you think about a hybrid of SLRU and random replacement,
that retains some characteristics of both? You could think of it as being
a bit like the tournament selection of the genetic algorithm, with a
tournament size of (say) 8 or 16. Any ideas on how to evaluate this and
choose the number? See attached.

Attachments:

v15-0001-Add-a-buffer-mapping-table-for-SLRUs.patchtext/x-patch; charset=US-ASCII; name=v15-0001-Add-a-buffer-mapping-table-for-SLRUs.patchDownload
From 5f61bd7d227077f86649a890be603eae01c828f8 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 25 Mar 2021 10:11:31 +1300
Subject: [PATCH v15 1/3] Add a buffer mapping table for SLRUs.

Instead of doing a linear search for the buffer holding a given page
number, use a hash table.  This will allow us to increase the size of
these caches.

Reviewed-by: Andrey M. Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 src/backend/access/transam/slru.c | 121 +++++++++++++++++++++++++-----
 src/include/access/slru.h         |   2 +
 2 files changed, 103 insertions(+), 20 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82149ad782..82c61c475b 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -58,6 +58,7 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "utils/hsearch.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -79,6 +80,12 @@ typedef struct SlruWriteAllData
 
 typedef struct SlruWriteAllData *SlruWriteAll;
 
+typedef struct SlruMappingTableEntry
+{
+	int			pageno;
+	int			slotno;
+} SlruMappingTableEntry;
+
 /*
  * Populate a file tag describing a segment file.  We only use the segment
  * number, since we can derive everything else we need by having separate
@@ -146,13 +153,16 @@ static int	SlruSelectLRUPage(SlruCtl ctl, int pageno);
 static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+static void	SlruMappingAdd(SlruCtl ctl, int pageno, int slotno);
+static void	SlruMappingRemove(SlruCtl ctl, int pageno);
+static int	SlruMappingFind(SlruCtl ctl, int pageno);
 
 /*
  * Initialization of shared memory
  */
 
-Size
-SimpleLruShmemSize(int nslots, int nlsns)
+static Size
+SimpleLruStructSize(int nslots, int nlsns)
 {
 	Size		sz;
 
@@ -167,10 +177,16 @@ SimpleLruShmemSize(int nslots, int nlsns)
 
 	if (nlsns > 0)
 		sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
-
 	return BUFFERALIGN(sz) + BLCKSZ * nslots;
 }
 
+Size
+SimpleLruShmemSize(int nslots, int nlsns)
+{
+	return SimpleLruStructSize(nslots, nlsns) +
+		hash_estimate_size(nslots, sizeof(SlruMappingTableEntry));
+}
+
 /*
  * Initialize, or attach to, a simple LRU cache in shared memory.
  *
@@ -187,11 +203,14 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 			  LWLock *ctllock, const char *subdir, int tranche_id,
 			  SyncRequestHandler sync_handler)
 {
+	char		mapping_table_name[SHMEM_INDEX_KEYSIZE];
+	HASHCTL		mapping_table_info;
+	HTAB	   *mapping_table;
 	SlruShared	shared;
 	bool		found;
 
 	shared = (SlruShared) ShmemInitStruct(name,
-										  SimpleLruShmemSize(nslots, nlsns),
+										  SimpleLruStructSize(nslots, nlsns),
 										  &found);
 
 	if (!IsUnderPostmaster)
@@ -258,11 +277,21 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 	else
 		Assert(found);
 
+	/* Create or find the buffer mapping table. */
+	memset(&mapping_table_info, 0, sizeof(mapping_table_info));
+	mapping_table_info.keysize = sizeof(int);
+	mapping_table_info.entrysize = sizeof(SlruMappingTableEntry);
+	snprintf(mapping_table_name, sizeof(mapping_table_name),
+			 "%s Lookup Table", name);
+	mapping_table = ShmemInitHash(mapping_table_name, nslots, nslots,
+								  &mapping_table_info, HASH_ELEM | HASH_BLOBS);
+
 	/*
 	 * Initialize the unshared control struct, including directory path. We
 	 * assume caller set PagePrecedes.
 	 */
 	ctl->shared = shared;
+	ctl->mapping_table = mapping_table;
 	ctl->sync_handler = sync_handler;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
@@ -289,6 +318,9 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 		   shared->page_number[slotno] == pageno);
 
 	/* Mark the slot as containing this page */
+	if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+		SlruMappingRemove(ctl, shared->page_number[slotno]);
+	SlruMappingAdd(ctl, pageno, slotno);
 	shared->page_number[slotno] = pageno;
 	shared->page_status[slotno] = SLRU_PAGE_VALID;
 	shared->page_dirty[slotno] = true;
@@ -362,7 +394,10 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 		{
 			/* indeed, the I/O must have failed */
 			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
+			{
+				SlruMappingRemove(ctl, shared->page_number[slotno]);
 				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			}
 			else				/* write_in_progress */
 			{
 				shared->page_status[slotno] = SLRU_PAGE_VALID;
@@ -436,6 +471,9 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 				!shared->page_dirty[slotno]));
 
 		/* Mark the slot read-busy */
+		if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
+		SlruMappingAdd(ctl, pageno, slotno);
 		shared->page_number[slotno] = pageno;
 		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
 		shared->page_dirty[slotno] = false;
@@ -459,7 +497,13 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
 			   !shared->page_dirty[slotno]);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		if (ok)
+			shared->page_status[slotno] = SLRU_PAGE_VALID;
+		else
+		{
+			SlruMappingRemove(ctl, pageno);
+			shared->page_status[slotno] =  SLRU_PAGE_EMPTY;
+		}
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -500,20 +544,20 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	slotno = SlruMappingFind(ctl, pageno);
+	if (slotno >= 0 &&
+		shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
 	{
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
-			shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
-		{
-			/* See comments for SlruRecentlyUsed macro */
-			SlruRecentlyUsed(shared, slotno);
+		Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+		Assert(shared->page_number[slotno] == pageno);
 
-			/* update the stats counter of pages found in the SLRU */
-			pgstat_count_slru_page_hit(shared->slru_stats_idx);
+		/* See comments for SlruRecentlyUsed macro */
+		SlruRecentlyUsed(shared, slotno);
 
-			return slotno;
-		}
+		/* update the stats counter of pages found in the SLRU */
+		pgstat_count_slru_page_hit(shared->slru_stats_idx);
+
+		return slotno;
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
@@ -1029,11 +1073,12 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		slotno = SlruMappingFind(ctl, pageno);
+		if (slotno >= 0)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
-				return slotno;
+			Assert(shared->page_number[slotno] == pageno);
+			Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+			return slotno;
 		}
 
 		/*
@@ -1266,6 +1311,7 @@ restart:;
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1348,6 +1394,7 @@ restart:
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1609,3 +1656,37 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
 	errno = save_errno;
 	return result;
 }
+
+static int
+SlruMappingFind(SlruCtl ctl, int pageno)
+{
+	SlruMappingTableEntry *mapping;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_FIND, NULL);
+	if (mapping)
+		return mapping->slotno;
+
+	return -1;
+}
+
+static void
+SlruMappingAdd(SlruCtl ctl, int pageno, int slotno)
+{
+	SlruMappingTableEntry *mapping;
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_ENTER, &found);
+	mapping->slotno = slotno;
+
+	Assert(!found);
+}
+
+static void
+SlruMappingRemove(SlruCtl ctl, int pageno)
+{
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	hash_search(ctl->mapping_table, &pageno, HASH_REMOVE, &found);
+
+	Assert(found);
+}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index dd52e8cec7..8aa3efc0ee 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -16,6 +16,7 @@
 #include "access/xlogdefs.h"
 #include "storage/lwlock.h"
 #include "storage/sync.h"
+#include "utils/hsearch.h"
 
 
 /*
@@ -110,6 +111,7 @@ typedef SlruSharedData *SlruShared;
 typedef struct SlruCtlData
 {
 	SlruShared	shared;
+	HTAB	   *mapping_table;
 
 	/*
 	 * Which sync handler function to use when handing sync requests over to
-- 
2.27.0

v15-0002-Make-all-SLRU-buffer-sizes-configurable.patchtext/x-patch; charset=US-ASCII; name=v15-0002-Make-all-SLRU-buffer-sizes-configurable.patchDownload
From 3462ffe7d740ef0a8d6b217a338fa5cb55a1fbcc Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v15 2/3] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Remove the limits on xact_buffers and commit_ts_buffers.  The default
sizes for those caches are ~0.2% and ~0.1% of shared_buffers, as before,
but now there is no cap at 128 and 16 buffers respectively (unless
track_commit_timestamp is disabled, in the latter case, then we might as
well keep it tiny).  Sizes much larger than the old limits have been
shown to be useful on modern systems, and an earlier commit replaced a
linear search with a hash table to avoid problems with extreme cases.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 135 ++++++++++++++++++
 src/backend/access/transam/clog.c             |  23 ++-
 src/backend/access/transam/commit_ts.c        |  10 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  99 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/clog.h                     |  10 ++
 src/include/access/commit_ts.h                |   1 -
 src/include/access/multixact.h                |   4 -
 src/include/access/slru.h                     |   5 +
 src/include/access/subtrans.h                 |   2 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 18 files changed, 301 insertions(+), 46 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index e51639d56c..79f46a3df8 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1924,6 +1924,141 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-xact-buffers" xreflabel="xact_buffers">
+      <term><varname>xact_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>xact_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to use to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 1024, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..dd2d7a5184 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -58,8 +58,8 @@
 
 /* We need two bits per xact, so four xacts fit in a byte */
 #define CLOG_BITS_PER_XACT	2
-#define CLOG_XACTS_PER_BYTE 4
-#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+StaticAssertDecl((CLOG_BITS_PER_XACT * CLOG_XACTS_PER_BYTE) == BITS_PER_BYTE,
+				 "CLOG_BITS_PER_XACT and CLOG_XACTS_PER_BYTE are inconsistent");
 #define CLOG_XACT_BITMASK	((1 << CLOG_BITS_PER_XACT) - 1)
 
 #define TransactionIdToPage(xid)	((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
@@ -659,23 +659,16 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
+ * By default, we'll use 2MB of for every 1GB of shared buffers, up to the
+ * theoretical maximum useful value, but always at least 4 buffers.
  */
 Size
 CLOGShmemBuffers(void)
 {
-	return Min(128, Max(4, NBuffers / 512));
+	/* Use configured value if provided. */
+	if (xact_buffers > 0)
+		return Max(4, xact_buffers);
+	return Min(CLOG_MAX_ALLOWED_BUFFERS, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 268bdba339..729a4b9212 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -524,13 +524,17 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 /*
  * Number of shared CommitTS buffers.
  *
- * We use a very similar logic as for the number of CLOG buffers; see comments
- * in CLOGShmemBuffers.
+ * By default, we'll use 1MB of for every 1GB of shared buffers, up to the
+ * maximum value that slru.c will allow, but always at least 4 buffers.
  */
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* Use configured value if provided. */
+	if (commit_ts_buffers > 0)
+		return Max(4, commit_ts_buffers);
+	return Min(track_commit_timestamp ? SLRU_MAX_ALLOWED_BUFFERS : 16,
+			   Max(4, NBuffers / 1024));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1f9f1a1fa1..21787765e2 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..785f2520fd 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 4b16fb5682..de17f52cd7 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d493aeef0f..b1f4f1651d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 381d9e548d..c83151d5ab 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -150,3 +150,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			xact_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index c9c9da85f3..d0f0532daa 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -32,9 +32,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -200,6 +202,8 @@ static const char *show_tcp_keepalives_idle(void);
 static const char *show_tcp_keepalives_interval(void);
 static const char *show_tcp_keepalives_count(void);
 static const char *show_tcp_user_timeout(void);
+static const char *show_xact_buffers(void);
+static const char *show_commit_ts_buffers(void);
 static bool check_maxconnections(int *newval, void **extra, GucSource source);
 static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
 static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
@@ -2330,6 +2334,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact offset SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact member SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the sub-transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the NOTIFY message SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the serializable transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"xact_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the transaction status SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&xact_buffers,
+		0, 0, CLOG_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_xact_buffers
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the size of the dedicated buffer pool used for the commit timestamp SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_commit_ts_buffers
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
@@ -11897,6 +11978,24 @@ show_tcp_user_timeout(void)
 	return nbuf;
 }
 
+static const char *
+show_xact_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CLOGShmemBuffers());
+	return nbuf;
+}
+
+static const char *
+show_commit_ts_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CommitTsShmemBuffers());
+	return nbuf;
+}
+
 static bool
 check_maxconnections(int *newval, void **extra, GucSource source)
 {
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 39da7cc942..5bbbf85923 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -190,6 +190,15 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers (change requires restart) -
+
+#xact_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_notify
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 39b8e4afa8..739a292f7f 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -15,6 +15,16 @@
 #include "storage/sync.h"
 #include "lib/stringinfo.h"
 
+/*
+ * Don't allow xact_buffers to be set higher than could possibly be useful or
+ * SLRU would allow.
+ */
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+#define CLOG_MAX_ALLOWED_BUFFERS \
+	Min(SLRU_MAX_ALLOWED_BUFFERS, \
+		(((MaxTransactionId / 2) + (CLOG_XACTS_PER_PAGE - 1)) / CLOG_XACTS_PER_PAGE))
+
 /*
  * Possible transaction statuses --- note that all-zeroes is the initial
  * state.
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 750369104a..e4cf988609 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -17,7 +17,6 @@
 #include "storage/sync.h"
 #include "utils/guc.h"
 
-
 extern PGDLLIMPORT bool track_commit_timestamp;
 
 extern bool check_track_commit_timestamp(bool *newval, void **extra,
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 8aa3efc0ee..97ea837646 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -18,6 +18,11 @@
 #include "storage/sync.h"
 #include "utils/hsearch.h"
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
 
 /*
  * Define SLRU segment size.  A page is the same BLCKSZ as is used everywhere
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..64fa86938e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,8 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 95202d37af..495c1bf901 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -164,6 +164,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int xact_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.27.0

v15-0003-Use-hybrid-random-SLRU-replacement-for-SLRUs.patchtext/x-patch; charset=US-ASCII; name=v15-0003-Use-hybrid-random-SLRU-replacement-for-SLRUs.patchDownload
From cea3142af73c434d11206dd39a7edaa8718269b4 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Wed, 7 Apr 2021 16:39:09 +1200
Subject: [PATCH v15 3/3] Use hybrid random/SLRU replacement for SLRUs.

The previous algorithm would search the entire SLRU to find the least
recently used page.  That doesn't seem like a good idea now that the
user can set SLRUs to large sizes.  Instead, apply the existing algorithm
to a small number of randomly chosen buffers, for a cheap hybrid of SLRU
and random replacement that doesn't require a complete rewrite of
slru.c's locking.

XXX experiment
---
 src/backend/access/transam/slru.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82c61c475b..95e404e856 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -71,6 +71,14 @@
  */
 #define MAX_WRITEALL_BUFFERS	16
 
+/*
+ * We need a fast way to choose a buffer to replace, because we hold a coarse
+ * grained exclusive lock while searching.  As an improvement over simple
+ * random replacement that still has some LRU tendancies, we'll compare the
+ * recency of a smallish number of randomly selected buffers.
+ */
+#define MAX_RANDOM_SEARCH		8
+
 typedef struct SlruWriteAllData
 {
 	int			num_files;		/* # files actually open */
@@ -1071,6 +1079,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			bestinvalidslot = 0;	/* keep compiler quiet */
 		int			best_invalid_delta = -1;
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
+		int			candidates = Min(shared->num_slots, MAX_RANDOM_SEARCH);
 
 		/* See if page already has a buffer assigned */
 		slotno = SlruMappingFind(ctl, pageno);
@@ -1082,9 +1091,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		}
 
 		/*
-		 * If we find any EMPTY slot, just select that one. Else choose a
-		 * victim page to replace.  We normally take the least recently used
-		 * valid page, but we will never take the slot containing
+		 * If we find any EMPTY slot, just select that one.  Else choose a
+		 * victim page to replace.  We take the least recently used of a small
+		 * number of randomly chosen pages, to avoid having to scan a
+		 * potentially large number of pages.  We skip the slot containing
 		 * latest_page_number, even if it appears least recently used.  We
 		 * will select a slot that is already I/O busy only if there is no
 		 * other choice: a read-busy slot will not be least recently used once
@@ -1109,11 +1119,13 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		 * multiple pages with the same lru_count.
 		 */
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (int i = 0; i < candidates; ++i)
 		{
 			int			this_delta;
 			int			this_page_number;
 
+retry:
+			slotno = (random() & LONG_MAX) % shared->num_slots;
 			if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
 				return slotno;
 			this_delta = cur_count - shared->page_lru_count[slotno];
@@ -1131,7 +1143,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 			}
 			this_page_number = shared->page_number[slotno];
 			if (this_page_number == shared->latest_page_number)
-				continue;
+				goto retry;
 			if (shared->page_status[slotno] == SLRU_PAGE_VALID)
 			{
 				if (this_delta > best_valid_delta ||
-- 
2.27.0

#61Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thomas Munro (#60)
Re: MultiXact\SLRU buffers configuration

7 апр. 2021 г., в 08:59, Thomas Munro <thomas.munro@gmail.com> написал(а):

The remaining thing that bothers me about this patch set is that there is still a linear search in the replacement algorithm, and it runs with an exclusive lock. That creates a serious problem for large caches that still aren't large enough. I wonder if we can do something to improve that situation in the time we have. I considered a bunch of ideas but could only find one that fits with slru.c's simplistic locking while tracking recency. What do you think about a hybrid of SLRU and random replacement, that retains some characteristics of both? You could think of it as being a bit like the tournament selection of the genetic algorithm, with a tournament size of (say) 8 or 16. Any ideas on how to evaluate this and choose the number? See attached.
<v15-0001-Add-a-buffer-mapping-table-for-SLRUs.patch><v15-0002-Make-all-SLRU-buffer-sizes-configurable.patch><v15-0003-Use-hybrid-random-SLRU-replacement-for-SLRUs.patch>

Maybe instead of fully associative cache with random replacement we could use 1-associative cache?
i.e. each page can reside only in one spcific buffer slot. If there's something else - evict it.
I think this would be as efficient as RR cache. And it's soooo fast.

Best regards, Andrey Borodin.

#62Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Andrey Borodin (#61)
Re: MultiXact\SLRU buffers configuration

7 апр. 2021 г., в 14:44, Andrey Borodin <x4mmm@yandex-team.ru> написал(а):

Maybe instead of fully associative cache with random replacement we could use 1-associative cache?
i.e. each page can reside only in one spcific buffer slot. If there's something else - evict it.
I think this would be as efficient as RR cache. And it's soooo fast.

I thought a bit more and understood that RR is protected from two competing pages in working set, while 1-associative cache is not. So, discard that idea.

Best regards, Andrey Borodin.

#63Thomas Munro
thomas.munro@gmail.com
In reply to: Andrey Borodin (#62)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Thu, Apr 8, 2021 at 12:13 AM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

7 апр. 2021 г., в 14:44, Andrey Borodin <x4mmm@yandex-team.ru> написал(а):
Maybe instead of fully associative cache with random replacement we could use 1-associative cache?
i.e. each page can reside only in one spcific buffer slot. If there's something else - evict it.
I think this would be as efficient as RR cache. And it's soooo fast.

I thought a bit more and understood that RR is protected from two competing pages in working set, while 1-associative cache is not. So, discard that idea.

It's an interesting idea. I know that at least one proprietary fork
just puts the whole CLOG in memory for direct indexing, which is what
we'd have here if we said "oh, your xact_buffers setting is so large
I'm just going to use slotno = pageno & mask".

Here's another approach that is a little less exciting than
"tournament RR" (or whatever that should be called; I couldn't find an
established name for it). This version is just our traditional linear
search, except that it stops at 128, and remembers where to start from
next time (like a sort of Fisher-Price GCLOCK hand). This feels more
committable to me. You can argue that all buffers above 128 are bonus
buffers that PostgreSQL 13 didn't have, so the fact that we can no
longer find the globally least recently used page when you set
xact_buffers > 128 doesn't seem too bad to me, as an incremental step
(but to be clear, of course we can do better than this with more work
in later releases).

Attachments:

v16-0001-Add-a-buffer-mapping-table-for-SLRUs.patchtext/x-patch; charset=US-ASCII; name=v16-0001-Add-a-buffer-mapping-table-for-SLRUs.patchDownload
From 72ebd5052851aa4b9aa281df30b9bf42c0ad5de4 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 25 Mar 2021 10:11:31 +1300
Subject: [PATCH v16 1/3] Add a buffer mapping table for SLRUs.

Instead of doing a linear search for the buffer holding a given page
number, use a hash table.  This will allow us to increase the size of
these caches.

Reviewed-by: Andrey M. Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 src/backend/access/transam/slru.c | 121 +++++++++++++++++++++++++-----
 src/include/access/slru.h         |   2 +
 2 files changed, 103 insertions(+), 20 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82149ad782..82c61c475b 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -58,6 +58,7 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "utils/hsearch.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -79,6 +80,12 @@ typedef struct SlruWriteAllData
 
 typedef struct SlruWriteAllData *SlruWriteAll;
 
+typedef struct SlruMappingTableEntry
+{
+	int			pageno;
+	int			slotno;
+} SlruMappingTableEntry;
+
 /*
  * Populate a file tag describing a segment file.  We only use the segment
  * number, since we can derive everything else we need by having separate
@@ -146,13 +153,16 @@ static int	SlruSelectLRUPage(SlruCtl ctl, int pageno);
 static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+static void	SlruMappingAdd(SlruCtl ctl, int pageno, int slotno);
+static void	SlruMappingRemove(SlruCtl ctl, int pageno);
+static int	SlruMappingFind(SlruCtl ctl, int pageno);
 
 /*
  * Initialization of shared memory
  */
 
-Size
-SimpleLruShmemSize(int nslots, int nlsns)
+static Size
+SimpleLruStructSize(int nslots, int nlsns)
 {
 	Size		sz;
 
@@ -167,10 +177,16 @@ SimpleLruShmemSize(int nslots, int nlsns)
 
 	if (nlsns > 0)
 		sz += MAXALIGN(nslots * nlsns * sizeof(XLogRecPtr));	/* group_lsn[] */
-
 	return BUFFERALIGN(sz) + BLCKSZ * nslots;
 }
 
+Size
+SimpleLruShmemSize(int nslots, int nlsns)
+{
+	return SimpleLruStructSize(nslots, nlsns) +
+		hash_estimate_size(nslots, sizeof(SlruMappingTableEntry));
+}
+
 /*
  * Initialize, or attach to, a simple LRU cache in shared memory.
  *
@@ -187,11 +203,14 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 			  LWLock *ctllock, const char *subdir, int tranche_id,
 			  SyncRequestHandler sync_handler)
 {
+	char		mapping_table_name[SHMEM_INDEX_KEYSIZE];
+	HASHCTL		mapping_table_info;
+	HTAB	   *mapping_table;
 	SlruShared	shared;
 	bool		found;
 
 	shared = (SlruShared) ShmemInitStruct(name,
-										  SimpleLruShmemSize(nslots, nlsns),
+										  SimpleLruStructSize(nslots, nlsns),
 										  &found);
 
 	if (!IsUnderPostmaster)
@@ -258,11 +277,21 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 	else
 		Assert(found);
 
+	/* Create or find the buffer mapping table. */
+	memset(&mapping_table_info, 0, sizeof(mapping_table_info));
+	mapping_table_info.keysize = sizeof(int);
+	mapping_table_info.entrysize = sizeof(SlruMappingTableEntry);
+	snprintf(mapping_table_name, sizeof(mapping_table_name),
+			 "%s Lookup Table", name);
+	mapping_table = ShmemInitHash(mapping_table_name, nslots, nslots,
+								  &mapping_table_info, HASH_ELEM | HASH_BLOBS);
+
 	/*
 	 * Initialize the unshared control struct, including directory path. We
 	 * assume caller set PagePrecedes.
 	 */
 	ctl->shared = shared;
+	ctl->mapping_table = mapping_table;
 	ctl->sync_handler = sync_handler;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
@@ -289,6 +318,9 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 		   shared->page_number[slotno] == pageno);
 
 	/* Mark the slot as containing this page */
+	if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+		SlruMappingRemove(ctl, shared->page_number[slotno]);
+	SlruMappingAdd(ctl, pageno, slotno);
 	shared->page_number[slotno] = pageno;
 	shared->page_status[slotno] = SLRU_PAGE_VALID;
 	shared->page_dirty[slotno] = true;
@@ -362,7 +394,10 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 		{
 			/* indeed, the I/O must have failed */
 			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
+			{
+				SlruMappingRemove(ctl, shared->page_number[slotno]);
 				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			}
 			else				/* write_in_progress */
 			{
 				shared->page_status[slotno] = SLRU_PAGE_VALID;
@@ -436,6 +471,9 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 				!shared->page_dirty[slotno]));
 
 		/* Mark the slot read-busy */
+		if (shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
+		SlruMappingAdd(ctl, pageno, slotno);
 		shared->page_number[slotno] = pageno;
 		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
 		shared->page_dirty[slotno] = false;
@@ -459,7 +497,13 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
 			   !shared->page_dirty[slotno]);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		if (ok)
+			shared->page_status[slotno] = SLRU_PAGE_VALID;
+		else
+		{
+			SlruMappingRemove(ctl, pageno);
+			shared->page_status[slotno] =  SLRU_PAGE_EMPTY;
+		}
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -500,20 +544,20 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	slotno = SlruMappingFind(ctl, pageno);
+	if (slotno >= 0 &&
+		shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
 	{
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
-			shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
-		{
-			/* See comments for SlruRecentlyUsed macro */
-			SlruRecentlyUsed(shared, slotno);
+		Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+		Assert(shared->page_number[slotno] == pageno);
 
-			/* update the stats counter of pages found in the SLRU */
-			pgstat_count_slru_page_hit(shared->slru_stats_idx);
+		/* See comments for SlruRecentlyUsed macro */
+		SlruRecentlyUsed(shared, slotno);
 
-			return slotno;
-		}
+		/* update the stats counter of pages found in the SLRU */
+		pgstat_count_slru_page_hit(shared->slru_stats_idx);
+
+		return slotno;
 	}
 
 	/* No luck, so switch to normal exclusive lock and do regular read */
@@ -1029,11 +1073,12 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		slotno = SlruMappingFind(ctl, pageno);
+		if (slotno >= 0)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
-				return slotno;
+			Assert(shared->page_number[slotno] == pageno);
+			Assert(shared->page_status[slotno] != SLRU_PAGE_EMPTY);
+			return slotno;
 		}
 
 		/*
@@ -1266,6 +1311,7 @@ restart:;
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1348,6 +1394,7 @@ restart:
 		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
 			!shared->page_dirty[slotno])
 		{
+			SlruMappingRemove(ctl, shared->page_number[slotno]);
 			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
 			continue;
 		}
@@ -1609,3 +1656,37 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
 	errno = save_errno;
 	return result;
 }
+
+static int
+SlruMappingFind(SlruCtl ctl, int pageno)
+{
+	SlruMappingTableEntry *mapping;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_FIND, NULL);
+	if (mapping)
+		return mapping->slotno;
+
+	return -1;
+}
+
+static void
+SlruMappingAdd(SlruCtl ctl, int pageno, int slotno)
+{
+	SlruMappingTableEntry *mapping;
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	mapping = hash_search(ctl->mapping_table, &pageno, HASH_ENTER, &found);
+	mapping->slotno = slotno;
+
+	Assert(!found);
+}
+
+static void
+SlruMappingRemove(SlruCtl ctl, int pageno)
+{
+	bool		found PG_USED_FOR_ASSERTS_ONLY;
+
+	hash_search(ctl->mapping_table, &pageno, HASH_REMOVE, &found);
+
+	Assert(found);
+}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index dd52e8cec7..8aa3efc0ee 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -16,6 +16,7 @@
 #include "access/xlogdefs.h"
 #include "storage/lwlock.h"
 #include "storage/sync.h"
+#include "utils/hsearch.h"
 
 
 /*
@@ -110,6 +111,7 @@ typedef SlruSharedData *SlruShared;
 typedef struct SlruCtlData
 {
 	SlruShared	shared;
+	HTAB	   *mapping_table;
 
 	/*
 	 * Which sync handler function to use when handing sync requests over to
-- 
2.30.1

v16-0002-Make-all-SLRU-buffer-sizes-configurable.patchtext/x-patch; charset=US-ASCII; name=v16-0002-Make-all-SLRU-buffer-sizes-configurable.patchDownload
From 97c5078f661a41617450826173dd252fc4d0c856 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v16 2/3] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Remove the limits on xact_buffers and commit_ts_buffers.  The default
sizes for those caches are ~0.2% and ~0.1% of shared_buffers, as before,
but now there is no cap at 128 and 16 buffers respectively (unless
track_commit_timestamp is disabled, in the latter case, then we might as
well keep it tiny).  Sizes much larger than the old limits have been
shown to be useful on modern systems, and an earlier commit replaced a
linear search with a hash table to avoid problems with extreme cases.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 135 ++++++++++++++++++
 src/backend/access/transam/clog.c             |  23 ++-
 src/backend/access/transam/commit_ts.c        |  10 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  99 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/clog.h                     |  10 ++
 src/include/access/commit_ts.h                |   1 -
 src/include/access/multixact.h                |   4 -
 src/include/access/slru.h                     |   5 +
 src/include/access/subtrans.h                 |   2 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 18 files changed, 301 insertions(+), 46 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 963824d050..58c46edf62 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1924,6 +1924,141 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-xact-buffers" xreflabel="xact_buffers">
+      <term><varname>xact_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>xact_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to use to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 1024, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..dd2d7a5184 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -58,8 +58,8 @@
 
 /* We need two bits per xact, so four xacts fit in a byte */
 #define CLOG_BITS_PER_XACT	2
-#define CLOG_XACTS_PER_BYTE 4
-#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+StaticAssertDecl((CLOG_BITS_PER_XACT * CLOG_XACTS_PER_BYTE) == BITS_PER_BYTE,
+				 "CLOG_BITS_PER_XACT and CLOG_XACTS_PER_BYTE are inconsistent");
 #define CLOG_XACT_BITMASK	((1 << CLOG_BITS_PER_XACT) - 1)
 
 #define TransactionIdToPage(xid)	((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
@@ -659,23 +659,16 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
+ * By default, we'll use 2MB of for every 1GB of shared buffers, up to the
+ * theoretical maximum useful value, but always at least 4 buffers.
  */
 Size
 CLOGShmemBuffers(void)
 {
-	return Min(128, Max(4, NBuffers / 512));
+	/* Use configured value if provided. */
+	if (xact_buffers > 0)
+		return Max(4, xact_buffers);
+	return Min(CLOG_MAX_ALLOWED_BUFFERS, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 268bdba339..729a4b9212 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -524,13 +524,17 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 /*
  * Number of shared CommitTS buffers.
  *
- * We use a very similar logic as for the number of CLOG buffers; see comments
- * in CLOGShmemBuffers.
+ * By default, we'll use 1MB of for every 1GB of shared buffers, up to the
+ * maximum value that slru.c will allow, but always at least 4 buffers.
  */
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* Use configured value if provided. */
+	if (commit_ts_buffers > 0)
+		return Max(4, commit_ts_buffers);
+	return Min(track_commit_timestamp ? SLRU_MAX_ALLOWED_BUFFERS : 16,
+			   Max(4, NBuffers / 1024));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1f9f1a1fa1..21787765e2 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..785f2520fd 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 4b16fb5682..de17f52cd7 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d493aeef0f..b1f4f1651d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 381d9e548d..c83151d5ab 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -150,3 +150,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			xact_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index bee976bae8..250cef80bd 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -32,9 +32,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -200,6 +202,8 @@ static const char *show_tcp_keepalives_idle(void);
 static const char *show_tcp_keepalives_interval(void);
 static const char *show_tcp_keepalives_count(void);
 static const char *show_tcp_user_timeout(void);
+static const char *show_xact_buffers(void);
+static const char *show_commit_ts_buffers(void);
 static bool check_maxconnections(int *newval, void **extra, GucSource source);
 static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
 static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
@@ -2340,6 +2344,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact offset SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact member SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the sub-transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the NOTIFY message SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the serializable transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"xact_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the transaction status SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&xact_buffers,
+		0, 0, CLOG_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_xact_buffers
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the size of the dedicated buffer pool used for the commit timestamp SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_commit_ts_buffers
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
@@ -11959,6 +12040,24 @@ show_tcp_user_timeout(void)
 	return nbuf;
 }
 
+static const char *
+show_xact_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CLOGShmemBuffers());
+	return nbuf;
+}
+
+static const char *
+show_commit_ts_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CommitTsShmemBuffers());
+	return nbuf;
+}
+
 static bool
 check_maxconnections(int *newval, void **extra, GucSource source)
 {
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index ff9fa006fe..7e14df3b51 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -190,6 +190,15 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers (change requires restart) -
+
+#xact_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_notify
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 39b8e4afa8..739a292f7f 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -15,6 +15,16 @@
 #include "storage/sync.h"
 #include "lib/stringinfo.h"
 
+/*
+ * Don't allow xact_buffers to be set higher than could possibly be useful or
+ * SLRU would allow.
+ */
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+#define CLOG_MAX_ALLOWED_BUFFERS \
+	Min(SLRU_MAX_ALLOWED_BUFFERS, \
+		(((MaxTransactionId / 2) + (CLOG_XACTS_PER_PAGE - 1)) / CLOG_XACTS_PER_PAGE))
+
 /*
  * Possible transaction statuses --- note that all-zeroes is the initial
  * state.
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 750369104a..e4cf988609 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -17,7 +17,6 @@
 #include "storage/sync.h"
 #include "utils/guc.h"
 
-
 extern PGDLLIMPORT bool track_commit_timestamp;
 
 extern bool check_track_commit_timestamp(bool *newval, void **extra,
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 8aa3efc0ee..97ea837646 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -18,6 +18,11 @@
 #include "storage/sync.h"
 #include "utils/hsearch.h"
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
 
 /*
  * Define SLRU segment size.  A page is the same BLCKSZ as is used everywhere
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..64fa86938e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,8 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 95202d37af..495c1bf901 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -164,6 +164,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int xact_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.30.1

v16-0003-Limit-SLRU-buffer-replacement-search.patchtext/x-patch; charset=US-ASCII; name=v16-0003-Limit-SLRU-buffer-replacement-search.patchDownload
From 79c15f73a21cfb67cb6157fc5b6822bcdc696383 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 8 Apr 2021 12:18:25 +1200
Subject: [PATCH v16 3/3] Limit SLRU buffer replacement search.

Now that users can configure large SLRU caches, slru.c's simple buffer
replacement algorithm needs some adjustment.  For now, limit its linear
search for the least recently accessed buffer to an arbitrary cap.  This
means it won't find the globally least recently used buffer, just the
least recently used in a given range of pages.  The cap is initially set
as large as the previous hard-coded search size.

Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 src/backend/access/transam/slru.c | 15 ++++++++++++++-
 src/include/access/slru.h         |  3 +++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82c61c475b..131f7a48d7 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -71,6 +71,12 @@
  */
 #define MAX_WRITEALL_BUFFERS	16
 
+/*
+ * When searching for buffers to replace, we will limit the scope of our search
+ * for now, to avoid holding an exclusive lock for too long.
+ */
+#define MAX_REPLACEMENT_SEARCH	128
+
 typedef struct SlruWriteAllData
 {
 	int			num_files;		/* # files actually open */
@@ -1060,6 +1066,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 {
 	SlruShared	shared = ctl->shared;
 
+
 	/* Outer loop handles restart after I/O */
 	for (;;)
 	{
@@ -1071,6 +1078,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			bestinvalidslot = 0;	/* keep compiler quiet */
 		int			best_invalid_delta = -1;
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
+		int			max_search;
 
 		/* See if page already has a buffer assigned */
 		slotno = SlruMappingFind(ctl, pageno);
@@ -1108,12 +1116,17 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		 * That gets us back on the path to having good data when there are
 		 * multiple pages with the same lru_count.
 		 */
+		max_search = Min(shared->num_slots, MAX_REPLACEMENT_SEARCH);
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (int i = 0; i < max_search; ++i)
 		{
 			int			this_delta;
 			int			this_page_number;
 
+			slotno = shared->search_slotno++;
+			if (shared->search_slotno == shared->num_slots)
+				shared->search_slotno = 0;
+
 			if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
 				return slotno;
 			this_delta = cur_count - shared->page_lru_count[slotno];
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 97ea837646..fb8a03972d 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -63,6 +63,9 @@ typedef struct SlruSharedData
 	/* Number of buffers managed by this SLRU structure */
 	int			num_slots;
 
+	/* Where to start buffer replacement search. */
+	int			search_slotno;
+
 	/*
 	 * Arrays holding info for each buffer slot.  Page number is undefined
 	 * when status is EMPTY, as is page_lru_count.
-- 
2.30.1

#64Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thomas Munro (#63)
Re: MultiXact\SLRU buffers configuration

8 апр. 2021 г., в 03:30, Thomas Munro <thomas.munro@gmail.com> написал(а):

Here's another approach that is a little less exciting than
"tournament RR" (or whatever that should be called; I couldn't find an
established name for it). This version is just our traditional linear
search, except that it stops at 128, and remembers where to start from
next time (like a sort of Fisher-Price GCLOCK hand). This feels more
committable to me. You can argue that all buffers above 128 are bonus
buffers that PostgreSQL 13 didn't have, so the fact that we can no
longer find the globally least recently used page when you set
xact_buffers > 128 doesn't seem too bad to me, as an incremental step
(but to be clear, of course we can do better than this with more work
in later releases).

I agree that this version of eviction seems much more effective and less intrusive than RR. And it's still LRU, which is important for subsystem that is called SLRU.
shared->search_slotno is initialized implicitly with memset(). But this seems like a common practice.
Also comment above "max_search = Min(shared->num_slots, MAX_REPLACEMENT_SEARCH);" does not reflect changes.

Besides this patch looks good to me.

Thanks!

Best regards, Andrey Borodin.

#65Thomas Munro
thomas.munro@gmail.com
In reply to: Andrey Borodin (#64)
Re: MultiXact\SLRU buffers configuration

On Thu, Apr 8, 2021 at 7:24 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

I agree that this version of eviction seems much more effective and less intrusive than RR. And it's still LRU, which is important for subsystem that is called SLRU.
shared->search_slotno is initialized implicitly with memset(). But this seems like a common practice.
Also comment above "max_search = Min(shared->num_slots, MAX_REPLACEMENT_SEARCH);" does not reflect changes.

Besides this patch looks good to me.

Thanks! I chickened out of committing a buffer replacement algorithm
patch written 11 hours before the feature freeze, but I also didn't
really want to commit the GUC patch without that. Ahh, if only we'd
latched onto the real problems here just a little sooner, but there is
always PostgreSQL 15, I heard it's going to be amazing. Moved to next
CF.

#66Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thomas Munro (#65)
2 attachment(s)
Re: MultiXact\SLRU buffers configuration

8 апр. 2021 г., в 15:22, Thomas Munro <thomas.munro@gmail.com> написал(а):

On Thu, Apr 8, 2021 at 7:24 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

I agree that this version of eviction seems much more effective and less intrusive than RR. And it's still LRU, which is important for subsystem that is called SLRU.
shared->search_slotno is initialized implicitly with memset(). But this seems like a common practice.
Also comment above "max_search = Min(shared->num_slots, MAX_REPLACEMENT_SEARCH);" does not reflect changes.

Besides this patch looks good to me.

Thanks! I chickened out of committing a buffer replacement algorithm
patch written 11 hours before the feature freeze, but I also didn't
really want to commit the GUC patch without that. Ahh, if only we'd
latched onto the real problems here just a little sooner, but there is
always PostgreSQL 15, I heard it's going to be amazing. Moved to next
CF.

I have one more idea inspired by CPU caches.
Let's make SLRU n-associative, where n ~ 8.
We can divide buffers into "banks", number of banks must be power of 2.
All banks are of equal size. We choose bank size to approximately satisfy user's configured buffer size.
Each page can live only within one bank. We use same search and eviction algorithms as we used in SLRU, but we only need to search\evict over 8 elements.
All SLRU data of a single bank will be colocated within at most 2 cache line.

I did not come up with idea how to avoid multiplication of bank_number * bank_size in case when user configured 31337 buffers (any number that is radically not a power of 2).

PFA patch implementing this idea.

Best regards, Andrey Borodin.

Attachments:

v17-0002-Divide-SLRU-buffers-into-n-associative-banks.patchapplication/octet-stream; name=v17-0002-Divide-SLRU-buffers-into-n-associative-banks.patch; x-unix-mode=0644Download
From b418d7eafacfd9aa6d44951deda9690752732197 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sun, 11 Apr 2021 21:18:10 +0300
Subject: [PATCH v17 2/2] Divide SLRU buffers into n-associative banks

---
 src/backend/access/transam/slru.c | 36 +++++++++++++++++++++++++++----
 src/include/access/slru.h         |  2 ++
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 82149ad782..84321b7509 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -133,7 +133,7 @@ typedef enum
 static SlruErrorCause slru_errcause;
 static int	slru_errno;
 
-
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset);
 static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
 static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
 static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
@@ -147,6 +147,23 @@ static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
 
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset)
+{
+	*banksize = *nslots;
+	int nbanks = 1;
+	*bankoffset = 0;
+	while (*banksize > 15)
+	{
+		if ((*banksize & 1) != 0)
+			*banksize +=1;
+		*banksize /= 2;
+		nbanks *= 2;
+		*bankoffset += 1;
+	}
+	elog(DEBUG5, "nslots %d banksize %d nbanks %d ", *nslots, *banksize, nbanks);
+	*nslots = *banksize * nbanks;
+}
+
 /*
  * Initialization of shared memory
  */
@@ -155,6 +172,8 @@ Size
 SimpleLruShmemSize(int nslots, int nlsns)
 {
 	Size		sz;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
@@ -189,6 +208,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 {
 	SlruShared	shared;
 	bool		found;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	shared = (SlruShared) ShmemInitStruct(name,
 										  SimpleLruShmemSize(nslots, nlsns),
@@ -208,6 +229,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 		shared->ControlLock = ctllock;
 
 		shared->num_slots = nslots;
+		shared->bank_mask =  (1 << bankoffset) - 1;
+		shared->bank_size = banksize;
+		
 		shared->lsn_groups_per_page = nlsns;
 
 		shared->cur_lru_count = 0;
@@ -500,7 +524,9 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+	int bankend = bankstart + shared->bank_size;
+	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
 		if (shared->page_number[slotno] == pageno &&
 			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
@@ -1029,7 +1055,9 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+		int bankend = bankstart + shared->bank_size;
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			if (shared->page_number[slotno] == pageno &&
 				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
@@ -1064,7 +1092,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		 * multiple pages with the same lru_count.
 		 */
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			int			this_delta;
 			int			this_page_number;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 793c045f16..f4df54d3c1 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -61,6 +61,8 @@ typedef struct SlruSharedData
 
 	/* Number of buffers managed by this SLRU structure */
 	int			num_slots;
+	int			bank_size;
+	int			bank_mask;
 
 	/*
 	 * Arrays holding info for each buffer slot.  Page number is undefined
-- 
2.24.3 (Apple Git-128)

v17-0001-Make-all-SLRU-buffer-sizes-configurable.patchapplication/octet-stream; name=v17-0001-Make-all-SLRU-buffer-sizes-configurable.patch; x-unix-mode=0644Download
From 46b3aff4ebede9378ea5471d578e8466f0639919 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v17 1/2] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Remove the limits on xact_buffers and commit_ts_buffers.  The default
sizes for those caches are ~0.2% and ~0.1% of shared_buffers, as before,
but now there is no cap at 128 and 16 buffers respectively (unless
track_commit_timestamp is disabled, in the latter case, then we might as
well keep it tiny).  Sizes much larger than the old limits have been
shown to be useful on modern systems, and an earlier commit replaced a
linear search with a hash table to avoid problems with extreme cases.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 135 ++++++++++++++++++
 src/backend/access/transam/clog.c             |  23 ++-
 src/backend/access/transam/commit_ts.c        |  10 +-
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  99 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/clog.h                     |  10 ++
 src/include/access/commit_ts.h                |   1 -
 src/include/access/multixact.h                |   4 -
 src/include/access/slru.h                     |   5 +
 src/include/access/subtrans.h                 |   2 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 18 files changed, 301 insertions(+), 46 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index ea5cf3a2dc..43bd93ccf4 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1924,6 +1924,141 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-xact-buffers" xreflabel="xact_buffers">
+      <term><varname>xact_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>xact_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to use to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 1024, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 6fa4713fb4..dd2d7a5184 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -58,8 +58,8 @@
 
 /* We need two bits per xact, so four xacts fit in a byte */
 #define CLOG_BITS_PER_XACT	2
-#define CLOG_XACTS_PER_BYTE 4
-#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+StaticAssertDecl((CLOG_BITS_PER_XACT * CLOG_XACTS_PER_BYTE) == BITS_PER_BYTE,
+				 "CLOG_BITS_PER_XACT and CLOG_XACTS_PER_BYTE are inconsistent");
 #define CLOG_XACT_BITMASK	((1 << CLOG_BITS_PER_XACT) - 1)
 
 #define TransactionIdToPage(xid)	((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
@@ -659,23 +659,16 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
+ * By default, we'll use 2MB of for every 1GB of shared buffers, up to the
+ * theoretical maximum useful value, but always at least 4 buffers.
  */
 Size
 CLOGShmemBuffers(void)
 {
-	return Min(128, Max(4, NBuffers / 512));
+	/* Use configured value if provided. */
+	if (xact_buffers > 0)
+		return Max(4, xact_buffers);
+	return Min(CLOG_MAX_ALLOWED_BUFFERS, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 268bdba339..729a4b9212 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -524,13 +524,17 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 /*
  * Number of shared CommitTS buffers.
  *
- * We use a very similar logic as for the number of CLOG buffers; see comments
- * in CLOGShmemBuffers.
+ * By default, we'll use 1MB of for every 1GB of shared buffers, up to the
+ * maximum value that slru.c will allow, but always at least 4 buffers.
  */
 Size
 CommitTsShmemBuffers(void)
 {
-	return Min(16, Max(4, NBuffers / 1024));
+	/* Use configured value if provided. */
+	if (commit_ts_buffers > 0)
+		return Max(4, commit_ts_buffers);
+	return Min(track_commit_timestamp ? SLRU_MAX_ALLOWED_BUFFERS : 16,
+			   Max(4, NBuffers / 1024));
 }
 
 /*
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1f9f1a1fa1..21787765e2 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1831,8 +1831,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1848,13 +1848,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f89..785f2520fd 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 4b16fb5682..de17f52cd7 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -107,7 +107,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -225,7 +225,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -514,7 +514,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -562,7 +562,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index d493aeef0f..b1f4f1651d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1395,7 +1395,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 381d9e548d..c83151d5ab 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -150,3 +150,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			xact_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index bee976bae8..250cef80bd 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -32,9 +32,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -200,6 +202,8 @@ static const char *show_tcp_keepalives_idle(void);
 static const char *show_tcp_keepalives_interval(void);
 static const char *show_tcp_keepalives_count(void);
 static const char *show_tcp_user_timeout(void);
+static const char *show_xact_buffers(void);
+static const char *show_commit_ts_buffers(void);
 static bool check_maxconnections(int *newval, void **extra, GucSource source);
 static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
 static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
@@ -2340,6 +2344,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact offset SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact member SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the sub-transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the NOTIFY message SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the serializable transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"xact_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the transaction status SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&xact_buffers,
+		0, 0, CLOG_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_xact_buffers
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the size of the dedicated buffer pool used for the commit timestamp SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_commit_ts_buffers
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
@@ -11959,6 +12040,24 @@ show_tcp_user_timeout(void)
 	return nbuf;
 }
 
+static const char *
+show_xact_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CLOGShmemBuffers());
+	return nbuf;
+}
+
+static const char *
+show_commit_ts_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CommitTsShmemBuffers());
+	return nbuf;
+}
+
 static bool
 check_maxconnections(int *newval, void **extra, GucSource source)
 {
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index ff9fa006fe..7e14df3b51 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -190,6 +190,15 @@
 					# (change requires restart)
 #backend_flush_after = 0		# measured in pages, 0 disables
 
+# - SLRU Buffers (change requires restart) -
+
+#xact_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_notify
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 39b8e4afa8..739a292f7f 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -15,6 +15,16 @@
 #include "storage/sync.h"
 #include "lib/stringinfo.h"
 
+/*
+ * Don't allow xact_buffers to be set higher than could possibly be useful or
+ * SLRU would allow.
+ */
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+#define CLOG_MAX_ALLOWED_BUFFERS \
+	Min(SLRU_MAX_ALLOWED_BUFFERS, \
+		(((MaxTransactionId / 2) + (CLOG_XACTS_PER_PAGE - 1)) / CLOG_XACTS_PER_PAGE))
+
 /*
  * Possible transaction statuses --- note that all-zeroes is the initial
  * state.
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 750369104a..e4cf988609 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -17,7 +17,6 @@
 #include "storage/sync.h"
 #include "utils/guc.h"
 
-
 extern PGDLLIMPORT bool track_commit_timestamp;
 
 extern bool check_track_commit_timestamp(bool *newval, void **extra,
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eae..97c0a46376 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index dd52e8cec7..793c045f16 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -17,6 +17,11 @@
 #include "storage/lwlock.h"
 #include "storage/sync.h"
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
 
 /*
  * Define SLRU segment size.  A page is the same BLCKSZ as is used everywhere
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae82..64fa86938e 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,8 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 9217f66b91..fa831e3721 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 95202d37af..495c1bf901 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -164,6 +164,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int xact_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b698611..c72779bd88 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.24.3 (Apple Git-128)

In reply to: Andrey Borodin (#66)
Re: MultiXact\SLRU buffers configuration

пн, 14 июн. 2021 г. в 15:07, Andrey Borodin <x4mmm@yandex-team.ru>:

PFA patch implementing this idea.

I'm benchmarked v17 patches.
Testing was done on a 96-core machine, with PGDATA completely placed in
tmpfs.
PostgreSQL was built with CFLAGS -O2.

for-update PgBench script:
\set aid random_zipfian(1, 100, 2)
begin;
select :aid from pgbench_accounts where aid = :aid for update;
update pgbench_accounts set abalance = abalance + 1 where aid = :aid;
update pgbench_accounts set abalance = abalance * 2 where aid = :aid;
update pgbench_accounts set abalance = abalance - 2 where aid = :aid;
end;

Before each test sample data was filled with "pgbench -i -s 100", testing
was performed 3 times for 1 hour each test.
The benchmark results are presented with changing
multi_xact_members_buffers and multicast_offsets_buffers (1:2 respectively):
settings tps
multixact_members_buffers_64Kb 693.2
multixact_members_buffers_128Kb 691.4
multixact_members_buffers_192Kb 696.3
multixact_members_buffers_256Kb 694.4
multixact_members_buffers_320Kb 692.3
multixact_members_buffers_448Kb 693.7
multixact_members_buffers_512Kb 693.3
vanilla 676.1

Best regards, Dmitry Vasiliev.

#68Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Andrey Borodin (#66)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

8 апр. 2021 г., в 15:22, Thomas Munro <thomas.munro@gmail.com> написал(а):

I have one more idea inspired by CPU caches.
Let's make SLRU n-associative, where n ~ 8.
We can divide buffers into "banks", number of banks must be power of 2.
All banks are of equal size. We choose bank size to approximately satisfy user's configured buffer size.
Each page can live only within one bank. We use same search and eviction algorithms as we used in SLRU, but we only need to search\evict over 8 elements.
All SLRU data of a single bank will be colocated within at most 2 cache line.

I did not come up with idea how to avoid multiplication of bank_number * bank_size in case when user configured 31337 buffers (any number that is radically not a power of 2).

We can avoid this multiplication by using gapped memory under SLRU page_statuses, but from my POV here complexity does not worth possible performance gain.

PFA rebase of the patchset. Also I've added a patch to combine page_number, page_status, and page_dirty together to touch less cachelines.

Best regards, Andrey Borodin.

Attachments:

v-18-0001-Make-all-SLRU-buffer-sizes-configurable.patchtext/x-diff; name=v-18-0001-Make-all-SLRU-buffer-sizes-configurable.patchDownload
From ea59d2ebde818ddc2a9111858b3d956cbcc7bff2 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v=18 1/3] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Remove the limits on xact_buffers and commit_ts_buffers.  The default
sizes for those caches are ~0.2% and ~0.1% of shared_buffers, as before,
but now there is no cap at 128 and 16 buffers respectively (unless
track_commit_timestamp is disabled, in the latter case, then we might as
well keep it tiny).  Sizes much larger than the old limits have been
shown to be useful on modern systems, and an earlier commit replaced a
linear search with a hash table to avoid problems with extreme cases.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 135 ++++++++++++++++++
 src/backend/access/transam/clog.c             |  23 ++-
 src/backend/access/transam/commit_ts.c        |   5 +
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  99 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/clog.h                     |  10 ++
 src/include/access/commit_ts.h                |   1 -
 src/include/access/multixact.h                |   4 -
 src/include/access/slru.h                     |   5 +
 src/include/access/subtrans.h                 |   2 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 18 files changed, 299 insertions(+), 43 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index afbb6c35e30..57d9696abe8 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1952,6 +1952,141 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-xact-buffers" xreflabel="xact_buffers">
+      <term><varname>xact_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>xact_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to use to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 1024, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3ea16a270a8..ca28ada75fa 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -58,8 +58,8 @@
 
 /* We need two bits per xact, so four xacts fit in a byte */
 #define CLOG_BITS_PER_XACT	2
-#define CLOG_XACTS_PER_BYTE 4
-#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+StaticAssertDecl((CLOG_BITS_PER_XACT * CLOG_XACTS_PER_BYTE) == BITS_PER_BYTE,
+				 "CLOG_BITS_PER_XACT and CLOG_XACTS_PER_BYTE are inconsistent");
 #define CLOG_XACT_BITMASK	((1 << CLOG_BITS_PER_XACT) - 1)
 
 #define TransactionIdToPage(xid)	((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
@@ -664,23 +664,16 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
+ * By default, we'll use 2MB of for every 1GB of shared buffers, up to the
+ * theoretical maximum useful value, but always at least 4 buffers.
  */
 Size
 CLOGShmemBuffers(void)
 {
-	return Min(128, Max(4, NBuffers / 512));
+	/* Use configured value if provided. */
+	if (xact_buffers > 0)
+		return Max(4, xact_buffers);
+	return Min(CLOG_MAX_ALLOWED_BUFFERS, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index cbbe19fea83..cb2e0ceb1c3 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -511,10 +511,15 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
  * We use a very similar logic as for the number of CLOG buffers (except we
  * scale up twice as fast with shared buffers, and the maximum is twice as
  * high); see comments in CLOGShmemBuffers.
+ * By default, we'll use 1MB of for every 1GB of shared buffers, up to the
+ * maximum value that slru.c will allow, but always at least 4 buffers.
  */
 Size
 CommitTsShmemBuffers(void)
 {
+	/* Use configured value if provided. */
+	if (commit_ts_buffers > 0)
+		return Max(4, commit_ts_buffers);
 	return Min(256, Max(4, NBuffers / 256));
 }
 
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e6c70ed0bc2..a29ab4769dc 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1834,8 +1834,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1851,13 +1851,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 6a8e521f894..785f2520fde 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 85570085450..7f2b7598449 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -117,7 +117,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -235,7 +235,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -521,7 +521,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -569,7 +569,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 4f4d5b0d20f..c5e66757643 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1396,7 +1396,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 381d9e548d1..c83151d5ab5 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -150,3 +150,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			xact_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index bff949a40bc..eb6bf4c0a04 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -32,9 +32,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -202,6 +204,8 @@ static const char *show_tcp_keepalives_idle(void);
 static const char *show_tcp_keepalives_interval(void);
 static const char *show_tcp_keepalives_count(void);
 static const char *show_tcp_user_timeout(void);
+static const char *show_xact_buffers(void);
+static const char *show_commit_ts_buffers(void);
 static bool check_maxconnections(int *newval, void **extra, GucSource source);
 static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
 static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
@@ -2366,6 +2370,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact offset SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact member SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the sub-transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the NOTIFY message SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the serializable transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"xact_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the transaction status SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&xact_buffers,
+		0, 0, CLOG_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_xact_buffers
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the size of the dedicated buffer pool used for the commit timestamp SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_commit_ts_buffers
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
@@ -12074,6 +12155,24 @@ show_tcp_user_timeout(void)
 	return nbuf;
 }
 
+static const char *
+show_xact_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CLOGShmemBuffers());
+	return nbuf;
+}
+
+static const char *
+show_commit_ts_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CommitTsShmemBuffers());
+	return nbuf;
+}
+
 static bool
 check_maxconnections(int *newval, void **extra, GucSource source)
 {
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index a1acd46b611..22bda4383ce 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -195,6 +195,15 @@
 #old_snapshot_threshold = -1		# 1min-60d; -1 disables; 0 is immediate
 					# (change requires restart)
 
+# - SLRU Buffers (change requires restart) -
+
+#xact_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_notify
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 39b8e4afa8a..739a292f7f3 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -15,6 +15,16 @@
 #include "storage/sync.h"
 #include "lib/stringinfo.h"
 
+/*
+ * Don't allow xact_buffers to be set higher than could possibly be useful or
+ * SLRU would allow.
+ */
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+#define CLOG_MAX_ALLOWED_BUFFERS \
+	Min(SLRU_MAX_ALLOWED_BUFFERS, \
+		(((MaxTransactionId / 2) + (CLOG_XACTS_PER_PAGE - 1)) / CLOG_XACTS_PER_PAGE))
+
 /*
  * Possible transaction statuses --- note that all-zeroes is the initial
  * state.
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index a1538978c62..f86760f7240 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -16,7 +16,6 @@
 #include "replication/origin.h"
 #include "storage/sync.h"
 
-
 extern PGDLLIMPORT bool track_commit_timestamp;
 
 extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4bbb035eaea..97c0a463768 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index dd52e8cec7e..793c045f160 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -17,6 +17,11 @@
 #include "storage/lwlock.h"
 #include "storage/sync.h"
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
 
 /*
  * Define SLRU segment size.  A page is the same BLCKSZ as is used everywhere
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index d0ab44ae828..64fa86938e2 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,8 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index f371ac896b9..99575974982 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 90a30160657..22d31546ad5 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -176,6 +176,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int xact_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 152b6986114..c72779bd88d 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.33.1

v-18-0003-Pack-SLRU-page_number-page_status-and-page_dirt.patchtext/x-diff; name=v-18-0003-Pack-SLRU-page_number-page_status-and-page_dirt.patchDownload
From 5c1aace8b1f5a2b852bf1476dffbd4a43f196ef3 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <x4m@flight.local>
Date: Sun, 26 Dec 2021 15:03:30 +0500
Subject: [PATCH v=18 3/3] Pack SLRU page_number, page_status and page_dirty
 toogether

This allows to test only one cacheline during successfull
SlruSelectLRUPage().
---
 src/backend/access/transam/clog.c      |  12 +--
 src/backend/access/transam/commit_ts.c |   6 +-
 src/backend/access/transam/multixact.c |  16 +--
 src/backend/access/transam/slru.c      | 143 ++++++++++++-------------
 src/backend/access/transam/subtrans.c  |   4 +-
 src/backend/commands/async.c           |   2 +-
 src/backend/storage/lmgr/predicate.c   |   2 +-
 src/include/access/slru.h              |  13 ++-
 8 files changed, 99 insertions(+), 99 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index ca28ada75fa..7d3a0286a5f 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -375,7 +375,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
 		{
 			for (i = 0; i < nsubxids; i++)
 			{
-				Assert(XactCtl->shared->page_number[slotno] == TransactionIdToPage(subxids[i]));
+				Assert(XactCtl->shared->page_entries[slotno].page_number == TransactionIdToPage(subxids[i]));
 				TransactionIdSetStatusBit(subxids[i],
 										  TRANSACTION_STATUS_SUB_COMMITTED,
 										  lsn, slotno);
@@ -389,11 +389,11 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
 	/* Set the subtransactions */
 	for (i = 0; i < nsubxids; i++)
 	{
-		Assert(XactCtl->shared->page_number[slotno] == TransactionIdToPage(subxids[i]));
+		Assert(XactCtl->shared->page_entries[slotno].page_number == TransactionIdToPage(subxids[i]));
 		TransactionIdSetStatusBit(subxids[i], status, lsn, slotno);
 	}
 
-	XactCtl->shared->page_dirty[slotno] = true;
+	XactCtl->shared->page_entries[slotno].page_dirty = true;
 }
 
 /*
@@ -713,7 +713,7 @@ BootStrapCLOG(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(XactCtl, slotno);
-	Assert(!XactCtl->shared->page_dirty[slotno]);
+	Assert(!XactCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(XactSLRULock);
 }
@@ -798,7 +798,7 @@ TrimCLOG(void)
 		/* Zero the rest of the page */
 		MemSet(byteptr + 1, 0, BLCKSZ - byteno - 1);
 
-		XactCtl->shared->page_dirty[slotno] = true;
+		XactCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(XactSLRULock);
@@ -994,7 +994,7 @@ clog_redo(XLogReaderState *record)
 
 		slotno = ZeroCLOGPage(pageno, false);
 		SimpleLruWritePage(XactCtl, slotno);
-		Assert(!XactCtl->shared->page_dirty[slotno]);
+		Assert(!XactCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(XactSLRULock);
 	}
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index cb2e0ceb1c3..6879ef3ec71 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -227,7 +227,7 @@ SetXidCommitTsInPage(TransactionId xid, int nsubxids,
 	for (i = 0; i < nsubxids; i++)
 		TransactionIdSetCommitTs(subxids[i], ts, nodeid, slotno);
 
-	CommitTsCtl->shared->page_dirty[slotno] = true;
+	CommitTsCtl->shared->page_entries[slotno].page_dirty = true;
 
 	LWLockRelease(CommitTsSLRULock);
 }
@@ -735,7 +735,7 @@ ActivateCommitTs(void)
 		LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
 		slotno = ZeroCommitTsPage(pageno, false);
 		SimpleLruWritePage(CommitTsCtl, slotno);
-		Assert(!CommitTsCtl->shared->page_dirty[slotno]);
+		Assert(!CommitTsCtl->shared->page_entries[slotno].page_dirty);
 		LWLockRelease(CommitTsSLRULock);
 	}
 
@@ -1005,7 +1005,7 @@ commit_ts_redo(XLogReaderState *record)
 
 		slotno = ZeroCommitTsPage(pageno, false);
 		SimpleLruWritePage(CommitTsCtl, slotno);
-		Assert(!CommitTsCtl->shared->page_dirty[slotno]);
+		Assert(!CommitTsCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(CommitTsSLRULock);
 	}
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index a29ab4769dc..eb32821b717 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -887,7 +887,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 
 	*offptr = offset;
 
-	MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
+	MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty = true;
 
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
@@ -931,7 +931,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 		flagsval |= (members[i].status << bshift);
 		*flagsptr = flagsval;
 
-		MultiXactMemberCtl->shared->page_dirty[slotno] = true;
+		MultiXactMemberCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(MultiXactMemberSLRULock);
@@ -1902,7 +1902,7 @@ BootStrapMultiXact(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(MultiXactOffsetCtl, slotno);
-	Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
+	Assert(!MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(MultiXactOffsetSLRULock);
 
@@ -1913,7 +1913,7 @@ BootStrapMultiXact(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(MultiXactMemberCtl, slotno);
-	Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
+	Assert(!MultiXactMemberCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(MultiXactMemberSLRULock);
 }
@@ -2074,7 +2074,7 @@ TrimMultiXact(void)
 
 		MemSet(offptr, 0, BLCKSZ - (entryno * sizeof(MultiXactOffset)));
 
-		MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
+		MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(MultiXactOffsetSLRULock);
@@ -2112,7 +2112,7 @@ TrimMultiXact(void)
 		 * writing.
 		 */
 
-		MultiXactMemberCtl->shared->page_dirty[slotno] = true;
+		MultiXactMemberCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(MultiXactMemberSLRULock);
@@ -3251,7 +3251,7 @@ multixact_redo(XLogReaderState *record)
 
 		slotno = ZeroMultiXactOffsetPage(pageno, false);
 		SimpleLruWritePage(MultiXactOffsetCtl, slotno);
-		Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
+		Assert(!MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(MultiXactOffsetSLRULock);
 	}
@@ -3266,7 +3266,7 @@ multixact_redo(XLogReaderState *record)
 
 		slotno = ZeroMultiXactMemberPage(pageno, false);
 		SimpleLruWritePage(MultiXactMemberCtl, slotno);
-		Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
+		Assert(!MultiXactMemberCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(MultiXactMemberSLRULock);
 	}
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 33857bffb79..1f87e50f05c 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -186,9 +186,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
 	sz += MAXALIGN(nslots * sizeof(char *));	/* page_buffer[] */
-	sz += MAXALIGN(nslots * sizeof(SlruPageStatus));	/* page_status[] */
-	sz += MAXALIGN(nslots * sizeof(bool));	/* page_dirty[] */
-	sz += MAXALIGN(nslots * sizeof(int));	/* page_number[] */
+	sz += MAXALIGN(nslots * sizeof(SlruPageEntry));	/* page_entries[] */
 	sz += MAXALIGN(nslots * sizeof(int));	/* page_lru_count[] */
 	sz += MAXALIGN(nslots * sizeof(LWLockPadded));	/* buffer_locks[] */
 
@@ -248,16 +246,13 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 
 		shared->slru_stats_idx = pgstat_slru_index(name);
 
+		Assert(sizeof(SlruPageEntry) == 8);
 		ptr = (char *) shared;
 		offset = MAXALIGN(sizeof(SlruSharedData));
 		shared->page_buffer = (char **) (ptr + offset);
 		offset += MAXALIGN(nslots * sizeof(char *));
-		shared->page_status = (SlruPageStatus *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
-		shared->page_dirty = (bool *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(bool));
-		shared->page_number = (int *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(int));
+		shared->page_entries = (SlruPageEntry *) (ptr + offset);
+		offset += MAXALIGN(nslots * sizeof(SlruPageEntry));
 		shared->page_lru_count = (int *) (ptr + offset);
 		offset += MAXALIGN(nslots * sizeof(int));
 
@@ -278,8 +273,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 							 tranche_id);
 
 			shared->page_buffer[slotno] = ptr;
-			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
-			shared->page_dirty[slotno] = false;
+			shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
+			shared->page_entries[slotno].page_dirty = false;
 			shared->page_lru_count[slotno] = 0;
 			ptr += BLCKSZ;
 		}
@@ -315,15 +310,15 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 
 	/* Find a suitable buffer slot for the page */
 	slotno = SlruSelectLRUPage(ctl, pageno);
-	Assert(shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
-		   (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-			!shared->page_dirty[slotno]) ||
-		   shared->page_number[slotno] == pageno);
+	Assert(shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY ||
+		   (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+			!shared->page_entries[slotno].page_dirty) ||
+		   shared->page_entries[slotno].page_number == pageno);
 
 	/* Mark the slot as containing this page */
-	shared->page_number[slotno] = pageno;
-	shared->page_status[slotno] = SLRU_PAGE_VALID;
-	shared->page_dirty[slotno] = true;
+	shared->page_entries[slotno].page_number = pageno;
+	shared->page_entries[slotno].page_status = SLRU_PAGE_VALID;
+	shared->page_entries[slotno].page_dirty = true;
 	SlruRecentlyUsed(shared, slotno);
 
 	/* Set the buffer to zeroes */
@@ -387,18 +382,18 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 	 * cheaply test for failure by seeing if the buffer lock is still held (we
 	 * assume that transaction abort would release the lock).
 	 */
-	if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS ||
-		shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS)
+	if (shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS ||
+		shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS)
 	{
 		if (LWLockConditionalAcquire(&shared->buffer_locks[slotno].lock, LW_SHARED))
 		{
 			/* indeed, the I/O must have failed */
-			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
-				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS)
+				shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
 			else				/* write_in_progress */
 			{
-				shared->page_status[slotno] = SLRU_PAGE_VALID;
-				shared->page_dirty[slotno] = true;
+				shared->page_entries[slotno].page_status = SLRU_PAGE_VALID;
+				shared->page_entries[slotno].page_dirty = true;
 			}
 			LWLockRelease(&shared->buffer_locks[slotno].lock);
 		}
@@ -438,15 +433,15 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 		slotno = SlruSelectLRUPage(ctl, pageno);
 
 		/* Did we find the page in memory? */
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+		if (shared->page_entries[slotno].page_number == pageno &&
+			shared->page_entries[slotno].page_status != SLRU_PAGE_EMPTY)
 		{
 			/*
 			 * If page is still being read in, we must wait for I/O.  Likewise
 			 * if the page is being written and the caller said that's not OK.
 			 */
-			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS ||
-				(shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS &&
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS ||
+				(shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS &&
 				 !write_ok))
 			{
 				SimpleLruWaitIO(ctl, slotno);
@@ -463,14 +458,14 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 		}
 
 		/* We found no match; assert we selected a freeable slot */
-		Assert(shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
-			   (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-				!shared->page_dirty[slotno]));
+		Assert(shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY ||
+			   (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+				!shared->page_entries[slotno].page_dirty));
 
 		/* Mark the slot read-busy */
-		shared->page_number[slotno] = pageno;
-		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
-		shared->page_dirty[slotno] = false;
+		shared->page_entries[slotno].page_number = pageno;
+		shared->page_entries[slotno].page_status = SLRU_PAGE_READ_IN_PROGRESS;
+		shared->page_entries[slotno].page_dirty = false;
 
 		/* Acquire per-buffer lock (cannot deadlock, see notes at top) */
 		LWLockAcquire(&shared->buffer_locks[slotno].lock, LW_EXCLUSIVE);
@@ -487,11 +482,11 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 		/* Re-acquire control lock and update page state */
 		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
 
-		Assert(shared->page_number[slotno] == pageno &&
-			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
-			   !shared->page_dirty[slotno]);
+		Assert(shared->page_entries[slotno].page_number == pageno &&
+			   shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS &&
+			   !shared->page_entries[slotno].page_dirty);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		shared->page_entries[slotno].page_status = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -536,9 +531,9 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	int bankend = bankstart + shared->bank_size;
 	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
-			shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
+		if (shared->page_entries[slotno].page_number == pageno &&
+			shared->page_entries[slotno].page_status != SLRU_PAGE_EMPTY &&
+			shared->page_entries[slotno].page_status != SLRU_PAGE_READ_IN_PROGRESS)
 		{
 			/* See comments for SlruRecentlyUsed macro */
 			SlruRecentlyUsed(shared, slotno);
@@ -572,12 +567,12 @@ static void
 SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
 {
 	SlruShared	shared = ctl->shared;
-	int			pageno = shared->page_number[slotno];
+	int			pageno = shared->page_entries[slotno].page_number;
 	bool		ok;
 
 	/* If a write is in progress, wait for it to finish */
-	while (shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS &&
-		   shared->page_number[slotno] == pageno)
+	while (shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS &&
+		   shared->page_entries[slotno].page_number == pageno)
 	{
 		SimpleLruWaitIO(ctl, slotno);
 	}
@@ -586,17 +581,17 @@ SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
 	 * Do nothing if page is not dirty, or if buffer no longer contains the
 	 * same page we were called for.
 	 */
-	if (!shared->page_dirty[slotno] ||
-		shared->page_status[slotno] != SLRU_PAGE_VALID ||
-		shared->page_number[slotno] != pageno)
+	if (!shared->page_entries[slotno].page_dirty ||
+		shared->page_entries[slotno].page_status != SLRU_PAGE_VALID ||
+		shared->page_entries[slotno].page_number != pageno)
 		return;
 
 	/*
 	 * Mark the slot write-busy, and clear the dirtybit.  After this point, a
 	 * transaction status update on this page will mark it dirty again.
 	 */
-	shared->page_status[slotno] = SLRU_PAGE_WRITE_IN_PROGRESS;
-	shared->page_dirty[slotno] = false;
+	shared->page_entries[slotno].page_status = SLRU_PAGE_WRITE_IN_PROGRESS;
+	shared->page_entries[slotno].page_dirty = false;
 
 	/* Acquire per-buffer lock (cannot deadlock, see notes at top) */
 	LWLockAcquire(&shared->buffer_locks[slotno].lock, LW_EXCLUSIVE);
@@ -619,14 +614,14 @@ SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
 	/* Re-acquire control lock and update page state */
 	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
 
-	Assert(shared->page_number[slotno] == pageno &&
-		   shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS);
+	Assert(shared->page_entries[slotno].page_number == pageno &&
+		   shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS);
 
 	/* If we failed to write, mark the page dirty again */
 	if (!ok)
-		shared->page_dirty[slotno] = true;
+		shared->page_entries[slotno].page_dirty = true;
 
-	shared->page_status[slotno] = SLRU_PAGE_VALID;
+	shared->page_entries[slotno].page_status = SLRU_PAGE_VALID;
 
 	LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -1067,8 +1062,8 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int bankend = bankstart + shared->bank_size;
 		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+			if (shared->page_entries[slotno].page_number == pageno &&
+				shared->page_entries[slotno].page_status != SLRU_PAGE_EMPTY)
 				return slotno;
 		}
 
@@ -1105,7 +1100,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 			int			this_delta;
 			int			this_page_number;
 
-			if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY)
 				return slotno;
 			this_delta = cur_count - shared->page_lru_count[slotno];
 			if (this_delta < 0)
@@ -1120,10 +1115,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 				shared->page_lru_count[slotno] = cur_count;
 				this_delta = 0;
 			}
-			this_page_number = shared->page_number[slotno];
+			this_page_number = shared->page_entries[slotno].page_number;
 			if (this_page_number == shared->latest_page_number)
 				continue;
-			if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID)
 			{
 				if (this_delta > best_valid_delta ||
 					(this_delta == best_valid_delta &&
@@ -1165,7 +1160,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		/*
 		 * If the selected page is clean, we're set.
 		 */
-		if (!shared->page_dirty[bestvalidslot])
+		if (!shared->page_entries[bestvalidslot].page_dirty)
 			return bestvalidslot;
 
 		/*
@@ -1217,9 +1212,9 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
 		 * already.  That's okay.
 		 */
 		Assert(allow_redirtied ||
-			   shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
-			   (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-				!shared->page_dirty[slotno]));
+			   shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY ||
+			   (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+				!shared->page_entries[slotno].page_dirty));
 	}
 
 	LWLockRelease(shared->ControlLock);
@@ -1291,18 +1286,18 @@ restart:;
 
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
 	{
-		if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY)
 			continue;
-		if (!ctl->PagePrecedes(shared->page_number[slotno], cutoffPage))
+		if (!ctl->PagePrecedes(shared->page_entries[slotno].page_number, cutoffPage))
 			continue;
 
 		/*
 		 * If page is clean, just change state to EMPTY (expected case).
 		 */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-			!shared->page_dirty[slotno])
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+			!shared->page_entries[slotno].page_dirty)
 		{
-			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
 			continue;
 		}
 
@@ -1316,7 +1311,7 @@ restart:;
 		 * won't have cause to read its data again.  For now, keep the logic
 		 * the same as it was.)
 		 */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID)
 			SlruInternalWritePage(ctl, slotno, NULL);
 		else
 			SimpleLruWaitIO(ctl, slotno);
@@ -1371,9 +1366,9 @@ restart:
 	did_write = false;
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
 	{
-		int			pagesegno = shared->page_number[slotno] / SLRU_PAGES_PER_SEGMENT;
+		int			pagesegno = shared->page_entries[slotno].page_number / SLRU_PAGES_PER_SEGMENT;
 
-		if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY)
 			continue;
 
 		/* not the segment we're looking for */
@@ -1381,15 +1376,15 @@ restart:
 			continue;
 
 		/* If page is clean, just change state to EMPTY (expected case). */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-			!shared->page_dirty[slotno])
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+			!shared->page_entries[slotno].page_dirty)
 		{
-			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
 			continue;
 		}
 
 		/* Same logic as SimpleLruTruncate() */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID)
 			SlruInternalWritePage(ctl, slotno, NULL);
 		else
 			SimpleLruWaitIO(ctl, slotno);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 785f2520fde..11754fdbac6 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -97,7 +97,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
 	{
 		Assert(*ptr == InvalidTransactionId);
 		*ptr = parent;
-		SubTransCtl->shared->page_dirty[slotno] = true;
+		SubTransCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(SubtransSLRULock);
@@ -220,7 +220,7 @@ BootStrapSUBTRANS(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(SubTransCtl, slotno);
-	Assert(!SubTransCtl->shared->page_dirty[slotno]);
+	Assert(!SubTransCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(SubtransSLRULock);
 }
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 7f2b7598449..86a5bc2430c 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -1445,7 +1445,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
 								   InvalidTransactionId);
 
 	/* Note we mark the page dirty before writing in it */
-	NotifyCtl->shared->page_dirty[slotno] = true;
+	NotifyCtl->shared->page_entries[slotno].page_dirty = true;
 
 	while (nextNotify != NULL)
 	{
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index c5e66757643..53bd7d957ce 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -963,7 +963,7 @@ SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
 		slotno = SimpleLruReadPage(SerialSlruCtl, targetPage, true, xid);
 
 	SerialValue(slotno, xid) = minConflictCommitSeqNo;
-	SerialSlruCtl->shared->page_dirty[slotno] = true;
+	SerialSlruCtl->shared->page_entries[slotno].page_dirty = true;
 
 	LWLockRelease(SerialSLRULock);
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index f4df54d3c12..0a4fae91d7f 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -44,7 +44,7 @@
  * in the latter case it implies that the page has been re-dirtied since
  * the write started.
  */
-typedef enum
+typedef enum SlruPageStatus:int16_t
 {
 	SLRU_PAGE_EMPTY,			/* buffer is not in use */
 	SLRU_PAGE_READ_IN_PROGRESS, /* page is being read in */
@@ -52,6 +52,13 @@ typedef enum
 	SLRU_PAGE_WRITE_IN_PROGRESS /* page is being written out */
 } SlruPageStatus;
 
+typedef struct SlruPageEntry
+{
+	int				page_number;
+	SlruPageStatus	page_status;
+	bool			page_dirty;
+} SlruPageEntry;
+
 /*
  * Shared-memory state
  */
@@ -69,9 +76,7 @@ typedef struct SlruSharedData
 	 * when status is EMPTY, as is page_lru_count.
 	 */
 	char	  **page_buffer;
-	SlruPageStatus *page_status;
-	bool	   *page_dirty;
-	int		   *page_number;
+	SlruPageEntry *page_entries;
 	int		   *page_lru_count;
 	LWLockPadded *buffer_locks;
 
-- 
2.33.1

v-18-0002-Divide-SLRU-buffers-into-8-associative-banks.patchtext/x-diff; name=v-18-0002-Divide-SLRU-buffers-into-8-associative-banks.patchDownload
From 12a1c31240e338c0e8c3c7211fbdd7b2e9666564 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sun, 11 Apr 2021 21:18:10 +0300
Subject: [PATCH v=18 2/3] Divide SLRU buffers into 8-associative banks

We want to eliminate linear search within SLRU buffers.
To do so we divide SLRU buffers into banks. Each bank holds
approximately 8 buffers. Each SLRU pageno may reside only in one bank.
Adjacent pagenos reside in different banks.
---
 src/backend/access/transam/slru.c | 43 ++++++++++++++++++++++++++++---
 src/include/access/slru.h         |  2 ++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 7585ae24ce9..33857bffb79 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -134,7 +134,7 @@ typedef enum
 static SlruErrorCause slru_errcause;
 static int	slru_errno;
 
-
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset);
 static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
 static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
 static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
@@ -148,6 +148,30 @@ static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
 
+/*
+ * Pick bank size optimal for N-assiciative SLRU buffers.
+ * We expect bank number to be picked from lowest bits of requested pageno.
+ * Thus we want number of banks to be power of 2. This routine computes number
+ * of banks aiming to make each bank of size 8. So we can pack page number and
+ * statuses of each bank on one cacheline.
+ */
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset)
+{
+	*banksize = *nslots;
+	int nbanks = 1;
+	*bankoffset = 0;
+	while (*banksize > 15)
+	{
+		if ((*banksize & 1) != 0)
+			*banksize +=1;
+		*banksize /= 2;
+		nbanks *= 2;
+		*bankoffset += 1;
+	}
+	elog(DEBUG5, "nslots %d banksize %d nbanks %d ", *nslots, *banksize, nbanks);
+	*nslots = *banksize * nbanks;
+}
+
 /*
  * Initialization of shared memory
  */
@@ -156,6 +180,8 @@ Size
 SimpleLruShmemSize(int nslots, int nlsns)
 {
 	Size		sz;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
@@ -190,6 +216,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 {
 	SlruShared	shared;
 	bool		found;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	shared = (SlruShared) ShmemInitStruct(name,
 										  SimpleLruShmemSize(nslots, nlsns),
@@ -209,6 +237,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 		shared->ControlLock = ctllock;
 
 		shared->num_slots = nslots;
+		shared->bank_mask =  (1 << bankoffset) - 1;
+		shared->bank_size = banksize;
+		
 		shared->lsn_groups_per_page = nlsns;
 
 		shared->cur_lru_count = 0;
@@ -501,7 +532,9 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+	int bankend = bankstart + shared->bank_size;
+	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
 		if (shared->page_number[slotno] == pageno &&
 			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
@@ -1030,7 +1063,9 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+		int bankend = bankstart + shared->bank_size;
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			if (shared->page_number[slotno] == pageno &&
 				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
@@ -1065,7 +1100,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		 * multiple pages with the same lru_count.
 		 */
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			int			this_delta;
 			int			this_page_number;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 793c045f160..f4df54d3c12 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -61,6 +61,8 @@ typedef struct SlruSharedData
 
 	/* Number of buffers managed by this SLRU structure */
 	int			num_slots;
+	int			bank_size;
+	int			bank_mask;
 
 	/*
 	 * Arrays holding info for each buffer slot.  Page number is undefined
-- 
2.33.1

#69Julien Rouhaud
rjuju123@gmail.com
In reply to: Andrey Borodin (#68)
Re: MultiXact\SLRU buffers configuration

Hi,
On Sun, Dec 26, 2021 at 03:09:59PM +0500, Andrey Borodin wrote:

PFA rebase of the patchset. Also I've added a patch to combine page_number, page_status, and page_dirty together to touch less cachelines.

The cfbot reports some errors on the latest version of the patch:

https://cirrus-ci.com/task/6121317215764480
[04:56:38.432] su postgres -c "make -s -j${BUILD_JOBS} world-bin"
[04:56:48.270] In file included from async.c:134:
[04:56:48.270] ../../../src/include/access/slru.h:47:28: error: expected identifier or ‘(’ before ‘:’ token
[04:56:48.270] 47 | typedef enum SlruPageStatus:int16_t
[04:56:48.270] | ^
[04:56:48.270] ../../../src/include/access/slru.h:53:3: warning: data definition has no type or storage class
[04:56:48.270] 53 | } SlruPageStatus;
[04:56:48.270] | ^~~~~~~~~~~~~~
[04:56:48.270] ../../../src/include/access/slru.h:53:3: warning: type defaults to ‘int’ in declaration of ‘SlruPageStatus’ [-Wimplicit-int]
[04:56:48.270] ../../../src/include/access/slru.h:58:2: error: expected specifier-qualifier-list before ‘SlruPageStatus’
[04:56:48.270] 58 | SlruPageStatus page_status;
[04:56:48.270] | ^~~~~~~~~~~~~~
[04:56:48.270] async.c: In function ‘asyncQueueAddEntries’:
[04:56:48.270] async.c:1448:41: error: ‘SlruPageEntry’ has no member named ‘page_dirty’
[04:56:48.270] 1448 | NotifyCtl->shared->page_entries[slotno].page_dirty = true;
[04:56:48.270] | ^
[04:56:48.271] make[3]: *** [<builtin>: async.o] Error 1
[04:56:48.271] make[3]: *** Waiting for unfinished jobs....
[04:56:48.297] make[2]: *** [common.mk:39: commands-recursive] Error 2
[04:56:48.297] make[2]: *** Waiting for unfinished jobs....
[04:56:54.554] In file included from clog.c:36:
[04:56:54.554] ../../../../src/include/access/slru.h:47:28: error: expected identifier or ‘(’ before ‘:’ token
[04:56:54.554] 47 | typedef enum SlruPageStatus:int16_t
[04:56:54.554] | ^
[04:56:54.554] ../../../../src/include/access/slru.h:53:3: warning: data definition has no type or storage class
[04:56:54.554] 53 | } SlruPageStatus;
[04:56:54.554] | ^~~~~~~~~~~~~~
[04:56:54.554] ../../../../src/include/access/slru.h:53:3: warning: type defaults to ‘int’ in declaration of ‘SlruPageStatus’ [-Wimplicit-int]
[04:56:54.554] ../../../../src/include/access/slru.h:58:2: error: expected specifier-qualifier-list before ‘SlruPageStatus’
[04:56:54.554] 58 | SlruPageStatus page_status;
[04:56:54.554] | ^~~~~~~~~~~~~~
[04:56:54.554] clog.c: In function ‘TransactionIdSetPageStatusInternal’:
[04:56:54.554] clog.c:396:39: error: ‘SlruPageEntry’ has no member named ‘page_dirty’
[04:56:54.554] 396 | XactCtl->shared->page_entries[slotno].page_dirty = true;
[04:56:54.554] | ^
[04:56:54.554] In file included from ../../../../src/include/postgres.h:46,
[04:56:54.554] from clog.c:33:
[04:56:54.554] clog.c: In function ‘BootStrapCLOG’:
[04:56:54.554] clog.c:716:47: error: ‘SlruPageEntry’ has no member named ‘page_dirty’
[04:56:54.554] 716 | Assert(!XactCtl->shared->page_entries[slotno].page_dirty);
[04:56:54.554] | ^
[04:56:54.554] ../../../../src/include/c.h:848:9: note: in definition of macro ‘Assert’
[04:56:54.554] 848 | if (!(condition)) \
[04:56:54.554] | ^~~~~~~~~
[04:56:54.554] clog.c: In function ‘TrimCLOG’:
[04:56:54.554] clog.c:801:40: error: ‘SlruPageEntry’ has no member named ‘page_dirty’
[04:56:54.554] 801 | XactCtl->shared->page_entries[slotno].page_dirty = true;
[04:56:54.554] | ^
[04:56:54.554] In file included from ../../../../src/include/postgres.h:46,
[04:56:54.554] from clog.c:33:
[04:56:54.554] clog.c: In function ‘clog_redo’:
[04:56:54.554] clog.c:997:48: error: ‘SlruPageEntry’ has no member named ‘page_dirty’
[04:56:54.554] 997 | Assert(!XactCtl->shared->page_entries[slotno].page_dirty);
[04:56:54.554] | ^
[04:56:54.554] ../../../../src/include/c.h:848:9: note: in definition of macro ‘Assert’
[04:56:54.554] 848 | if (!(condition)) \
[04:56:54.554] | ^~~~~~~~~
[04:56:54.555] make[4]: *** [<builtin>: clog.o] Error 1
[04:56:54.555] make[3]: *** [../../../src/backend/common.mk:39: transam-recursive] Error 2
[04:56:54.555] make[3]: *** Waiting for unfinished jobs....
[04:56:56.405] make[2]: *** [common.mk:39: access-recursive] Error 2
[04:56:56.405] make[1]: *** [Makefile:42: all-backend-recurse] Error 2
[04:56:56.405] make: *** [GNUmakefile:21: world-bin-src-recurse] Error 2
[04:56:56.407]
[04:56:56.407] Exit status: 2

Could you send a new version? In the meantime I will switch the patch status
to Waiting on Author.

#70Shawn Debnath
sdn@amazon.com
In reply to: Julien Rouhaud (#69)
Re: MultiXact\SLRU buffers configuration

On Fri, Jan 14, 2022 at 05:28:38PM +0800, Julien Rouhaud wrote:

PFA rebase of the patchset. Also I've added a patch to combine
page_number, page_status, and page_dirty together to touch less
cachelines.

The cfbot reports some errors on the latest version of the patch:

https://cirrus-ci.com/task/6121317215764480
[...]
Could you send a new version? In the meantime I will switch the patch
status
to Waiting on Author.

I was planning on running a set of stress tests on these patches. Could
we confirm which ones we plan to include in the commitfest?

--
Shawn Debnath
Amazon Web Services (AWS)

#71Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Shawn Debnath (#70)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

15 янв. 2022 г., в 03:20, Shawn Debnath <sdn@amazon.com> написал(а):

On Fri, Jan 14, 2022 at 05:28:38PM +0800, Julien Rouhaud wrote:

PFA rebase of the patchset. Also I've added a patch to combine
page_number, page_status, and page_dirty together to touch less
cachelines.

The cfbot reports some errors on the latest version of the patch:

https://cirrus-ci.com/task/6121317215764480
[...]
Could you send a new version? In the meantime I will switch the patch
status
to Waiting on Author.

I was planning on running a set of stress tests on these patches. Could
we confirm which ones we plan to include in the commitfest?

Many thanks for your interest. Here's the latest version.

Best regards, Andrey Borodin.

Attachments:

v19-0003-Pack-SLRU-page_number-page_status-and-page_dirty.patchapplication/octet-stream; name=v19-0003-Pack-SLRU-page_number-page_status-and-page_dirty.patch; x-unix-mode=0644Download
From beec299856cce82280f39d629da004a2cd6e3d04 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <x4m@flight.local>
Date: Sun, 26 Dec 2021 15:03:30 +0500
Subject: [PATCH v19 3/3] Pack SLRU page_number, page_status and page_dirty
 toogether

This allows to test only one cacheline during successfull
SlruSelectLRUPage().
---
 src/backend/access/transam/clog.c      |  12 +--
 src/backend/access/transam/commit_ts.c |   6 +-
 src/backend/access/transam/multixact.c |  16 +--
 src/backend/access/transam/slru.c      | 143 ++++++++++++-------------
 src/backend/access/transam/subtrans.c  |   4 +-
 src/backend/commands/async.c           |   2 +-
 src/backend/storage/lmgr/predicate.c   |   2 +-
 src/include/access/slru.h              |  13 ++-
 8 files changed, 99 insertions(+), 99 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 23922abc60..afb6c4ea57 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -375,7 +375,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
 		{
 			for (i = 0; i < nsubxids; i++)
 			{
-				Assert(XactCtl->shared->page_number[slotno] == TransactionIdToPage(subxids[i]));
+				Assert(XactCtl->shared->page_entries[slotno].page_number == TransactionIdToPage(subxids[i]));
 				TransactionIdSetStatusBit(subxids[i],
 										  TRANSACTION_STATUS_SUB_COMMITTED,
 										  lsn, slotno);
@@ -389,11 +389,11 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
 	/* Set the subtransactions */
 	for (i = 0; i < nsubxids; i++)
 	{
-		Assert(XactCtl->shared->page_number[slotno] == TransactionIdToPage(subxids[i]));
+		Assert(XactCtl->shared->page_entries[slotno].page_number == TransactionIdToPage(subxids[i]));
 		TransactionIdSetStatusBit(subxids[i], status, lsn, slotno);
 	}
 
-	XactCtl->shared->page_dirty[slotno] = true;
+	XactCtl->shared->page_entries[slotno].page_dirty = true;
 }
 
 /*
@@ -713,7 +713,7 @@ BootStrapCLOG(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(XactCtl, slotno);
-	Assert(!XactCtl->shared->page_dirty[slotno]);
+	Assert(!XactCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(XactSLRULock);
 }
@@ -798,7 +798,7 @@ TrimCLOG(void)
 		/* Zero the rest of the page */
 		MemSet(byteptr + 1, 0, BLCKSZ - byteno - 1);
 
-		XactCtl->shared->page_dirty[slotno] = true;
+		XactCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(XactSLRULock);
@@ -994,7 +994,7 @@ clog_redo(XLogReaderState *record)
 
 		slotno = ZeroCLOGPage(pageno, false);
 		SimpleLruWritePage(XactCtl, slotno);
-		Assert(!XactCtl->shared->page_dirty[slotno]);
+		Assert(!XactCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(XactSLRULock);
 	}
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 1247691e79..72bd116eef 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -227,7 +227,7 @@ SetXidCommitTsInPage(TransactionId xid, int nsubxids,
 	for (i = 0; i < nsubxids; i++)
 		TransactionIdSetCommitTs(subxids[i], ts, nodeid, slotno);
 
-	CommitTsCtl->shared->page_dirty[slotno] = true;
+	CommitTsCtl->shared->page_entries[slotno].page_dirty = true;
 
 	LWLockRelease(CommitTsSLRULock);
 }
@@ -735,7 +735,7 @@ ActivateCommitTs(void)
 		LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
 		slotno = ZeroCommitTsPage(pageno, false);
 		SimpleLruWritePage(CommitTsCtl, slotno);
-		Assert(!CommitTsCtl->shared->page_dirty[slotno]);
+		Assert(!CommitTsCtl->shared->page_entries[slotno].page_dirty);
 		LWLockRelease(CommitTsSLRULock);
 	}
 
@@ -1005,7 +1005,7 @@ commit_ts_redo(XLogReaderState *record)
 
 		slotno = ZeroCommitTsPage(pageno, false);
 		SimpleLruWritePage(CommitTsCtl, slotno);
-		Assert(!CommitTsCtl->shared->page_dirty[slotno]);
+		Assert(!CommitTsCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(CommitTsSLRULock);
 	}
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 3c86bd4517..276584d45e 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -887,7 +887,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 
 	*offptr = offset;
 
-	MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
+	MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty = true;
 
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
@@ -931,7 +931,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 		flagsval |= (members[i].status << bshift);
 		*flagsptr = flagsval;
 
-		MultiXactMemberCtl->shared->page_dirty[slotno] = true;
+		MultiXactMemberCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(MultiXactMemberSLRULock);
@@ -1902,7 +1902,7 @@ BootStrapMultiXact(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(MultiXactOffsetCtl, slotno);
-	Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
+	Assert(!MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(MultiXactOffsetSLRULock);
 
@@ -1913,7 +1913,7 @@ BootStrapMultiXact(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(MultiXactMemberCtl, slotno);
-	Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
+	Assert(!MultiXactMemberCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(MultiXactMemberSLRULock);
 }
@@ -2074,7 +2074,7 @@ TrimMultiXact(void)
 
 		MemSet(offptr, 0, BLCKSZ - (entryno * sizeof(MultiXactOffset)));
 
-		MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
+		MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(MultiXactOffsetSLRULock);
@@ -2112,7 +2112,7 @@ TrimMultiXact(void)
 		 * writing.
 		 */
 
-		MultiXactMemberCtl->shared->page_dirty[slotno] = true;
+		MultiXactMemberCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(MultiXactMemberSLRULock);
@@ -3251,7 +3251,7 @@ multixact_redo(XLogReaderState *record)
 
 		slotno = ZeroMultiXactOffsetPage(pageno, false);
 		SimpleLruWritePage(MultiXactOffsetCtl, slotno);
-		Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
+		Assert(!MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(MultiXactOffsetSLRULock);
 	}
@@ -3266,7 +3266,7 @@ multixact_redo(XLogReaderState *record)
 
 		slotno = ZeroMultiXactMemberPage(pageno, false);
 		SimpleLruWritePage(MultiXactMemberCtl, slotno);
-		Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
+		Assert(!MultiXactMemberCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(MultiXactMemberSLRULock);
 	}
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index f34a2e3fdd..2f5088996a 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -186,9 +186,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
 	sz += MAXALIGN(nslots * sizeof(char *));	/* page_buffer[] */
-	sz += MAXALIGN(nslots * sizeof(SlruPageStatus));	/* page_status[] */
-	sz += MAXALIGN(nslots * sizeof(bool));	/* page_dirty[] */
-	sz += MAXALIGN(nslots * sizeof(int));	/* page_number[] */
+	sz += MAXALIGN(nslots * sizeof(SlruPageEntry));	/* page_entries[] */
 	sz += MAXALIGN(nslots * sizeof(int));	/* page_lru_count[] */
 	sz += MAXALIGN(nslots * sizeof(LWLockPadded));	/* buffer_locks[] */
 
@@ -248,16 +246,13 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 
 		shared->slru_stats_idx = pgstat_slru_index(name);
 
+		Assert(sizeof(SlruPageEntry) == 8);
 		ptr = (char *) shared;
 		offset = MAXALIGN(sizeof(SlruSharedData));
 		shared->page_buffer = (char **) (ptr + offset);
 		offset += MAXALIGN(nslots * sizeof(char *));
-		shared->page_status = (SlruPageStatus *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
-		shared->page_dirty = (bool *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(bool));
-		shared->page_number = (int *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(int));
+		shared->page_entries = (SlruPageEntry *) (ptr + offset);
+		offset += MAXALIGN(nslots * sizeof(SlruPageEntry));
 		shared->page_lru_count = (int *) (ptr + offset);
 		offset += MAXALIGN(nslots * sizeof(int));
 
@@ -278,8 +273,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 							 tranche_id);
 
 			shared->page_buffer[slotno] = ptr;
-			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
-			shared->page_dirty[slotno] = false;
+			shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
+			shared->page_entries[slotno].page_dirty = false;
 			shared->page_lru_count[slotno] = 0;
 			ptr += BLCKSZ;
 		}
@@ -315,15 +310,15 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 
 	/* Find a suitable buffer slot for the page */
 	slotno = SlruSelectLRUPage(ctl, pageno);
-	Assert(shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
-		   (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-			!shared->page_dirty[slotno]) ||
-		   shared->page_number[slotno] == pageno);
+	Assert(shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY ||
+		   (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+			!shared->page_entries[slotno].page_dirty) ||
+		   shared->page_entries[slotno].page_number == pageno);
 
 	/* Mark the slot as containing this page */
-	shared->page_number[slotno] = pageno;
-	shared->page_status[slotno] = SLRU_PAGE_VALID;
-	shared->page_dirty[slotno] = true;
+	shared->page_entries[slotno].page_number = pageno;
+	shared->page_entries[slotno].page_status = SLRU_PAGE_VALID;
+	shared->page_entries[slotno].page_dirty = true;
 	SlruRecentlyUsed(shared, slotno);
 
 	/* Set the buffer to zeroes */
@@ -387,18 +382,18 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 	 * cheaply test for failure by seeing if the buffer lock is still held (we
 	 * assume that transaction abort would release the lock).
 	 */
-	if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS ||
-		shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS)
+	if (shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS ||
+		shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS)
 	{
 		if (LWLockConditionalAcquire(&shared->buffer_locks[slotno].lock, LW_SHARED))
 		{
 			/* indeed, the I/O must have failed */
-			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
-				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS)
+				shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
 			else				/* write_in_progress */
 			{
-				shared->page_status[slotno] = SLRU_PAGE_VALID;
-				shared->page_dirty[slotno] = true;
+				shared->page_entries[slotno].page_status = SLRU_PAGE_VALID;
+				shared->page_entries[slotno].page_dirty = true;
 			}
 			LWLockRelease(&shared->buffer_locks[slotno].lock);
 		}
@@ -438,15 +433,15 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 		slotno = SlruSelectLRUPage(ctl, pageno);
 
 		/* Did we find the page in memory? */
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+		if (shared->page_entries[slotno].page_number == pageno &&
+			shared->page_entries[slotno].page_status != SLRU_PAGE_EMPTY)
 		{
 			/*
 			 * If page is still being read in, we must wait for I/O.  Likewise
 			 * if the page is being written and the caller said that's not OK.
 			 */
-			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS ||
-				(shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS &&
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS ||
+				(shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS &&
 				 !write_ok))
 			{
 				SimpleLruWaitIO(ctl, slotno);
@@ -463,14 +458,14 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 		}
 
 		/* We found no match; assert we selected a freeable slot */
-		Assert(shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
-			   (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-				!shared->page_dirty[slotno]));
+		Assert(shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY ||
+			   (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+				!shared->page_entries[slotno].page_dirty));
 
 		/* Mark the slot read-busy */
-		shared->page_number[slotno] = pageno;
-		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
-		shared->page_dirty[slotno] = false;
+		shared->page_entries[slotno].page_number = pageno;
+		shared->page_entries[slotno].page_status = SLRU_PAGE_READ_IN_PROGRESS;
+		shared->page_entries[slotno].page_dirty = false;
 
 		/* Acquire per-buffer lock (cannot deadlock, see notes at top) */
 		LWLockAcquire(&shared->buffer_locks[slotno].lock, LW_EXCLUSIVE);
@@ -487,11 +482,11 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 		/* Re-acquire control lock and update page state */
 		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
 
-		Assert(shared->page_number[slotno] == pageno &&
-			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
-			   !shared->page_dirty[slotno]);
+		Assert(shared->page_entries[slotno].page_number == pageno &&
+			   shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS &&
+			   !shared->page_entries[slotno].page_dirty);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		shared->page_entries[slotno].page_status = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -536,9 +531,9 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	int bankend = bankstart + shared->bank_size;
 	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
-			shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
+		if (shared->page_entries[slotno].page_number == pageno &&
+			shared->page_entries[slotno].page_status != SLRU_PAGE_EMPTY &&
+			shared->page_entries[slotno].page_status != SLRU_PAGE_READ_IN_PROGRESS)
 		{
 			/* See comments for SlruRecentlyUsed macro */
 			SlruRecentlyUsed(shared, slotno);
@@ -572,12 +567,12 @@ static void
 SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
 {
 	SlruShared	shared = ctl->shared;
-	int			pageno = shared->page_number[slotno];
+	int			pageno = shared->page_entries[slotno].page_number;
 	bool		ok;
 
 	/* If a write is in progress, wait for it to finish */
-	while (shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS &&
-		   shared->page_number[slotno] == pageno)
+	while (shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS &&
+		   shared->page_entries[slotno].page_number == pageno)
 	{
 		SimpleLruWaitIO(ctl, slotno);
 	}
@@ -586,17 +581,17 @@ SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
 	 * Do nothing if page is not dirty, or if buffer no longer contains the
 	 * same page we were called for.
 	 */
-	if (!shared->page_dirty[slotno] ||
-		shared->page_status[slotno] != SLRU_PAGE_VALID ||
-		shared->page_number[slotno] != pageno)
+	if (!shared->page_entries[slotno].page_dirty ||
+		shared->page_entries[slotno].page_status != SLRU_PAGE_VALID ||
+		shared->page_entries[slotno].page_number != pageno)
 		return;
 
 	/*
 	 * Mark the slot write-busy, and clear the dirtybit.  After this point, a
 	 * transaction status update on this page will mark it dirty again.
 	 */
-	shared->page_status[slotno] = SLRU_PAGE_WRITE_IN_PROGRESS;
-	shared->page_dirty[slotno] = false;
+	shared->page_entries[slotno].page_status = SLRU_PAGE_WRITE_IN_PROGRESS;
+	shared->page_entries[slotno].page_dirty = false;
 
 	/* Acquire per-buffer lock (cannot deadlock, see notes at top) */
 	LWLockAcquire(&shared->buffer_locks[slotno].lock, LW_EXCLUSIVE);
@@ -619,14 +614,14 @@ SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
 	/* Re-acquire control lock and update page state */
 	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
 
-	Assert(shared->page_number[slotno] == pageno &&
-		   shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS);
+	Assert(shared->page_entries[slotno].page_number == pageno &&
+		   shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS);
 
 	/* If we failed to write, mark the page dirty again */
 	if (!ok)
-		shared->page_dirty[slotno] = true;
+		shared->page_entries[slotno].page_dirty = true;
 
-	shared->page_status[slotno] = SLRU_PAGE_VALID;
+	shared->page_entries[slotno].page_status = SLRU_PAGE_VALID;
 
 	LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -1067,8 +1062,8 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int bankend = bankstart + shared->bank_size;
 		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+			if (shared->page_entries[slotno].page_number == pageno &&
+				shared->page_entries[slotno].page_status != SLRU_PAGE_EMPTY)
 				return slotno;
 		}
 
@@ -1105,7 +1100,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 			int			this_delta;
 			int			this_page_number;
 
-			if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY)
 				return slotno;
 			this_delta = cur_count - shared->page_lru_count[slotno];
 			if (this_delta < 0)
@@ -1120,10 +1115,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 				shared->page_lru_count[slotno] = cur_count;
 				this_delta = 0;
 			}
-			this_page_number = shared->page_number[slotno];
+			this_page_number = shared->page_entries[slotno].page_number;
 			if (this_page_number == shared->latest_page_number)
 				continue;
-			if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID)
 			{
 				if (this_delta > best_valid_delta ||
 					(this_delta == best_valid_delta &&
@@ -1165,7 +1160,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		/*
 		 * If the selected page is clean, we're set.
 		 */
-		if (!shared->page_dirty[bestvalidslot])
+		if (!shared->page_entries[bestvalidslot].page_dirty)
 			return bestvalidslot;
 
 		/*
@@ -1217,9 +1212,9 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
 		 * already.  That's okay.
 		 */
 		Assert(allow_redirtied ||
-			   shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
-			   (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-				!shared->page_dirty[slotno]));
+			   shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY ||
+			   (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+				!shared->page_entries[slotno].page_dirty));
 	}
 
 	LWLockRelease(shared->ControlLock);
@@ -1291,18 +1286,18 @@ restart:;
 
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
 	{
-		if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY)
 			continue;
-		if (!ctl->PagePrecedes(shared->page_number[slotno], cutoffPage))
+		if (!ctl->PagePrecedes(shared->page_entries[slotno].page_number, cutoffPage))
 			continue;
 
 		/*
 		 * If page is clean, just change state to EMPTY (expected case).
 		 */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-			!shared->page_dirty[slotno])
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+			!shared->page_entries[slotno].page_dirty)
 		{
-			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
 			continue;
 		}
 
@@ -1316,7 +1311,7 @@ restart:;
 		 * won't have cause to read its data again.  For now, keep the logic
 		 * the same as it was.)
 		 */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID)
 			SlruInternalWritePage(ctl, slotno, NULL);
 		else
 			SimpleLruWaitIO(ctl, slotno);
@@ -1371,9 +1366,9 @@ restart:
 	did_write = false;
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
 	{
-		int			pagesegno = shared->page_number[slotno] / SLRU_PAGES_PER_SEGMENT;
+		int			pagesegno = shared->page_entries[slotno].page_number / SLRU_PAGES_PER_SEGMENT;
 
-		if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY)
 			continue;
 
 		/* not the segment we're looking for */
@@ -1381,15 +1376,15 @@ restart:
 			continue;
 
 		/* If page is clean, just change state to EMPTY (expected case). */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-			!shared->page_dirty[slotno])
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+			!shared->page_entries[slotno].page_dirty)
 		{
-			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
 			continue;
 		}
 
 		/* Same logic as SimpleLruTruncate() */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID)
 			SlruInternalWritePage(ctl, slotno, NULL);
 		else
 			SimpleLruWaitIO(ctl, slotno);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 862b0eab96..4cf34ef733 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -97,7 +97,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
 	{
 		Assert(*ptr == InvalidTransactionId);
 		*ptr = parent;
-		SubTransCtl->shared->page_dirty[slotno] = true;
+		SubTransCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(SubtransSLRULock);
@@ -220,7 +220,7 @@ BootStrapSUBTRANS(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(SubTransCtl, slotno);
-	Assert(!SubTransCtl->shared->page_dirty[slotno]);
+	Assert(!SubTransCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(SubtransSLRULock);
 }
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 6b98060330..2d220e4819 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -1445,7 +1445,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
 								   InvalidTransactionId);
 
 	/* Note we mark the page dirty before writing in it */
-	NotifyCtl->shared->page_dirty[slotno] = true;
+	NotifyCtl->shared->page_entries[slotno].page_dirty = true;
 
 	while (nextNotify != NULL)
 	{
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 1534d4ea48..957cbe82f7 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -963,7 +963,7 @@ SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
 		slotno = SimpleLruReadPage(SerialSlruCtl, targetPage, true, xid);
 
 	SerialValue(slotno, xid) = minConflictCommitSeqNo;
-	SerialSlruCtl->shared->page_dirty[slotno] = true;
+	SerialSlruCtl->shared->page_entries[slotno].page_dirty = true;
 
 	LWLockRelease(SerialSLRULock);
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index cc9cc10d27..48bf37d6e4 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -44,7 +44,7 @@
  * in the latter case it implies that the page has been re-dirtied since
  * the write started.
  */
-typedef enum
+typedef enum SlruPageStatus:int16_t
 {
 	SLRU_PAGE_EMPTY,			/* buffer is not in use */
 	SLRU_PAGE_READ_IN_PROGRESS, /* page is being read in */
@@ -52,6 +52,13 @@ typedef enum
 	SLRU_PAGE_WRITE_IN_PROGRESS /* page is being written out */
 } SlruPageStatus;
 
+typedef struct SlruPageEntry
+{
+	int				page_number;
+	SlruPageStatus	page_status;
+	bool			page_dirty;
+} SlruPageEntry;
+
 /*
  * Shared-memory state
  */
@@ -69,9 +76,7 @@ typedef struct SlruSharedData
 	 * when status is EMPTY, as is page_lru_count.
 	 */
 	char	  **page_buffer;
-	SlruPageStatus *page_status;
-	bool	   *page_dirty;
-	int		   *page_number;
+	SlruPageEntry *page_entries;
 	int		   *page_lru_count;
 	LWLockPadded *buffer_locks;
 
-- 
2.24.3 (Apple Git-128)

v19-0002-Divide-SLRU-buffers-into-8-associative-banks.patchapplication/octet-stream; name=v19-0002-Divide-SLRU-buffers-into-8-associative-banks.patch; x-unix-mode=0644Download
From c745ddad76ff9e066c0da2cd6bc57f9b0abc8a1d Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sun, 11 Apr 2021 21:18:10 +0300
Subject: [PATCH v19 2/3] Divide SLRU buffers into 8-associative banks

We want to eliminate linear search within SLRU buffers.
To do so we divide SLRU buffers into banks. Each bank holds
approximately 8 buffers. Each SLRU pageno may reside only in one bank.
Adjacent pagenos reside in different banks.
---
 src/backend/access/transam/slru.c | 43 ++++++++++++++++++++++++++++---
 src/include/access/slru.h         |  2 ++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5d..f34a2e3fdd 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -134,7 +134,7 @@ typedef enum
 static SlruErrorCause slru_errcause;
 static int	slru_errno;
 
-
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset);
 static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
 static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
 static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
@@ -148,6 +148,30 @@ static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
 
+/*
+ * Pick bank size optimal for N-assiciative SLRU buffers.
+ * We expect bank number to be picked from lowest bits of requested pageno.
+ * Thus we want number of banks to be power of 2. This routine computes number
+ * of banks aiming to make each bank of size 8. So we can pack page number and
+ * statuses of each bank on one cacheline.
+ */
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset)
+{
+	*banksize = *nslots;
+	int nbanks = 1;
+	*bankoffset = 0;
+	while (*banksize > 15)
+	{
+		if ((*banksize & 1) != 0)
+			*banksize +=1;
+		*banksize /= 2;
+		nbanks *= 2;
+		*bankoffset += 1;
+	}
+	elog(DEBUG5, "nslots %d banksize %d nbanks %d ", *nslots, *banksize, nbanks);
+	*nslots = *banksize * nbanks;
+}
+
 /*
  * Initialization of shared memory
  */
@@ -156,6 +180,8 @@ Size
 SimpleLruShmemSize(int nslots, int nlsns)
 {
 	Size		sz;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
@@ -190,6 +216,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 {
 	SlruShared	shared;
 	bool		found;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	shared = (SlruShared) ShmemInitStruct(name,
 										  SimpleLruShmemSize(nslots, nlsns),
@@ -209,6 +237,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 		shared->ControlLock = ctllock;
 
 		shared->num_slots = nslots;
+		shared->bank_mask =  (1 << bankoffset) - 1;
+		shared->bank_size = banksize;
+		
 		shared->lsn_groups_per_page = nlsns;
 
 		shared->cur_lru_count = 0;
@@ -501,7 +532,9 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+	int bankend = bankstart + shared->bank_size;
+	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
 		if (shared->page_number[slotno] == pageno &&
 			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
@@ -1030,7 +1063,9 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+		int bankend = bankstart + shared->bank_size;
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			if (shared->page_number[slotno] == pageno &&
 				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
@@ -1065,7 +1100,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		 * multiple pages with the same lru_count.
 		 */
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			int			this_delta;
 			int			this_page_number;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index b7e2e2b55e..cc9cc10d27 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -61,6 +61,8 @@ typedef struct SlruSharedData
 
 	/* Number of buffers managed by this SLRU structure */
 	int			num_slots;
+	int			bank_size;
+	int			bank_mask;
 
 	/*
 	 * Arrays holding info for each buffer slot.  Page number is undefined
-- 
2.24.3 (Apple Git-128)

v19-0001-Make-all-SLRU-buffer-sizes-configurable.patchapplication/octet-stream; name=v19-0001-Make-all-SLRU-buffer-sizes-configurable.patch; x-unix-mode=0644Download
From 8fc0196ac13f29daae76deb2df97037bc9f06931 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v19 1/3] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Remove the limits on xact_buffers and commit_ts_buffers.  The default
sizes for those caches are ~0.2% and ~0.1% of shared_buffers, as before,
but now there is no cap at 128 and 16 buffers respectively (unless
track_commit_timestamp is disabled, in the latter case, then we might as
well keep it tiny).  Sizes much larger than the old limits have been
shown to be useful on modern systems, and an earlier commit replaced a
linear search with a hash table to avoid problems with extreme cases.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 135 ++++++++++++++++++
 src/backend/access/transam/clog.c             |  23 ++-
 src/backend/access/transam/commit_ts.c        |   5 +
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  99 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/clog.h                     |  10 ++
 src/include/access/commit_ts.h                |   1 -
 src/include/access/multixact.h                |   4 -
 src/include/access/slru.h                     |   5 +
 src/include/access/subtrans.h                 |   2 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 18 files changed, 299 insertions(+), 43 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index c0fbf03dd3..962465818d 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1952,6 +1952,141 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-xact-buffers" xreflabel="xact_buffers">
+      <term><varname>xact_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>xact_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to use to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 1024, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index de787c3d37..23922abc60 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -58,8 +58,8 @@
 
 /* We need two bits per xact, so four xacts fit in a byte */
 #define CLOG_BITS_PER_XACT	2
-#define CLOG_XACTS_PER_BYTE 4
-#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+StaticAssertDecl((CLOG_BITS_PER_XACT * CLOG_XACTS_PER_BYTE) == BITS_PER_BYTE,
+				 "CLOG_BITS_PER_XACT and CLOG_XACTS_PER_BYTE are inconsistent");
 #define CLOG_XACT_BITMASK	((1 << CLOG_BITS_PER_XACT) - 1)
 
 #define TransactionIdToPage(xid)	((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
@@ -664,23 +664,16 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
+ * By default, we'll use 2MB of for every 1GB of shared buffers, up to the
+ * theoretical maximum useful value, but always at least 4 buffers.
  */
 Size
 CLOGShmemBuffers(void)
 {
-	return Min(128, Max(4, NBuffers / 512));
+	/* Use configured value if provided. */
+	if (xact_buffers > 0)
+		return Max(4, xact_buffers);
+	return Min(CLOG_MAX_ALLOWED_BUFFERS, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 659109f8d4..1247691e79 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -511,10 +511,15 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
  * We use a very similar logic as for the number of CLOG buffers (except we
  * scale up twice as fast with shared buffers, and the maximum is twice as
  * high); see comments in CLOGShmemBuffers.
+ * By default, we'll use 1MB of for every 1GB of shared buffers, up to the
+ * maximum value that slru.c will allow, but always at least 4 buffers.
  */
 Size
 CommitTsShmemBuffers(void)
 {
+	/* Use configured value if provided. */
+	if (commit_ts_buffers > 0)
+		return Max(4, commit_ts_buffers);
 	return Min(256, Max(4, NBuffers / 256));
 }
 
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 806f2e43ba..3c86bd4517 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1834,8 +1834,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1851,13 +1851,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..862b0eab96 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..6b98060330 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -117,7 +117,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -235,7 +235,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -521,7 +521,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -569,7 +569,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 25e7e4e37b..1534d4ea48 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1396,7 +1396,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index c26a1a73df..3c390213b2 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -150,3 +150,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			xact_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index effb9d03a0..7fc4e270b1 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -32,9 +32,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -203,6 +205,8 @@ static const char *show_tcp_keepalives_idle(void);
 static const char *show_tcp_keepalives_interval(void);
 static const char *show_tcp_keepalives_count(void);
 static const char *show_tcp_user_timeout(void);
+static const char *show_xact_buffers(void);
+static const char *show_commit_ts_buffers(void);
 static bool check_maxconnections(int *newval, void **extra, GucSource source);
 static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
 static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
@@ -2376,6 +2380,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact offset SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact member SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the sub-transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the NOTIFY message SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the serializable transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"xact_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the transaction status SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&xact_buffers,
+		0, 0, CLOG_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_xact_buffers
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the size of the dedicated buffer pool used for the commit timestamp SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_commit_ts_buffers
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
@@ -12039,6 +12120,24 @@ show_tcp_user_timeout(void)
 	return nbuf;
 }
 
+static const char *
+show_xact_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CLOGShmemBuffers());
+	return nbuf;
+}
+
+static const char *
+show_commit_ts_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CommitTsShmemBuffers());
+	return nbuf;
+}
+
 static bool
 check_maxconnections(int *newval, void **extra, GucSource source)
 {
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index a1acd46b61..22bda4383c 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -195,6 +195,15 @@
 #old_snapshot_threshold = -1		# 1min-60d; -1 disables; 0 is immediate
 					# (change requires restart)
 
+# - SLRU Buffers (change requires restart) -
+
+#xact_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_notify
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 543f2e2643..17d103aa4d 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -15,6 +15,16 @@
 #include "storage/sync.h"
 #include "lib/stringinfo.h"
 
+/*
+ * Don't allow xact_buffers to be set higher than could possibly be useful or
+ * SLRU would allow.
+ */
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+#define CLOG_MAX_ALLOWED_BUFFERS \
+	Min(SLRU_MAX_ALLOWED_BUFFERS, \
+		(((MaxTransactionId / 2) + (CLOG_XACTS_PER_PAGE - 1)) / CLOG_XACTS_PER_PAGE))
+
 /*
  * Possible transaction statuses --- note that all-zeroes is the initial
  * state.
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 7662f8e1a9..d928dcc935 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -16,7 +16,6 @@
 #include "replication/origin.h"
 #include "storage/sync.h"
 
-
 extern PGDLLIMPORT bool track_commit_timestamp;
 
 extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index a5600a320a..da7b8f0abb 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..b7e2e2b55e 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -17,6 +17,11 @@
 #include "storage/lwlock.h"
 #include "storage/sync.h"
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
 
 /*
  * Define SLRU segment size.  A page is the same BLCKSZ as is used everywhere
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index f94e116640..1ddb62883b 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,8 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index ebc9271789..f1591dd2ba 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 02276d3edd..4e36d6bdf5 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -176,6 +176,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int xact_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index ba12904f22..b40c762cf4 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.24.3 (Apple Git-128)

#72Justin Pryzby
pryzby@telsasoft.com
In reply to: Andrey Borodin (#71)
Re: MultiXact/SLRU buffers configuration

On Sat, Jan 15, 2022 at 12:16:59PM +0500, Andrey Borodin wrote:

15 янв. 2022 г., в 03:20, Shawn Debnath <sdn@amazon.com> написал(а):
On Fri, Jan 14, 2022 at 05:28:38PM +0800, Julien Rouhaud wrote:

PFA rebase of the patchset. Also I've added a patch to combine
page_number, page_status, and page_dirty together to touch less
cachelines.

The cfbot reports some errors on the latest version of the patch:

https://cirrus-ci.com/task/6121317215764480
[...]
Could you send a new version? In the meantime I will switch the patch
status to Waiting on Author.

I was planning on running a set of stress tests on these patches. Could
we confirm which ones we plan to include in the commitfest?

Many thanks for your interest. Here's the latest version.

This is failing to compile under linux and windows due to bitfield syntax.
http://cfbot.cputube.org/andrey-borodin.html

And compile warnings:

slru.c: In function ‘SlruAdjustNSlots’:
slru.c:161:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
161 | int nbanks = 1;
| ^~~
slru.c: In function ‘SimpleLruReadPage_ReadOnly’:
slru.c:530:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
530 | int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
| ^~~

Note that you can test the CI result using any github account without waiting
for the cfbot. See ./src/tools/ci/README.

--
Justin

#73Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Justin Pryzby (#72)
3 attachment(s)
Re: MultiXact/SLRU buffers configuration

15 янв. 2022 г., в 20:46, Justin Pryzby <pryzby@telsasoft.com> написал(а):

I was planning on running a set of stress tests on these patches. Could
we confirm which ones we plan to include in the commitfest?

Many thanks for your interest. Here's the latest version.

This is failing to compile under linux and windows due to bitfield syntax.
http://cfbot.cputube.org/andrey-borodin.html

Uh, sorry, I formatted a patch from wrong branch.

Just tested Cirrus. It's wonderful, thanks! Really faster than doing stuff on my machines...

Best regards, Andrey Borodin.

Attachments:

v20-0001-Make-all-SLRU-buffer-sizes-configurable.patchapplication/octet-stream; name=v20-0001-Make-all-SLRU-buffer-sizes-configurable.patch; x-unix-mode=0644Download
From 8fc0196ac13f29daae76deb2df97037bc9f06931 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v20 1/3] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Remove the limits on xact_buffers and commit_ts_buffers.  The default
sizes for those caches are ~0.2% and ~0.1% of shared_buffers, as before,
but now there is no cap at 128 and 16 buffers respectively (unless
track_commit_timestamp is disabled, in the latter case, then we might as
well keep it tiny).  Sizes much larger than the old limits have been
shown to be useful on modern systems, and an earlier commit replaced a
linear search with a hash table to avoid problems with extreme cases.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 135 ++++++++++++++++++
 src/backend/access/transam/clog.c             |  23 ++-
 src/backend/access/transam/commit_ts.c        |   5 +
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  99 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/clog.h                     |  10 ++
 src/include/access/commit_ts.h                |   1 -
 src/include/access/multixact.h                |   4 -
 src/include/access/slru.h                     |   5 +
 src/include/access/subtrans.h                 |   2 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 18 files changed, 299 insertions(+), 43 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index c0fbf03dd3..962465818d 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1952,6 +1952,141 @@ include_dir 'conf.d'
        </para>
       </listitem>
      </varlistentry>
+     
+    <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+    <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-xact-buffers" xreflabel="xact_buffers">
+      <term><varname>xact_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>xact_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+     
+    <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to use to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 1024, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
 
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index de787c3d37..23922abc60 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -58,8 +58,8 @@
 
 /* We need two bits per xact, so four xacts fit in a byte */
 #define CLOG_BITS_PER_XACT	2
-#define CLOG_XACTS_PER_BYTE 4
-#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+StaticAssertDecl((CLOG_BITS_PER_XACT * CLOG_XACTS_PER_BYTE) == BITS_PER_BYTE,
+				 "CLOG_BITS_PER_XACT and CLOG_XACTS_PER_BYTE are inconsistent");
 #define CLOG_XACT_BITMASK	((1 << CLOG_BITS_PER_XACT) - 1)
 
 #define TransactionIdToPage(xid)	((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
@@ -664,23 +664,16 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
+ * By default, we'll use 2MB of for every 1GB of shared buffers, up to the
+ * theoretical maximum useful value, but always at least 4 buffers.
  */
 Size
 CLOGShmemBuffers(void)
 {
-	return Min(128, Max(4, NBuffers / 512));
+	/* Use configured value if provided. */
+	if (xact_buffers > 0)
+		return Max(4, xact_buffers);
+	return Min(CLOG_MAX_ALLOWED_BUFFERS, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 659109f8d4..1247691e79 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -511,10 +511,15 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
  * We use a very similar logic as for the number of CLOG buffers (except we
  * scale up twice as fast with shared buffers, and the maximum is twice as
  * high); see comments in CLOGShmemBuffers.
+ * By default, we'll use 1MB of for every 1GB of shared buffers, up to the
+ * maximum value that slru.c will allow, but always at least 4 buffers.
  */
 Size
 CommitTsShmemBuffers(void)
 {
+	/* Use configured value if provided. */
+	if (commit_ts_buffers > 0)
+		return Max(4, commit_ts_buffers);
 	return Min(256, Max(4, NBuffers / 256));
 }
 
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 806f2e43ba..3c86bd4517 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1834,8 +1834,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1851,13 +1851,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..862b0eab96 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..6b98060330 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -117,7 +117,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -235,7 +235,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -521,7 +521,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -569,7 +569,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 25e7e4e37b..1534d4ea48 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1396,7 +1396,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index c26a1a73df..3c390213b2 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -150,3 +150,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			xact_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index effb9d03a0..7fc4e270b1 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -32,9 +32,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -203,6 +205,8 @@ static const char *show_tcp_keepalives_idle(void);
 static const char *show_tcp_keepalives_interval(void);
 static const char *show_tcp_keepalives_count(void);
 static const char *show_tcp_user_timeout(void);
+static const char *show_xact_buffers(void);
+static const char *show_commit_ts_buffers(void);
 static bool check_maxconnections(int *newval, void **extra, GucSource source);
 static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
 static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
@@ -2376,6 +2380,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact offset SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact member SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the sub-transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the NOTIFY message SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the serializable transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"xact_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the transaction status SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&xact_buffers,
+		0, 0, CLOG_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_xact_buffers
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the size of the dedicated buffer pool used for the commit timestamp SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_commit_ts_buffers
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
@@ -12039,6 +12120,24 @@ show_tcp_user_timeout(void)
 	return nbuf;
 }
 
+static const char *
+show_xact_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CLOGShmemBuffers());
+	return nbuf;
+}
+
+static const char *
+show_commit_ts_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CommitTsShmemBuffers());
+	return nbuf;
+}
+
 static bool
 check_maxconnections(int *newval, void **extra, GucSource source)
 {
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index a1acd46b61..22bda4383c 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -195,6 +195,15 @@
 #old_snapshot_threshold = -1		# 1min-60d; -1 disables; 0 is immediate
 					# (change requires restart)
 
+# - SLRU Buffers (change requires restart) -
+
+#xact_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_notify
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 543f2e2643..17d103aa4d 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -15,6 +15,16 @@
 #include "storage/sync.h"
 #include "lib/stringinfo.h"
 
+/*
+ * Don't allow xact_buffers to be set higher than could possibly be useful or
+ * SLRU would allow.
+ */
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+#define CLOG_MAX_ALLOWED_BUFFERS \
+	Min(SLRU_MAX_ALLOWED_BUFFERS, \
+		(((MaxTransactionId / 2) + (CLOG_XACTS_PER_PAGE - 1)) / CLOG_XACTS_PER_PAGE))
+
 /*
  * Possible transaction statuses --- note that all-zeroes is the initial
  * state.
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 7662f8e1a9..d928dcc935 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -16,7 +16,6 @@
 #include "replication/origin.h"
 #include "storage/sync.h"
 
-
 extern PGDLLIMPORT bool track_commit_timestamp;
 
 extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index a5600a320a..da7b8f0abb 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..b7e2e2b55e 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -17,6 +17,11 @@
 #include "storage/lwlock.h"
 #include "storage/sync.h"
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
 
 /*
  * Define SLRU segment size.  A page is the same BLCKSZ as is used everywhere
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index f94e116640..1ddb62883b 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,8 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index ebc9271789..f1591dd2ba 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 02276d3edd..4e36d6bdf5 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -176,6 +176,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int xact_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index ba12904f22..b40c762cf4 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern int	max_predicate_locks_per_xact;
 extern int	max_predicate_locks_per_relation;
 extern int	max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.24.3 (Apple Git-128)

v20-0002-Divide-SLRU-buffers-into-8-associative-banks.patchapplication/octet-stream; name=v20-0002-Divide-SLRU-buffers-into-8-associative-banks.patch; x-unix-mode=0644Download
From c745ddad76ff9e066c0da2cd6bc57f9b0abc8a1d Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sun, 11 Apr 2021 21:18:10 +0300
Subject: [PATCH v20 2/3] Divide SLRU buffers into 8-associative banks

We want to eliminate linear search within SLRU buffers.
To do so we divide SLRU buffers into banks. Each bank holds
approximately 8 buffers. Each SLRU pageno may reside only in one bank.
Adjacent pagenos reside in different banks.
---
 src/backend/access/transam/slru.c | 43 ++++++++++++++++++++++++++++---
 src/include/access/slru.h         |  2 ++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5d..f34a2e3fdd 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -134,7 +134,7 @@ typedef enum
 static SlruErrorCause slru_errcause;
 static int	slru_errno;
 
-
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset);
 static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
 static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
 static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
@@ -148,6 +148,30 @@ static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
 
+/*
+ * Pick bank size optimal for N-assiciative SLRU buffers.
+ * We expect bank number to be picked from lowest bits of requested pageno.
+ * Thus we want number of banks to be power of 2. This routine computes number
+ * of banks aiming to make each bank of size 8. So we can pack page number and
+ * statuses of each bank on one cacheline.
+ */
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset)
+{
+	*banksize = *nslots;
+	int nbanks = 1;
+	*bankoffset = 0;
+	while (*banksize > 15)
+	{
+		if ((*banksize & 1) != 0)
+			*banksize +=1;
+		*banksize /= 2;
+		nbanks *= 2;
+		*bankoffset += 1;
+	}
+	elog(DEBUG5, "nslots %d banksize %d nbanks %d ", *nslots, *banksize, nbanks);
+	*nslots = *banksize * nbanks;
+}
+
 /*
  * Initialization of shared memory
  */
@@ -156,6 +180,8 @@ Size
 SimpleLruShmemSize(int nslots, int nlsns)
 {
 	Size		sz;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
@@ -190,6 +216,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 {
 	SlruShared	shared;
 	bool		found;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	shared = (SlruShared) ShmemInitStruct(name,
 										  SimpleLruShmemSize(nslots, nlsns),
@@ -209,6 +237,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 		shared->ControlLock = ctllock;
 
 		shared->num_slots = nslots;
+		shared->bank_mask =  (1 << bankoffset) - 1;
+		shared->bank_size = banksize;
+		
 		shared->lsn_groups_per_page = nlsns;
 
 		shared->cur_lru_count = 0;
@@ -501,7 +532,9 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+	int bankend = bankstart + shared->bank_size;
+	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
 		if (shared->page_number[slotno] == pageno &&
 			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
@@ -1030,7 +1063,9 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+		int bankend = bankstart + shared->bank_size;
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			if (shared->page_number[slotno] == pageno &&
 				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
@@ -1065,7 +1100,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		 * multiple pages with the same lru_count.
 		 */
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			int			this_delta;
 			int			this_page_number;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index b7e2e2b55e..cc9cc10d27 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -61,6 +61,8 @@ typedef struct SlruSharedData
 
 	/* Number of buffers managed by this SLRU structure */
 	int			num_slots;
+	int			bank_size;
+	int			bank_mask;
 
 	/*
 	 * Arrays holding info for each buffer slot.  Page number is undefined
-- 
2.24.3 (Apple Git-128)

v20-0003-Pack-SLRU-page_number-page_status-and-page_dirty.patchapplication/octet-stream; name=v20-0003-Pack-SLRU-page_number-page_status-and-page_dirty.patch; x-unix-mode=0644Download
From 7f584b2296512181d86a82aa6ebb7cb6794a9c4a Mon Sep 17 00:00:00 2001
From: Andrey Borodin <x4m@flight.local>
Date: Sun, 26 Dec 2021 15:03:30 +0500
Subject: [PATCH v20 3/3] Pack SLRU page_number, page_status and page_dirty
 toogether

This allows to test only one cacheline during successfull
SlruSelectLRUPage().
---
 src/backend/access/transam/clog.c      |  12 +-
 src/backend/access/transam/commit_ts.c |   6 +-
 src/backend/access/transam/multixact.c |  16 +--
 src/backend/access/transam/slru.c      | 150 ++++++++++++-------------
 src/backend/access/transam/subtrans.c  |   4 +-
 src/backend/commands/async.c           |   2 +-
 src/backend/storage/lmgr/predicate.c   |   2 +-
 src/include/access/slru.h              |  14 ++-
 8 files changed, 104 insertions(+), 102 deletions(-)

diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 23922abc60..afb6c4ea57 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -375,7 +375,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
 		{
 			for (i = 0; i < nsubxids; i++)
 			{
-				Assert(XactCtl->shared->page_number[slotno] == TransactionIdToPage(subxids[i]));
+				Assert(XactCtl->shared->page_entries[slotno].page_number == TransactionIdToPage(subxids[i]));
 				TransactionIdSetStatusBit(subxids[i],
 										  TRANSACTION_STATUS_SUB_COMMITTED,
 										  lsn, slotno);
@@ -389,11 +389,11 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
 	/* Set the subtransactions */
 	for (i = 0; i < nsubxids; i++)
 	{
-		Assert(XactCtl->shared->page_number[slotno] == TransactionIdToPage(subxids[i]));
+		Assert(XactCtl->shared->page_entries[slotno].page_number == TransactionIdToPage(subxids[i]));
 		TransactionIdSetStatusBit(subxids[i], status, lsn, slotno);
 	}
 
-	XactCtl->shared->page_dirty[slotno] = true;
+	XactCtl->shared->page_entries[slotno].page_dirty = true;
 }
 
 /*
@@ -713,7 +713,7 @@ BootStrapCLOG(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(XactCtl, slotno);
-	Assert(!XactCtl->shared->page_dirty[slotno]);
+	Assert(!XactCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(XactSLRULock);
 }
@@ -798,7 +798,7 @@ TrimCLOG(void)
 		/* Zero the rest of the page */
 		MemSet(byteptr + 1, 0, BLCKSZ - byteno - 1);
 
-		XactCtl->shared->page_dirty[slotno] = true;
+		XactCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(XactSLRULock);
@@ -994,7 +994,7 @@ clog_redo(XLogReaderState *record)
 
 		slotno = ZeroCLOGPage(pageno, false);
 		SimpleLruWritePage(XactCtl, slotno);
-		Assert(!XactCtl->shared->page_dirty[slotno]);
+		Assert(!XactCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(XactSLRULock);
 	}
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 1247691e79..72bd116eef 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -227,7 +227,7 @@ SetXidCommitTsInPage(TransactionId xid, int nsubxids,
 	for (i = 0; i < nsubxids; i++)
 		TransactionIdSetCommitTs(subxids[i], ts, nodeid, slotno);
 
-	CommitTsCtl->shared->page_dirty[slotno] = true;
+	CommitTsCtl->shared->page_entries[slotno].page_dirty = true;
 
 	LWLockRelease(CommitTsSLRULock);
 }
@@ -735,7 +735,7 @@ ActivateCommitTs(void)
 		LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
 		slotno = ZeroCommitTsPage(pageno, false);
 		SimpleLruWritePage(CommitTsCtl, slotno);
-		Assert(!CommitTsCtl->shared->page_dirty[slotno]);
+		Assert(!CommitTsCtl->shared->page_entries[slotno].page_dirty);
 		LWLockRelease(CommitTsSLRULock);
 	}
 
@@ -1005,7 +1005,7 @@ commit_ts_redo(XLogReaderState *record)
 
 		slotno = ZeroCommitTsPage(pageno, false);
 		SimpleLruWritePage(CommitTsCtl, slotno);
-		Assert(!CommitTsCtl->shared->page_dirty[slotno]);
+		Assert(!CommitTsCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(CommitTsSLRULock);
 	}
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 3c86bd4517..276584d45e 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -887,7 +887,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 
 	*offptr = offset;
 
-	MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
+	MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty = true;
 
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
@@ -931,7 +931,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 		flagsval |= (members[i].status << bshift);
 		*flagsptr = flagsval;
 
-		MultiXactMemberCtl->shared->page_dirty[slotno] = true;
+		MultiXactMemberCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(MultiXactMemberSLRULock);
@@ -1902,7 +1902,7 @@ BootStrapMultiXact(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(MultiXactOffsetCtl, slotno);
-	Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
+	Assert(!MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(MultiXactOffsetSLRULock);
 
@@ -1913,7 +1913,7 @@ BootStrapMultiXact(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(MultiXactMemberCtl, slotno);
-	Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
+	Assert(!MultiXactMemberCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(MultiXactMemberSLRULock);
 }
@@ -2074,7 +2074,7 @@ TrimMultiXact(void)
 
 		MemSet(offptr, 0, BLCKSZ - (entryno * sizeof(MultiXactOffset)));
 
-		MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
+		MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(MultiXactOffsetSLRULock);
@@ -2112,7 +2112,7 @@ TrimMultiXact(void)
 		 * writing.
 		 */
 
-		MultiXactMemberCtl->shared->page_dirty[slotno] = true;
+		MultiXactMemberCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(MultiXactMemberSLRULock);
@@ -3251,7 +3251,7 @@ multixact_redo(XLogReaderState *record)
 
 		slotno = ZeroMultiXactOffsetPage(pageno, false);
 		SimpleLruWritePage(MultiXactOffsetCtl, slotno);
-		Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
+		Assert(!MultiXactOffsetCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(MultiXactOffsetSLRULock);
 	}
@@ -3266,7 +3266,7 @@ multixact_redo(XLogReaderState *record)
 
 		slotno = ZeroMultiXactMemberPage(pageno, false);
 		SimpleLruWritePage(MultiXactMemberCtl, slotno);
-		Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
+		Assert(!MultiXactMemberCtl->shared->page_entries[slotno].page_dirty);
 
 		LWLockRelease(MultiXactMemberSLRULock);
 	}
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index f34a2e3fdd..6a43381f81 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -157,8 +157,8 @@ static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
  */
 static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset)
 {
-	*banksize = *nslots;
 	int nbanks = 1;
+	*banksize = *nslots;
 	*bankoffset = 0;
 	while (*banksize > 15)
 	{
@@ -181,14 +181,13 @@ SimpleLruShmemSize(int nslots, int nlsns)
 {
 	Size		sz;
 	int bankoffset, banksize;
+	Assert(sizeof(SlruPageEntry)%8 == 0);
 	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
 	sz += MAXALIGN(nslots * sizeof(char *));	/* page_buffer[] */
-	sz += MAXALIGN(nslots * sizeof(SlruPageStatus));	/* page_status[] */
-	sz += MAXALIGN(nslots * sizeof(bool));	/* page_dirty[] */
-	sz += MAXALIGN(nslots * sizeof(int));	/* page_number[] */
+	sz += MAXALIGN(nslots * sizeof(SlruPageEntry));	/* page_entries[] */
 	sz += MAXALIGN(nslots * sizeof(int));	/* page_lru_count[] */
 	sz += MAXALIGN(nslots * sizeof(LWLockPadded));	/* buffer_locks[] */
 
@@ -248,16 +247,13 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 
 		shared->slru_stats_idx = pgstat_slru_index(name);
 
+		Assert(sizeof(SlruPageEntry) == 8);
 		ptr = (char *) shared;
 		offset = MAXALIGN(sizeof(SlruSharedData));
 		shared->page_buffer = (char **) (ptr + offset);
 		offset += MAXALIGN(nslots * sizeof(char *));
-		shared->page_status = (SlruPageStatus *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
-		shared->page_dirty = (bool *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(bool));
-		shared->page_number = (int *) (ptr + offset);
-		offset += MAXALIGN(nslots * sizeof(int));
+		shared->page_entries = (SlruPageEntry *) (ptr + offset);
+		offset += MAXALIGN(nslots * sizeof(SlruPageEntry));
 		shared->page_lru_count = (int *) (ptr + offset);
 		offset += MAXALIGN(nslots * sizeof(int));
 
@@ -278,8 +274,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 							 tranche_id);
 
 			shared->page_buffer[slotno] = ptr;
-			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
-			shared->page_dirty[slotno] = false;
+			shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
+			shared->page_entries[slotno].page_dirty = false;
 			shared->page_lru_count[slotno] = 0;
 			ptr += BLCKSZ;
 		}
@@ -315,15 +311,15 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 
 	/* Find a suitable buffer slot for the page */
 	slotno = SlruSelectLRUPage(ctl, pageno);
-	Assert(shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
-		   (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-			!shared->page_dirty[slotno]) ||
-		   shared->page_number[slotno] == pageno);
+	Assert(shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY ||
+		   (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+			!shared->page_entries[slotno].page_dirty) ||
+		   shared->page_entries[slotno].page_number == pageno);
 
 	/* Mark the slot as containing this page */
-	shared->page_number[slotno] = pageno;
-	shared->page_status[slotno] = SLRU_PAGE_VALID;
-	shared->page_dirty[slotno] = true;
+	shared->page_entries[slotno].page_number = pageno;
+	shared->page_entries[slotno].page_status = SLRU_PAGE_VALID;
+	shared->page_entries[slotno].page_dirty = true;
 	SlruRecentlyUsed(shared, slotno);
 
 	/* Set the buffer to zeroes */
@@ -387,18 +383,18 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
 	 * cheaply test for failure by seeing if the buffer lock is still held (we
 	 * assume that transaction abort would release the lock).
 	 */
-	if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS ||
-		shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS)
+	if (shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS ||
+		shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS)
 	{
 		if (LWLockConditionalAcquire(&shared->buffer_locks[slotno].lock, LW_SHARED))
 		{
 			/* indeed, the I/O must have failed */
-			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
-				shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS)
+				shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
 			else				/* write_in_progress */
 			{
-				shared->page_status[slotno] = SLRU_PAGE_VALID;
-				shared->page_dirty[slotno] = true;
+				shared->page_entries[slotno].page_status = SLRU_PAGE_VALID;
+				shared->page_entries[slotno].page_dirty = true;
 			}
 			LWLockRelease(&shared->buffer_locks[slotno].lock);
 		}
@@ -438,15 +434,15 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 		slotno = SlruSelectLRUPage(ctl, pageno);
 
 		/* Did we find the page in memory? */
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+		if (shared->page_entries[slotno].page_number == pageno &&
+			shared->page_entries[slotno].page_status != SLRU_PAGE_EMPTY)
 		{
 			/*
 			 * If page is still being read in, we must wait for I/O.  Likewise
 			 * if the page is being written and the caller said that's not OK.
 			 */
-			if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS ||
-				(shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS &&
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS ||
+				(shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS &&
 				 !write_ok))
 			{
 				SimpleLruWaitIO(ctl, slotno);
@@ -463,14 +459,14 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 		}
 
 		/* We found no match; assert we selected a freeable slot */
-		Assert(shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
-			   (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-				!shared->page_dirty[slotno]));
+		Assert(shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY ||
+			   (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+				!shared->page_entries[slotno].page_dirty));
 
 		/* Mark the slot read-busy */
-		shared->page_number[slotno] = pageno;
-		shared->page_status[slotno] = SLRU_PAGE_READ_IN_PROGRESS;
-		shared->page_dirty[slotno] = false;
+		shared->page_entries[slotno].page_number = pageno;
+		shared->page_entries[slotno].page_status = SLRU_PAGE_READ_IN_PROGRESS;
+		shared->page_entries[slotno].page_dirty = false;
 
 		/* Acquire per-buffer lock (cannot deadlock, see notes at top) */
 		LWLockAcquire(&shared->buffer_locks[slotno].lock, LW_EXCLUSIVE);
@@ -487,11 +483,11 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
 		/* Re-acquire control lock and update page state */
 		LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
 
-		Assert(shared->page_number[slotno] == pageno &&
-			   shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS &&
-			   !shared->page_dirty[slotno]);
+		Assert(shared->page_entries[slotno].page_number == pageno &&
+			   shared->page_entries[slotno].page_status == SLRU_PAGE_READ_IN_PROGRESS &&
+			   !shared->page_entries[slotno].page_dirty);
 
-		shared->page_status[slotno] = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
+		shared->page_entries[slotno].page_status = ok ? SLRU_PAGE_VALID : SLRU_PAGE_EMPTY;
 
 		LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -527,18 +523,18 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
+	int			bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+	int			bankend = bankstart + shared->bank_size;
 
 	/* Try to find the page while holding only shared lock */
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
-	int bankend = bankstart + shared->bank_size;
 	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
-		if (shared->page_number[slotno] == pageno &&
-			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
-			shared->page_status[slotno] != SLRU_PAGE_READ_IN_PROGRESS)
+		if (shared->page_entries[slotno].page_number == pageno &&
+			shared->page_entries[slotno].page_status != SLRU_PAGE_EMPTY &&
+			shared->page_entries[slotno].page_status != SLRU_PAGE_READ_IN_PROGRESS)
 		{
 			/* See comments for SlruRecentlyUsed macro */
 			SlruRecentlyUsed(shared, slotno);
@@ -572,12 +568,12 @@ static void
 SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
 {
 	SlruShared	shared = ctl->shared;
-	int			pageno = shared->page_number[slotno];
+	int			pageno = shared->page_entries[slotno].page_number;
 	bool		ok;
 
 	/* If a write is in progress, wait for it to finish */
-	while (shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS &&
-		   shared->page_number[slotno] == pageno)
+	while (shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS &&
+		   shared->page_entries[slotno].page_number == pageno)
 	{
 		SimpleLruWaitIO(ctl, slotno);
 	}
@@ -586,17 +582,17 @@ SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
 	 * Do nothing if page is not dirty, or if buffer no longer contains the
 	 * same page we were called for.
 	 */
-	if (!shared->page_dirty[slotno] ||
-		shared->page_status[slotno] != SLRU_PAGE_VALID ||
-		shared->page_number[slotno] != pageno)
+	if (!shared->page_entries[slotno].page_dirty ||
+		shared->page_entries[slotno].page_status != SLRU_PAGE_VALID ||
+		shared->page_entries[slotno].page_number != pageno)
 		return;
 
 	/*
 	 * Mark the slot write-busy, and clear the dirtybit.  After this point, a
 	 * transaction status update on this page will mark it dirty again.
 	 */
-	shared->page_status[slotno] = SLRU_PAGE_WRITE_IN_PROGRESS;
-	shared->page_dirty[slotno] = false;
+	shared->page_entries[slotno].page_status = SLRU_PAGE_WRITE_IN_PROGRESS;
+	shared->page_entries[slotno].page_dirty = false;
 
 	/* Acquire per-buffer lock (cannot deadlock, see notes at top) */
 	LWLockAcquire(&shared->buffer_locks[slotno].lock, LW_EXCLUSIVE);
@@ -619,14 +615,14 @@ SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
 	/* Re-acquire control lock and update page state */
 	LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
 
-	Assert(shared->page_number[slotno] == pageno &&
-		   shared->page_status[slotno] == SLRU_PAGE_WRITE_IN_PROGRESS);
+	Assert(shared->page_entries[slotno].page_number == pageno &&
+		   shared->page_entries[slotno].page_status == SLRU_PAGE_WRITE_IN_PROGRESS);
 
 	/* If we failed to write, mark the page dirty again */
 	if (!ok)
-		shared->page_dirty[slotno] = true;
+		shared->page_entries[slotno].page_dirty = true;
 
-	shared->page_status[slotno] = SLRU_PAGE_VALID;
+	shared->page_entries[slotno].page_status = SLRU_PAGE_VALID;
 
 	LWLockRelease(&shared->buffer_locks[slotno].lock);
 
@@ -1067,8 +1063,8 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int bankend = bankstart + shared->bank_size;
 		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
-			if (shared->page_number[slotno] == pageno &&
-				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
+			if (shared->page_entries[slotno].page_number == pageno &&
+				shared->page_entries[slotno].page_status != SLRU_PAGE_EMPTY)
 				return slotno;
 		}
 
@@ -1105,7 +1101,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 			int			this_delta;
 			int			this_page_number;
 
-			if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY)
 				return slotno;
 			this_delta = cur_count - shared->page_lru_count[slotno];
 			if (this_delta < 0)
@@ -1120,10 +1116,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 				shared->page_lru_count[slotno] = cur_count;
 				this_delta = 0;
 			}
-			this_page_number = shared->page_number[slotno];
+			this_page_number = shared->page_entries[slotno].page_number;
 			if (this_page_number == shared->latest_page_number)
 				continue;
-			if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+			if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID)
 			{
 				if (this_delta > best_valid_delta ||
 					(this_delta == best_valid_delta &&
@@ -1165,7 +1161,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		/*
 		 * If the selected page is clean, we're set.
 		 */
-		if (!shared->page_dirty[bestvalidslot])
+		if (!shared->page_entries[bestvalidslot].page_dirty)
 			return bestvalidslot;
 
 		/*
@@ -1217,9 +1213,9 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
 		 * already.  That's okay.
 		 */
 		Assert(allow_redirtied ||
-			   shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
-			   (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-				!shared->page_dirty[slotno]));
+			   shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY ||
+			   (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+				!shared->page_entries[slotno].page_dirty));
 	}
 
 	LWLockRelease(shared->ControlLock);
@@ -1291,18 +1287,18 @@ restart:;
 
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
 	{
-		if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY)
 			continue;
-		if (!ctl->PagePrecedes(shared->page_number[slotno], cutoffPage))
+		if (!ctl->PagePrecedes(shared->page_entries[slotno].page_number, cutoffPage))
 			continue;
 
 		/*
 		 * If page is clean, just change state to EMPTY (expected case).
 		 */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-			!shared->page_dirty[slotno])
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+			!shared->page_entries[slotno].page_dirty)
 		{
-			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
 			continue;
 		}
 
@@ -1316,7 +1312,7 @@ restart:;
 		 * won't have cause to read its data again.  For now, keep the logic
 		 * the same as it was.)
 		 */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID)
 			SlruInternalWritePage(ctl, slotno, NULL);
 		else
 			SimpleLruWaitIO(ctl, slotno);
@@ -1371,9 +1367,9 @@ restart:
 	did_write = false;
 	for (slotno = 0; slotno < shared->num_slots; slotno++)
 	{
-		int			pagesegno = shared->page_number[slotno] / SLRU_PAGES_PER_SEGMENT;
+		int			pagesegno = shared->page_entries[slotno].page_number / SLRU_PAGES_PER_SEGMENT;
 
-		if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_EMPTY)
 			continue;
 
 		/* not the segment we're looking for */
@@ -1381,15 +1377,15 @@ restart:
 			continue;
 
 		/* If page is clean, just change state to EMPTY (expected case). */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID &&
-			!shared->page_dirty[slotno])
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID &&
+			!shared->page_entries[slotno].page_dirty)
 		{
-			shared->page_status[slotno] = SLRU_PAGE_EMPTY;
+			shared->page_entries[slotno].page_status = SLRU_PAGE_EMPTY;
 			continue;
 		}
 
 		/* Same logic as SimpleLruTruncate() */
-		if (shared->page_status[slotno] == SLRU_PAGE_VALID)
+		if (shared->page_entries[slotno].page_status == SLRU_PAGE_VALID)
 			SlruInternalWritePage(ctl, slotno, NULL);
 		else
 			SimpleLruWaitIO(ctl, slotno);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 862b0eab96..4cf34ef733 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -97,7 +97,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
 	{
 		Assert(*ptr == InvalidTransactionId);
 		*ptr = parent;
-		SubTransCtl->shared->page_dirty[slotno] = true;
+		SubTransCtl->shared->page_entries[slotno].page_dirty = true;
 	}
 
 	LWLockRelease(SubtransSLRULock);
@@ -220,7 +220,7 @@ BootStrapSUBTRANS(void)
 
 	/* Make sure it's written out */
 	SimpleLruWritePage(SubTransCtl, slotno);
-	Assert(!SubTransCtl->shared->page_dirty[slotno]);
+	Assert(!SubTransCtl->shared->page_entries[slotno].page_dirty);
 
 	LWLockRelease(SubtransSLRULock);
 }
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 6b98060330..2d220e4819 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -1445,7 +1445,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
 								   InvalidTransactionId);
 
 	/* Note we mark the page dirty before writing in it */
-	NotifyCtl->shared->page_dirty[slotno] = true;
+	NotifyCtl->shared->page_entries[slotno].page_dirty = true;
 
 	while (nextNotify != NULL)
 	{
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 1534d4ea48..957cbe82f7 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -963,7 +963,7 @@ SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
 		slotno = SimpleLruReadPage(SerialSlruCtl, targetPage, true, xid);
 
 	SerialValue(slotno, xid) = minConflictCommitSeqNo;
-	SerialSlruCtl->shared->page_dirty[slotno] = true;
+	SerialSlruCtl->shared->page_entries[slotno].page_dirty = true;
 
 	LWLockRelease(SerialSLRULock);
 }
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index cc9cc10d27..4a1fe1a1ae 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -44,7 +44,7 @@
  * in the latter case it implies that the page has been re-dirtied since
  * the write started.
  */
-typedef enum
+typedef enum SlruPageStatus
 {
 	SLRU_PAGE_EMPTY,			/* buffer is not in use */
 	SLRU_PAGE_READ_IN_PROGRESS, /* page is being read in */
@@ -52,6 +52,14 @@ typedef enum
 	SLRU_PAGE_WRITE_IN_PROGRESS /* page is being written out */
 } SlruPageStatus;
 
+typedef struct SlruPageEntry
+{
+	int32	page_number;
+	char	page_status;
+	bool	page_dirty;
+	uint16	padding;
+} SlruPageEntry;
+
 /*
  * Shared-memory state
  */
@@ -69,9 +77,7 @@ typedef struct SlruSharedData
 	 * when status is EMPTY, as is page_lru_count.
 	 */
 	char	  **page_buffer;
-	SlruPageStatus *page_status;
-	bool	   *page_dirty;
-	int		   *page_number;
+	SlruPageEntry *page_entries;
 	int		   *page_lru_count;
 	LWLockPadded *buffer_locks;
 
-- 
2.24.3 (Apple Git-128)

#74Shawn Debnath
sdn@amazon.com
In reply to: Andrey Borodin (#71)
Re: MultiXact\SLRU buffers configuration

On Sat, Jan 15, 2022 at 12:16:59PM +0500, Andrey Borodin wrote:

I was planning on running a set of stress tests on these patches. Could
we confirm which ones we plan to include in the commitfest?

Many thanks for your interest. Here's the latest version.

Here are the results of the multixact perf test I ran on the patch that splits
the linear SLRU caches into banks. With my test setup, the binaries
with the patch applied performed slower marginally across the test
matrix against unpatched binaries. Here are the results:

+-------------------------------+---------------------+-----------------------+------------+
|           workload            | patched average tps | unpatched average tps | difference |
+-------------------------------+---------------------+-----------------------+------------+
| create only                   |         10250.54396 |           10349.67487 | -1.0%      |
| create and select             |         9677.711286 |           9991.065037 | -3.2%      |
| large cache create only       |         10310.96646 |           10337.16455 | -0.3%      |
| large cache create and select |          9654.24077 |           9924.270242 | -2.8%      |
+-------------------------------+---------------------+-----------------------+------------+

The test was configured in the following manner:
- AWS EC2 c5d.24xlarge instances, located in the same AZ, were used as
the database host and the test driver. These systems have 96 vcpus and
184 GB memory. NVMe drives were configured as RAID5.
- GUCs were changed from defaults to be the following:
max_connections = 5000
shared_buffers = 96GB
max_wal_size = 2GB
min_wal_size = 192MB
- pgbench runs were done with -c 1000 -j 1000 and a scale of 10,000
- Two multixact workloads were tested, first [0]https://gist.github.com/sdebnath/e015561811adf721dd40dd6638969c69 was a create only
script which selected 100 pgbench_account rows for share. Second
workload [1]https://gist.github.com/sdebnath/2f3802e1fe288594b6661a7a59a7ca07 added a select statement to visit rows touched in the
past which had multixacts generated for them. pgbench test script [2]https://gist.github.com/sdebnath/6bbfd5f87945a7d819e30a9a1701bc97
wraps the call to the functions inside an explicit transaction.
- Large cache tests are multixact offsets cache size hard coded to 128
and members cache size hard coded to 256.
- Row selection is based on time based approach that lets all client
connections coordinate which rows to work with based on the
millisecond they start executing. To allow for more multixacts to be
generated and reduce contention, the workload uses offsets ahead of
the start id based on a random number.
- The one bummer about these runs were that they only ran for 600
seconds for insert only and 400 seconds for insert and select. I
consistently ran into checkpointer getting oom-killed on this instance
after that timeframe. Will dig into this separately. But the TPS was
consistent.
- Each test was repeated at least 3 times and the average of those runs
were used.
- I am using the master branch and changes were applied on commit
f47ed79cc8a0cfa154dc7f01faaf59822552363f

I think patch 1 is a must-have. Regarding patch 2, I would propose we
avoid introducing more complexity into SimpleLRU cache and instead focus
on making the SLRU to buffer cache effort [3]/messages/by-id/CA+hUKGKAYze99B-jk9NoMp-2BDqAgiRC4oJv+bFxghNgdieq8Q@mail.gmail.com a reality. I would also
add that we have a few customers in our fleet who have been successfully
running the large cache configuration on the regular SLRU without any
issues. With cache sizes this small, the linear searches are still quite
efficient.

If my test workload can be made better, please let me know. Happy to
re-run tests as needed.

[0]: https://gist.github.com/sdebnath/e015561811adf721dd40dd6638969c69
[1]: https://gist.github.com/sdebnath/2f3802e1fe288594b6661a7a59a7ca07
[2]: https://gist.github.com/sdebnath/6bbfd5f87945a7d819e30a9a1701bc97
[3]: /messages/by-id/CA+hUKGKAYze99B-jk9NoMp-2BDqAgiRC4oJv+bFxghNgdieq8Q@mail.gmail.com

--
Shawn Debnath
Amazon Web Services (AWS)

#75Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Shawn Debnath (#74)
Re: MultiXact\SLRU buffers configuration

20 янв. 2022 г., в 20:44, Shawn Debnath <sdn@amazon.com> написал(а):

If my test workload can be made better, please let me know. Happy to
re-run tests as needed.

Shawn, thanks for the benchmarking!

Can you please also test 2nd patch against a large multixact SLRUs?
2nd patch is not intended to do make thing better on default buffer sizes. It must save the perfromance in case of really huge SLRU buffers.

Thanks!

Best regards, Andrey Borodin.

#76Shawn Debnath
sdn@amazon.com
In reply to: Andrey Borodin (#75)
Re: MultiXact\SLRU buffers configuration

On Thu, Jan 20, 2022 at 09:21:24PM +0500, Andrey Borodin wrote:

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.

20 янв. 2022 г., в 20:44, Shawn Debnath <sdn@amazon.com> написал(а):

Can you please also test 2nd patch against a large multixact SLRUs?
2nd patch is not intended to do make thing better on default buffer sizes. It must save the perfromance in case of really huge SLRU buffers.

Test was performed on 128/256 for multixact offset/members cache as
stated in my previous email. Sure I can test it for higher values - but
what's a real world value that would make sense? We have been using this
configuration successfully for a few of our customers that ran into
MultiXact contention.

--
Shawn Debnath
Amazon Web Services (AWS)

#77Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Shawn Debnath (#76)
Re: MultiXact\SLRU buffers configuration

21 янв. 2022 г., в 05:19, Shawn Debnath <sdn@amazon.com> написал(а):

On Thu, Jan 20, 2022 at 09:21:24PM +0500, Andrey Borodin wrote:

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.

20 янв. 2022 г., в 20:44, Shawn Debnath <sdn@amazon.com> написал(а):

Can you please also test 2nd patch against a large multixact SLRUs?
2nd patch is not intended to do make thing better on default buffer sizes. It must save the perfromance in case of really huge SLRU buffers.

Test was performed on 128/256 for multixact offset/members cache as
stated in my previous email. Sure I can test it for higher values - but
what's a real world value that would make sense? We have been using this
configuration successfully for a few of our customers that ran into
MultiXact contention.

Sorry, seems like I misinterpreted results yesterday.
I had one concern about 1st patch step: it makes CLOG buffers size dependent on shared_buffers. But in your tests you seem to have already exercised xact_buffers = 24576 without noticeable degradation. Is it correct? I doubt a little bit that linear search among 24K elements on each CLOG access does not incur performance impact, but your tests seem to prove it.

IMV splitting SLRU buffer into banks would make sense for values greater than 1<<10. But you are right that 256 seems enough to cope with most of problems of multixacts so far. I just thought about stressing SLRU buffers with multixacts to be sure that CLOG buffers will not suffer degradation. But yes, it's too indirect test.

Maybe, just to be sure, let's repeat tests with autovacuum turned off to stress xact_buffers?

Thanks!

Best regards, Andrey Borodin.

#78Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thomas Munro (#65)
Re: MultiXact\SLRU buffers configuration

8 апр. 2021 г., в 17:22, Thomas Munro <thomas.munro@gmail.com> написал(а):

Thanks! I chickened out of committing a buffer replacement algorithm
patch written 11 hours before the feature freeze, but I also didn't
really want to commit the GUC patch without that. Ahh, if only we'd
latched onto the real problems here just a little sooner, but there is
always PostgreSQL 15, I heard it's going to be amazing. Moved to next
CF.

Hi Thomas!

There's feature freeze approaching again. I see that you are working on moving SLRUs to buffer pools, but it is not clear to which PG version it will land. And there is 100% consensus that first patch is useful and helps to prevent big issues. Maybe let's commit 1'st step without lifting default xact_buffers limit? Or 1st patch as-is with any simple technique that prevents linear search in SLRU buffers.

Best regards, Andrey Borodin.

#79Thomas Munro
thomas.munro@gmail.com
In reply to: Andrey Borodin (#78)
Re: MultiXact\SLRU buffers configuration

On Sat, Feb 19, 2022 at 6:34 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

There's feature freeze approaching again. I see that you are working on moving SLRUs to buffer pools, but it is not clear to which PG version it will land. And there is 100% consensus that first patch is useful and helps to prevent big issues. Maybe let's commit 1'st step without lifting default xact_buffers limit? Or 1st patch as-is with any simple technique that prevents linear search in SLRU buffers.

Hi Andrey,

Yeah, the SLRU/buffer pool thing would be complete enough to propose
for 16 at the earliest. I posted the early prototype to see what sort
of reaction the concept would get before doing more work; I know
others have investigated this topic too... maybe it can encourage more
patches, experimental results, ideas to be shared... but this is not
relevant for 15.

Back to this patch: assuming we can settle on a good-enough-for-now
replacement algorithm, do we want to add this set of 7 GUCs? Does
anyone else want to weigh in on that? Concretely, this patch adds:

multixact_offsets_buffers
multixact_members_buffers
subtrans_buffers
notify_buffers
serial_buffers
xact_buffers
commit_ts_buffers

I guess the people at
https://ottertune.com/blog/postgresql-knobs-list/ would be happy if we
did. Hopefully we'd drop the settings in a future release once we
figure out the main buffer pool thing (or some other scheme to
automate sizing).

#80Andres Freund
andres@anarazel.de
In reply to: Thomas Munro (#79)
Re: MultiXact\SLRU buffers configuration

On 2022-02-20 10:38:53 +1300, Thomas Munro wrote:

Back to this patch: assuming we can settle on a good-enough-for-now
replacement algorithm, do we want to add this set of 7 GUCs? Does
anyone else want to weigh in on that?

I'm -0.2 on it, given that we have a better path forward.

#81Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Andres Freund (#80)
Re: MultiXact\SLRU buffers configuration

On 20 Feb 2022, at 02:42, Andres Freund <andres@anarazel.de> wrote:

On 2022-02-20 10:38:53 +1300, Thomas Munro wrote:

Back to this patch: assuming we can settle on a good-enough-for-now
replacement algorithm, do we want to add this set of 7 GUCs? Does
anyone else want to weigh in on that?

I'm -0.2 on it, given that we have a better path forward.

That’s a really good path forward, but it's discussed at least for 3.5 years[0]/messages/by-id/20180814213500.GA74618@60f81dc409fc.ant.amazon.com. And guaranteed not to be there until 2023. Gilles, Shawn, Dmitry expressed their opinion in lines with that the patch “is a must-have” referring to real pathological performance degradation inflicted by SLRU cache starvation. And I can remember dozen of other incidents that would not happen if the patch was applied, e.g. this post is referring to the patch as a cure [1]https://about.gitlab.com/blog/2021/09/29/why-we-spent-the-last-month-eliminating-postgresql-subtransactions/#what-can-we-do-about-getting-rid-of-nessie.

Best regards, Andrey Borodin.

[0]: /messages/by-id/20180814213500.GA74618@60f81dc409fc.ant.amazon.com
[1]: https://about.gitlab.com/blog/2021/09/29/why-we-spent-the-last-month-eliminating-postgresql-subtransactions/#what-can-we-do-about-getting-rid-of-nessie

#82Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thomas Munro (#79)
Re: MultiXact\SLRU buffers configuration

On 20 Feb 2022, at 02:38, Thomas Munro <thomas.munro@gmail.com> wrote:

Back to this patch: assuming we can settle on a good-enough-for-now
replacement algorithm, do we want to add this set of 7 GUCs? Does
anyone else want to weigh in on that?

Hi Thomas!

It seems we don't have any other input besides reviews and Andres's -0.2.
Is there a chance to proceed?

Best regards, Andrey Borodin.

#83Yura Sokolov
y.sokolov@postgrespro.ru
In reply to: Andrey Borodin (#81)
5 attachment(s)
Re: MultiXact\SLRU buffers configuration

Good day, all.

I did benchmark of patch on 2 socket Xeon 5220 CPU @ 2.20GHz .
I used "benchmark" used to reproduce problems with SLRU on our
customers setup.
In opposite to Shawn's tests I concentrated on bad case: a lot
of contention.

slru-funcs.sql - function definitions
- functions creates a lot of subtrunsactions to stress subtrans
- and select random rows for share to stress multixacts

slru-call.sql - function call for benchmark

slru-ballast.sql - randomly select 1000 consequent rows
"for update skip locked" to stress multixacts

patch1 - make SLRU buffers configurable
patch2 - make "8-associative banks"

Benchmark done by pgbench.
Inited with scale 1 to induce contention.
pgbench -i -s 1 testdb

Benchmark 1:
- low number of connections (50), 60% slru-call, 40% slru-ballast
pgbench -f slru-call.sql@60 -f slru-ballast.sql@40 -c 50 -j 75 -P 1 -T 30 testdb

version | subtrans | multixact | tps
| buffers | offs/memb | func+ballast
--------+----------+-----------+------
master | 32 | 8/16 | 184+119
patch1 | 32 | 8/16 | 184+119
patch1 | 1024 | 8/16 | 121+77
patch1 | 1024 | 512/1024 | 118+75
patch2 | 32 | 8/16 | 190+122
patch2 | 1024 | 8/16 | 190+125
patch2 | 1024 | 512/1024 | 190+127

As you see, this test case degrades with dumb increase of
SLRU buffers. But use of "hash table" in form of "associative
buckets" makes performance stable.

Benchmark 2:
- high connection number (600), 98% slru-call, 2% slru-ballast
pgbench -f slru-call.sql@98 -f slru-ballast.sql@2 -c 600 -j 75 -P 1 -T 30 testdb

I don't paste "ballast" tps here since 2% make them too small,
and they're very noisy.

version | subtrans | multixact | tps
| buffers | offs/memb | func
--------+----------+-----------+------
master | 32 | 8/16 | 13
patch1 | 32
| 8/16 | 13
patch1 | 1024 | 8/16 | 31
patch1 | 1024 | 512/1024 | 53
patch2 | 32 | 8/16 | 12
patch2 | 1024 | 8/16 | 34
patch2 | 1024 | 512/1024 | 67

In this case simple buffer increase does help. But "buckets"
increase performance gain.

I didn't paste here results third part of patch ("Pack SLRU...")
because I didn't see any major performance gain from it, and
it consumes large part of patch diff.

Rebased versions of first two patch parts are attached.

regards,

Yura Sokolov

Attachments:

slru-ballast.sqlapplication/sql; name=slru-ballast.sqlDownload
slru-call.sqlapplication/sql; name=slru-call.sqlDownload
slru-func.sqlapplication/sql; name=slru-func.sqlDownload
v21-0002-Divide-SLRU-buffers-into-8-associative-banks.patchtext/x-patch; charset=UTF-8; name=v21-0002-Divide-SLRU-buffers-into-8-associative-banks.patchDownload
From 41ec9d1c54184c515d53ecc8021c4a998813f2a9 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Sun, 11 Apr 2021 21:18:10 +0300
Subject: [PATCH v21 2/2] Divide SLRU buffers into 8-associative banks

We want to eliminate linear search within SLRU buffers.
To do so we divide SLRU buffers into banks. Each bank holds
approximately 8 buffers. Each SLRU pageno may reside only in one bank.
Adjacent pagenos reside in different banks.
---
 src/backend/access/transam/slru.c | 43 ++++++++++++++++++++++++++++---
 src/include/access/slru.h         |  2 ++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7ff..abc534bbd06 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -134,7 +134,7 @@ typedef enum
 static SlruErrorCause slru_errcause;
 static int	slru_errno;
 
-
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset);
 static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
 static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
 static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
@@ -148,6 +148,30 @@ static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
 
+/*
+ * Pick bank size optimal for N-assiciative SLRU buffers.
+ * We expect bank number to be picked from lowest bits of requested pageno.
+ * Thus we want number of banks to be power of 2. This routine computes number
+ * of banks aiming to make each bank of size 8. So we can pack page number and
+ * statuses of each bank on one cacheline.
+ */
+static void SlruAdjustNSlots(int* nslots, int* banksize, int* bankoffset)
+{
+	int nbanks = 1;
+	*banksize = *nslots;
+	*bankoffset = 0;
+	while (*banksize > 15)
+	{
+		if ((*banksize & 1) != 0)
+			*banksize +=1;
+		*banksize /= 2;
+		nbanks *= 2;
+		*bankoffset += 1;
+	}
+	elog(DEBUG5, "nslots %d banksize %d nbanks %d ", *nslots, *banksize, nbanks);
+	*nslots = *banksize * nbanks;
+}
+
 /*
  * Initialization of shared memory
  */
@@ -156,6 +180,8 @@ Size
 SimpleLruShmemSize(int nslots, int nlsns)
 {
 	Size		sz;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
@@ -190,6 +216,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 {
 	SlruShared	shared;
 	bool		found;
+	int bankoffset, banksize;
+	SlruAdjustNSlots(&nslots, &banksize, &bankoffset);
 
 	shared = (SlruShared) ShmemInitStruct(name,
 										  SimpleLruShmemSize(nslots, nlsns),
@@ -209,6 +237,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 		shared->ControlLock = ctllock;
 
 		shared->num_slots = nslots;
+		shared->bank_mask =  (1 << bankoffset) - 1;
+		shared->bank_size = banksize;
+		
 		shared->lsn_groups_per_page = nlsns;
 
 		shared->cur_lru_count = 0;
@@ -496,12 +527,14 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
+	int			bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+	int			bankend = bankstart + shared->bank_size;
 
 	/* Try to find the page while holding only shared lock */
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
 		if (shared->page_number[slotno] == pageno &&
 			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
@@ -1030,7 +1063,9 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		int bankstart = (pageno & shared->bank_mask) * shared->bank_size;
+		int bankend = bankstart + shared->bank_size;
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			if (shared->page_number[slotno] == pageno &&
 				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
@@ -1065,7 +1100,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		 * multiple pages with the same lru_count.
 		 */
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			int			this_delta;
 			int			this_page_number;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index b7e2e2b55e3..cc9cc10d271 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -61,6 +61,8 @@ typedef struct SlruSharedData
 
 	/* Number of buffers managed by this SLRU structure */
 	int			num_slots;
+	int			bank_size;
+	int			bank_mask;
 
 	/*
 	 * Arrays holding info for each buffer slot.  Page number is undefined
-- 
2.30.2

v21-0001-Make-all-SLRU-buffer-sizes-configurable.patchtext/x-patch; charset=UTF-8; name=v21-0001-Make-all-SLRU-buffer-sizes-configurable.patchDownload
From e5f03ebac800f06f45c9ecb5f7139c96032e7fa7 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 15 Feb 2021 21:51:56 +0500
Subject: [PATCH v21 1/2] Make all SLRU buffer sizes configurable.

Provide new GUCs to set the number of buffers, instead of using hard
coded defaults.

Remove the limits on xact_buffers and commit_ts_buffers.  The default
sizes for those caches are ~0.2% and ~0.1% of shared_buffers, as before,
but now there is no cap at 128 and 16 buffers respectively (unless
track_commit_timestamp is disabled, in the latter case, then we might as
well keep it tiny).  Sizes much larger than the old limits have been
shown to be useful on modern systems, and an earlier commit replaced a
linear search with a hash table to avoid problems with extreme cases.

Author: Andrey M. Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Gilles Darold <gilles@darold.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/2BEC2B3F-9B61-4C1D-9FB5-5FAB0F05EF86%40yandex-team.ru
---
 doc/src/sgml/config.sgml                      | 135 ++++++++++++++++++
 src/backend/access/transam/clog.c             |  23 ++-
 src/backend/access/transam/commit_ts.c        |   5 +
 src/backend/access/transam/multixact.c        |   8 +-
 src/backend/access/transam/subtrans.c         |   5 +-
 src/backend/commands/async.c                  |   8 +-
 src/backend/storage/lmgr/predicate.c          |   4 +-
 src/backend/utils/init/globals.c              |   8 ++
 src/backend/utils/misc/guc.c                  |  99 +++++++++++++
 src/backend/utils/misc/postgresql.conf.sample |   9 ++
 src/include/access/clog.h                     |  10 ++
 src/include/access/commit_ts.h                |   1 -
 src/include/access/multixact.h                |   4 -
 src/include/access/slru.h                     |   5 +
 src/include/access/subtrans.h                 |   2 -
 src/include/commands/async.h                  |   5 -
 src/include/miscadmin.h                       |   7 +
 src/include/storage/predicate.h               |   4 -
 18 files changed, 299 insertions(+), 43 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index e2d728e0c4f..991dba69757 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1961,6 +1961,141 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+     <varlistentry id="guc-multixact-offsets-buffers" xreflabel="multixact_offsets_buffers">
+      <term><varname>multixact_offsets_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_offsets_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/offsets</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry id="guc-multixact-members-buffers" xreflabel="multixact_members_buffers">
+      <term><varname>multixact_members_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>multixact_members_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_multixact/members</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry id="guc-subtrans-buffers" xreflabel="subtrans_buffers">
+      <term><varname>subtrans_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>subtrans_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_subtrans</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry id="guc-notify-buffers" xreflabel="notify_buffers">
+      <term><varname>notify_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>notify_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_notify</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>8</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry id="guc-serial-buffers" xreflabel="serial_buffers">
+      <term><varname>serial_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>serial_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_serial</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>16</literal>.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry id="guc-xact-buffers" xreflabel="xact_buffers">
+      <term><varname>xact_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>xact_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of shared memory to use to cache the contents
+        of <literal>pg_xact</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 512, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry id="guc-commit-ts-buffers" xreflabel="commit_ts_buffers">
+      <term><varname>commit_ts_buffers</varname> (<type>integer</type>)
+      <indexterm>
+       <primary><varname>commit_ts_buffers</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Specifies the amount of memory to use to cache the cotents of
+        <literal>pg_commit_ts</literal> (see
+        <xref linkend="pgdata-contents-table"/>).
+        If this value is specified without units, it is taken as blocks,
+        that is <symbol>BLCKSZ</symbol> bytes, typically 8kB.
+        The default value is <literal>0</literal>, which requests
+        <varname>shared_buffers</varname> / 1024, but not fewer than 4 blocks.
+        This parameter can only be set at server start.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e96a75d6959 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -58,8 +58,8 @@
 
 /* We need two bits per xact, so four xacts fit in a byte */
 #define CLOG_BITS_PER_XACT	2
-#define CLOG_XACTS_PER_BYTE 4
-#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+StaticAssertDecl((CLOG_BITS_PER_XACT * CLOG_XACTS_PER_BYTE) == BITS_PER_BYTE,
+				 "CLOG_BITS_PER_XACT and CLOG_XACTS_PER_BYTE are inconsistent");
 #define CLOG_XACT_BITMASK	((1 << CLOG_BITS_PER_XACT) - 1)
 
 #define TransactionIdToPage(xid)	((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
@@ -665,23 +665,16 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 /*
  * Number of shared CLOG buffers.
  *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
+ * By default, we'll use 2MB of for every 1GB of shared buffers, up to the
+ * theoretical maximum useful value, but always at least 4 buffers.
  */
 Size
 CLOGShmemBuffers(void)
 {
-	return Min(128, Max(4, NBuffers / 512));
+	/* Use configured value if provided. */
+	if (xact_buffers > 0)
+		return Max(4, xact_buffers);
+	return Min(CLOG_MAX_ALLOWED_BUFFERS, Max(4, NBuffers / 512));
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 4dc8d402bd3..48ca5007475 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -514,10 +514,15 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
  * We use a very similar logic as for the number of CLOG buffers (except we
  * scale up twice as fast with shared buffers, and the maximum is twice as
  * high); see comments in CLOGShmemBuffers.
+ * By default, we'll use 1MB of for every 1GB of shared buffers, up to the
+ * maximum value that slru.c will allow, but always at least 4 buffers.
  */
 Size
 CommitTsShmemBuffers(void)
 {
+	/* Use configured value if provided. */
+	if (commit_ts_buffers > 0)
+		return Max(4, commit_ts_buffers);
 	return Min(256, Max(4, NBuffers / 256));
 }
 
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 8f7d12950e5..71d17e338e9 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1834,8 +1834,8 @@ MultiXactShmemSize(void)
 			 mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot))
 
 	size = SHARED_MULTIXACT_STATE_SIZE;
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTOFFSET_BUFFERS, 0));
-	size = add_size(size, SimpleLruShmemSize(NUM_MULTIXACTMEMBER_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_offsets_buffers, 0));
+	size = add_size(size, SimpleLruShmemSize(multixact_members_buffers, 0));
 
 	return size;
 }
@@ -1851,13 +1851,13 @@ MultiXactShmemInit(void)
 	MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes;
 
 	SimpleLruInit(MultiXactOffsetCtl,
-				  "MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
+				  "MultiXactOffset", multixact_offsets_buffers, 0,
 				  MultiXactOffsetSLRULock, "pg_multixact/offsets",
 				  LWTRANCHE_MULTIXACTOFFSET_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_OFFSET);
 	SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
 	SimpleLruInit(MultiXactMemberCtl,
-				  "MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
+				  "MultiXactMember", multixact_offsets_buffers, 0,
 				  MultiXactMemberSLRULock, "pg_multixact/members",
 				  LWTRANCHE_MULTIXACTMEMBER_BUFFER,
 				  SYNC_HANDLER_MULTIXACT_MEMBER);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d35481552..862b0eab966 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
@@ -184,14 +185,14 @@ SubTransGetTopmostTransaction(TransactionId xid)
 Size
 SUBTRANSShmemSize(void)
 {
-	return SimpleLruShmemSize(NUM_SUBTRANS_BUFFERS, 0);
+	return SimpleLruShmemSize(subtrans_buffers, 0);
 }
 
 void
 SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
-	SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
+	SimpleLruInit(SubTransCtl, "Subtrans", subtrans_buffers, 0,
 				  SubtransSLRULock, "pg_subtrans",
 				  LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
 	SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df030..6b980603302 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -117,7 +117,7 @@
  * frontend during startup.)  The above design guarantees that notifies from
  * other backends will never be missed by ignoring self-notifies.
  *
- * The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
+ * The amount of shared memory used for notify management (notify_buffers)
  * can be varied without affecting anything but performance.  The maximum
  * amount of notification data that can be queued at one time is determined
  * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
@@ -235,7 +235,7 @@ typedef struct QueuePosition
  *
  * Resist the temptation to make this really large.  While that would save
  * work in some places, it would add cost in others.  In particular, this
- * should likely be less than NUM_NOTIFY_BUFFERS, to ensure that backends
+ * should likely be less than notify_buffers, to ensure that backends
  * catch up before the pages they'll need to read fall out of SLRU cache.
  */
 #define QUEUE_CLEANUP_DELAY 4
@@ -521,7 +521,7 @@ AsyncShmemSize(void)
 	size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus));
 	size = add_size(size, offsetof(AsyncQueueControl, backend));
 
-	size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(notify_buffers, 0));
 
 	return size;
 }
@@ -569,7 +569,7 @@ AsyncShmemInit(void)
 	 * Set up SLRU management of the pg_notify data.
 	 */
 	NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
-	SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
+	SimpleLruInit(NotifyCtl, "Notify", notify_buffers, 0,
 				  NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
 				  SYNC_HANDLER_NONE);
 
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 5136da6ea36..54a0d66d579 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -872,7 +872,7 @@ SerialInit(void)
 	 */
 	SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
 	SimpleLruInit(SerialSlruCtl, "Serial",
-				  NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
+				  serial_buffers, 0, SerialSLRULock, "pg_serial",
 				  LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
 #ifdef USE_ASSERT_CHECKING
 	SerialPagePrecedesLogicallyUnitTests();
@@ -1396,7 +1396,7 @@ PredicateLockShmemSize(void)
 
 	/* Shared memory structures for SLRU tracking of old committed xids. */
 	size = add_size(size, sizeof(SerialControlData));
-	size = add_size(size, SimpleLruShmemSize(NUM_SERIAL_BUFFERS, 0));
+	size = add_size(size, SimpleLruShmemSize(serial_buffers, 0));
 
 	return size;
 }
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 1a5d29ac9ba..cc0ca91a8b3 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -151,3 +151,11 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			multixact_offsets_buffers = 8;
+int			multixact_members_buffers = 16;
+int			subtrans_buffers = 32;
+int			notify_buffers = 8;
+int			serial_buffers = 16;
+int			xact_buffers = 0;
+int			commit_ts_buffers = 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index af4a1c30689..2d9121b9265 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -32,9 +32,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -209,6 +211,8 @@ static const char *show_tcp_keepalives_idle(void);
 static const char *show_tcp_keepalives_interval(void);
 static const char *show_tcp_keepalives_count(void);
 static const char *show_tcp_user_timeout(void);
+static const char *show_xact_buffers(void);
+static const char *show_commit_ts_buffers(void);
 static bool check_maxconnections(int *newval, void **extra, GucSource source);
 static bool check_max_worker_processes(int *newval, void **extra, GucSource source);
 static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source);
@@ -2426,6 +2430,83 @@ static struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"multixact_offsets_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact offset SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_offsets_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"multixact_members_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the MultiXact member SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&multixact_members_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"subtrans_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the sub-transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&subtrans_buffers,
+		32, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"notify_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the NOTIFY message SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&notify_buffers,
+		8, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"serial_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the serializable transaction SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&serial_buffers,
+		16, 2, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, NULL
+	},
+
+	{
+		{"xact_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the number of shared memory buffers used for the transaction status SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&xact_buffers,
+		0, 0, CLOG_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_xact_buffers
+	},
+
+	{
+		{"commit_ts_buffers", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("Sets the size of the dedicated buffer pool used for the commit timestamp SLRU cache."),
+			NULL,
+			GUC_UNIT_BLOCKS
+		},
+		&commit_ts_buffers,
+		0, 0, SLRU_MAX_ALLOWED_BUFFERS,
+		NULL, NULL, show_commit_ts_buffers
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
@@ -12447,6 +12528,24 @@ show_tcp_user_timeout(void)
 	return nbuf;
 }
 
+static const char *
+show_xact_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CLOGShmemBuffers());
+	return nbuf;
+}
+
+static const char *
+show_commit_ts_buffers(void)
+{
+	static char nbuf[16];
+
+	snprintf(nbuf, sizeof(nbuf), "%zu", CommitTsShmemBuffers());
+	return nbuf;
+}
+
 static bool
 check_maxconnections(int *newval, void **extra, GucSource source)
 {
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index b4bc06e5f5a..2cb827e1e3b 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -195,6 +195,15 @@
 #old_snapshot_threshold = -1		# 1min-60d; -1 disables; 0 is immediate
 					# (change requires restart)
 
+# - SLRU Buffers (change requires restart) -
+
+#xact_buffers = 0			# memory for pg_xact (0 = auto)
+#subtrans_buffers = 32			# memory for pg_subtrans
+#multixact_offsets_buffers = 8		# memory for pg_multixact/offsets
+#multixact_members_buffers = 16		# memory for pg_multixact/members
+#notify_buffers = 8			# memory for pg_notify
+#serial_buffers = 16			# memory for pg_serial
+#commit_ts_buffers = 0			# memory for pg_commit_ts (0 = auto)
 
 #------------------------------------------------------------------------------
 # WRITE-AHEAD LOG
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 543f2e2643a..17d103aa4da 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -15,6 +15,16 @@
 #include "storage/sync.h"
 #include "lib/stringinfo.h"
 
+/*
+ * Don't allow xact_buffers to be set higher than could possibly be useful or
+ * SLRU would allow.
+ */
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+#define CLOG_MAX_ALLOWED_BUFFERS \
+	Min(SLRU_MAX_ALLOWED_BUFFERS, \
+		(((MaxTransactionId / 2) + (CLOG_XACTS_PER_PAGE - 1)) / CLOG_XACTS_PER_PAGE))
+
 /*
  * Possible transaction statuses --- note that all-zeroes is the initial
  * state.
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 7662f8e1a9c..d928dcc9352 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -16,7 +16,6 @@
 #include "replication/origin.h"
 #include "storage/sync.h"
 
-
 extern PGDLLIMPORT bool track_commit_timestamp;
 
 extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index a5600a320ae..da7b8f0abb9 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -29,10 +29,6 @@
 
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
-/* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
-
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
  * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..b7e2e2b55e3 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -17,6 +17,11 @@
 #include "storage/lwlock.h"
 #include "storage/sync.h"
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
 
 /*
  * Define SLRU segment size.  A page is the same BLCKSZ as is used everywhere
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index f94e116640b..1ddb62883b0 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -11,8 +11,6 @@
 #ifndef SUBTRANS_H
 #define SUBTRANS_H
 
-/* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 926af933d1b..402d184b9b3 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,11 +15,6 @@
 
 #include <signal.h>
 
-/*
- * The number of SLRU page buffers we use for the notification queue.
- */
-#define NUM_NOTIFY_BUFFERS	8
-
 extern PGDLLIMPORT bool Trace_notify;
 extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
 
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index ea9a56d3955..e65990e04e8 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -177,6 +177,13 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int multixact_offsets_buffers;
+extern PGDLLIMPORT int multixact_members_buffers;
+extern PGDLLIMPORT int subtrans_buffers;
+extern PGDLLIMPORT int notify_buffers;
+extern PGDLLIMPORT int serial_buffers;
+extern PGDLLIMPORT int xact_buffers;
+extern PGDLLIMPORT int commit_ts_buffers;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index 8dfcb3944b4..1e3f757ec30 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -26,10 +26,6 @@ extern PGDLLIMPORT int max_predicate_locks_per_xact;
 extern PGDLLIMPORT int max_predicate_locks_per_relation;
 extern PGDLLIMPORT int max_predicate_locks_per_page;
 
-
-/* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
-
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
  * in a parallel query.
-- 
2.30.2

#84Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Yura Sokolov (#83)
Re: MultiXact\SLRU buffers configuration

On 21 Jul 2022, at 18:00, Yura Sokolov <y.sokolov@postgrespro.ru> wrote:

In this case simple buffer increase does help. But "buckets"
increase performance gain.

Yura, thank you for your benchmarks!
We already knew that patch can save the day on pathological workloads, now we have a proof of this.
Also there's the evidence that user can blindly increase size of SLRU if they want (with the second patch). So there's no need for hard explanations on how to tune the buffers size.

Thomas, do you still have any doubts? Or is it certain that SLRU will be replaced by any better subsystem in 16?

Best regards, Andrey Borodin.

#85Thomas Munro
thomas.munro@gmail.com
In reply to: Andrey Borodin (#84)
Re: MultiXact\SLRU buffers configuration

On Sat, Jul 23, 2022 at 8:41 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

Thomas, do you still have any doubts? Or is it certain that SLRU will be replaced by any better subsystem in 16?

Hi Andrey,

Sorry for my lack of replies on this and the other SLRU thread -- I'm
thinking and experimenting. More soon.

#86Noname
i.lazarev@postgrespro.ru
In reply to: Andrey Borodin (#84)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

Andrey Borodin wrote 2022-07-23 11:39:

Yura, thank you for your benchmarks!
We already knew that patch can save the day on pathological workloads,
now we have a proof of this.
Also there's the evidence that user can blindly increase size of SLRU
if they want (with the second patch). So there's no need for hard
explanations on how to tune the buffers size.

Hi @Andrey.Borodin, With some considerations and performance checks from
@Yura.Sokolov we simplified your approach by the following:

1. Preamble. We feel free to increase any SLRU's, since there's no
performance degradation on large Buffers count using your SLRU buckets
solution.
2. `slru_buffers_size_scale` is only one config param introduced for all
SLRUs. It scales SLRUs upper cap by power 2.
3. All SLRU buffers count are capped by both `MBuffers (shared_buffers)`
and `slru_buffers_size_scale`. see
4. Magic initial constants `NUM_*_BUFFERS << slru_buffers_size_scale`
are applied for every SLRU.
5. All SLRU buffers are always sized as power of 2, their hash bucket
size is always 8.

There's attached patch for your consideration. It does gather and
simplify both `v21-0001-Make-all-SLRU-buffer-sizes-configurable.patch`
and `v21-0002-Divide-SLRU-buffers-into-8-associative-banks.patch` to
much simpler approach.

Thank you, Yours,
- Ivan

Attachments:

v22-0006-bucketed-SLRUs-simplified_patch.patchtext/x-diff; name=v22-0006-bucketed-SLRUs-simplified_patch.patchDownload
Index: src/include/miscadmin.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
--- a/src/include/miscadmin.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/miscadmin.h	(date 1660678108730)
@@ -176,6 +176,7 @@
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int slru_buffers_size_scale;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
Index: src/include/access/subtrans.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
--- a/src/include/access/subtrans.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/access/subtrans.h	(date 1660678108698)
@@ -12,7 +12,7 @@
 #define SUBTRANS_H
 
 /* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
+#define NUM_SUBTRANS_BUFFERS	(32 << slru_buffers_size_scale)
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
Index: src/backend/utils/init/globals.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
--- a/src/backend/utils/init/globals.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/utils/init/globals.c	(date 1660678064048)
@@ -150,3 +150,5 @@
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			slru_buffers_size_scale = 2;	/* power 2 scale for SLRU buffers */
Index: src/backend/access/transam/slru.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
--- a/src/backend/access/transam/slru.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/access/transam/slru.c	(date 1660678063980)
@@ -59,6 +59,7 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "port/pg_bitutils.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -71,6 +72,17 @@
  */
 #define MAX_WRITEALL_BUFFERS	16
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
+
+/*
+ * SLRU bank size for slotno hash banks
+ */
+#define SLRU_BANK_SIZE 8
+
 typedef struct SlruWriteAllData
 {
 	int			num_files;		/* # files actually open */
@@ -134,7 +146,7 @@
 static SlruErrorCause slru_errcause;
 static int	slru_errno;
 
-
+static void SlruAdjustNSlots(int *nslots, int *bankmask);
 static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
 static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
 static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
@@ -148,6 +160,25 @@
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
 
+/*
+ * Pick number of slots and bank size optimal for hashed associative SLRU buffers.
+ * We declare SLRU nslots is always power of 2.
+ * We split SLRU to 8-sized hash banks, after some performance benchmarks.
+ * We hash pageno to banks by pageno masked by 3 upper bits.
+ */
+static void
+SlruAdjustNSlots(int *nslots, int *bankmask)
+{
+	Assert(*nslots > 0);
+	Assert(*nslots <= SLRU_MAX_ALLOWED_BUFFERS);
+
+	*nslots = (int) pg_nextpower2_32(Max(SLRU_BANK_SIZE, Min(*nslots, NBuffers / 256)));
+
+	*bankmask = *nslots / SLRU_BANK_SIZE - 1;
+
+	elog(DEBUG5, "nslots %d banksize %d nbanks %d bankmask %x", *nslots, SLRU_BANK_SIZE, *nslots / SLRU_BANK_SIZE, *bankmask);
+}
+
 /*
  * Initialization of shared memory
  */
@@ -156,6 +187,9 @@
 SimpleLruShmemSize(int nslots, int nlsns)
 {
 	Size		sz;
+	int			bankmask_ignore;
+
+	SlruAdjustNSlots(&nslots, &bankmask_ignore);
 
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
@@ -190,6 +224,9 @@
 {
 	SlruShared	shared;
 	bool		found;
+	int			bankmask;
+
+	SlruAdjustNSlots(&nslots, &bankmask);
 
 	shared = (SlruShared) ShmemInitStruct(name,
 										  SimpleLruShmemSize(nslots, nlsns),
@@ -257,7 +294,10 @@
 		Assert(ptr - (char *) shared <= SimpleLruShmemSize(nslots, nlsns));
 	}
 	else
+	{
 		Assert(found);
+		Assert(shared->num_slots == nslots);
+	}
 
 	/*
 	 * Initialize the unshared control struct, including directory path. We
@@ -265,6 +305,7 @@
 	 */
 	ctl->shared = shared;
 	ctl->sync_handler = sync_handler;
+	ctl->bank_mask = bankmask;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
 
@@ -496,12 +537,14 @@
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
+	int			bankstart = (pageno & ctl->bank_mask) * SLRU_BANK_SIZE;
+	int			bankend = bankstart + SLRU_BANK_SIZE;
 
 	/* Try to find the page while holding only shared lock */
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
 		if (shared->page_number[slotno] == pageno &&
 			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
@@ -1030,7 +1073,10 @@
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		int			bankstart = (pageno & ctl->bank_mask) * SLRU_BANK_SIZE;
+		int			bankend = bankstart + SLRU_BANK_SIZE;
+
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			if (shared->page_number[slotno] == pageno &&
 				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
@@ -1065,7 +1111,7 @@
 		 * multiple pages with the same lru_count.
 		 */
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			int			this_delta;
 			int			this_page_number;
Index: src/backend/access/transam/clog.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
--- a/src/backend/access/transam/clog.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/access/transam/clog.c	(date 1660677867877)
@@ -74,6 +74,8 @@
 #define GetLSNIndex(slotno, xid)	((slotno) * CLOG_LSNS_PER_PAGE + \
 	((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) / CLOG_XACTS_PER_LSN_GROUP)
 
+#define NUM_CLOG_BUFFERS 	(128 << slru_buffers_size_scale)
+
 /*
  * The number of subtransactions below which we consider to apply clog group
  * update optimization.  Testing reveals that the number higher than this can
@@ -661,42 +663,20 @@
 	return status;
 }
 
-/*
- * Number of shared CLOG buffers.
- *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
- */
-Size
-CLOGShmemBuffers(void)
-{
-	return Min(128, Max(4, NBuffers / 512));
-}
-
 /*
  * Initialization of shared memory for CLOG
  */
 Size
 CLOGShmemSize(void)
 {
-	return SimpleLruShmemSize(CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE);
+	return SimpleLruShmemSize(NUM_CLOG_BUFFERS, CLOG_LSNS_PER_PAGE);
 }
 
 void
 CLOGShmemInit(void)
 {
 	XactCtl->PagePrecedes = CLOGPagePrecedes;
-	SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
+	SimpleLruInit(XactCtl, "Xact", NUM_CLOG_BUFFERS, CLOG_LSNS_PER_PAGE,
 				  XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
 				  SYNC_HANDLER_CLOG);
 	SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
Index: src/include/storage/predicate.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
--- a/src/include/storage/predicate.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/storage/predicate.h	(date 1660678108718)
@@ -28,7 +28,7 @@
 
 
 /* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
+#define NUM_SERIAL_BUFFERS	(16 << slru_buffers_size_scale)
 
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
Index: src/backend/utils/misc/postgresql.conf.sample
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
--- a/src/backend/utils/misc/postgresql.conf.sample	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/utils/misc/postgresql.conf.sample	(date 1660678108650)
@@ -155,6 +155,8 @@
 					#   mmap
 					# (change requires restart)
 #min_dynamic_shared_memory = 0MB	# (change requires restart)
+#slru_buffers_size_scale = 2 # SLRU buffers size scale of power 2, range 0..7
+					# (change requires restart)
 
 # - Disk -
 
Index: src/include/access/multixact.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
--- a/src/include/access/multixact.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/access/multixact.h	(date 1660678108678)
@@ -30,8 +30,8 @@
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
 /* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
+#define NUM_MULTIXACTOFFSET_BUFFERS		(16 << slru_buffers_size_scale)
+#define NUM_MULTIXACTMEMBER_BUFFERS		(32 << slru_buffers_size_scale)
 
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
Index: src/backend/utils/misc/guc.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
--- a/src/backend/utils/misc/guc.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/utils/misc/guc.c	(date 1660678064216)
@@ -32,9 +32,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -2375,6 +2377,16 @@
 		-1, -1, INT_MAX,
 		NULL, NULL, NULL
 	},
+
+	{
+		{"slru_buffers_size_scale", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("SLRU buffers size scale of power 2"),
+			NULL
+		},
+		&slru_buffers_size_scale,
+		2, 0, 7,
+		NULL, NULL, NULL
+	},
 
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
Index: src/include/commands/async.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
--- a/src/include/commands/async.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/commands/async.h	(date 1660678108702)
@@ -18,7 +18,7 @@
 /*
  * The number of SLRU page buffers we use for the notification queue.
  */
-#define NUM_NOTIFY_BUFFERS	8
+#define NUM_NOTIFY_BUFFERS	(16 << slru_buffers_size_scale)
 
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
Index: src/include/access/slru.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
--- a/src/include/access/slru.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/access/slru.h	(date 1660678108690)
@@ -134,6 +134,11 @@
 	 * it's always the same, it doesn't need to be in shared memory.
 	 */
 	char		Dir[64];
+
+	/*
+	 * mask for slotno hash bank
+	 */
+	Size		bank_mask;
 } SlruCtlData;
 
 typedef SlruCtlData *SlruCtl;
Index: src/backend/access/transam/subtrans.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
--- a/src/backend/access/transam/subtrans.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/access/transam/subtrans.c	(date 1660678064032)
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
Index: doc/src/sgml/config.sgml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
--- a/doc/src/sgml/config.sgml	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/doc/src/sgml/config.sgml	(date 1660677867861)
@@ -1953,6 +1953,37 @@
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-slru-buffers-size-scale" xreflabel="slru_buffers_size_scale">
+     <term><varname>slru_buffers_size_scale</varname> (<type>integer</type>)
+     <indexterm>
+      <primary><varname>slru_buffers_size_scale</varname> configuration parameter</primary>
+     </indexterm>
+     </term>
+     <listitem>
+      <para>
+       Specifies power 2 scale for all SLRU shared memory buffers sizes. Buffers sizes depends on
+       both <literal>guc_slru_buffers_size_scale</literal> and <literal>shared_buffers</literal> params.
+      </para>
+      <para>
+       This affects on buffers in the list below (see also <xref linkend="pgdata-contents-table"/>):
+        <itemizedlist>
+         <listitem><para><literal>NUM_MULTIXACTOFFSET_BUFFERS = Min(32 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_MULTIXACTMEMBER_BUFFERS = Min(64 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_SUBTRANS_BUFFERS = Min(64 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_NOTIFY_BUFFERS = Min(32 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_SERIAL_BUFFERS = Min(32 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_CLOG_BUFFERS = Min(128 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_COMMIT_TS_BUFFERS = Min(128 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+        </itemizedlist>
+      </para>
+      <para>
+       Value is in <literal>0..7</literal> bounds.
+       The default value is <literal>2</literal>.
+       This parameter can only be set at server start.
+      </para>
+     </listitem>
+    </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
Index: src/backend/access/transam/commit_ts.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
--- a/src/backend/access/transam/commit_ts.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/access/transam/commit_ts.c	(date 1660677867889)
@@ -73,6 +73,8 @@
 #define TransactionIdToCTsEntry(xid)	\
 	((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
 
+#define NUM_COMMIT_TS_BUFFERS	(128 << slru_buffers_size_scale)
+
 /*
  * Link to shared-memory data structures for CommitTs control
  */
@@ -508,26 +510,13 @@
 	PG_RETURN_DATUM(HeapTupleGetDatum(htup));
 }
 
-/*
- * Number of shared CommitTS buffers.
- *
- * We use a very similar logic as for the number of CLOG buffers (except we
- * scale up twice as fast with shared buffers, and the maximum is twice as
- * high); see comments in CLOGShmemBuffers.
- */
-Size
-CommitTsShmemBuffers(void)
-{
-	return Min(256, Max(4, NBuffers / 256));
-}
-
 /*
  * Shared memory sizing for CommitTs
  */
 Size
 CommitTsShmemSize(void)
 {
-	return SimpleLruShmemSize(CommitTsShmemBuffers(), 0) +
+	return SimpleLruShmemSize(NUM_COMMIT_TS_BUFFERS, 0) +
 		sizeof(CommitTimestampShared);
 }
 
@@ -541,7 +530,7 @@
 	bool		found;
 
 	CommitTsCtl->PagePrecedes = CommitTsPagePrecedes;
-	SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
+	SimpleLruInit(CommitTsCtl, "CommitTs", NUM_COMMIT_TS_BUFFERS, 0,
 				  CommitTsSLRULock, "pg_commit_ts",
 				  LWTRANCHE_COMMITTS_BUFFER,
 				  SYNC_HANDLER_COMMIT_TS);
#87Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Noname (#86)
Re: MultiXact\SLRU buffers configuration

On 17 Aug 2022, at 00:36, i.lazarev@postgrespro.ru wrote:

Andrey Borodin wrote 2022-07-23 11:39:
Yura, thank you for your benchmarks!
We already knew that patch can save the day on pathological workloads,
now we have a proof of this.
Also there's the evidence that user can blindly increase size of SLRU
if they want (with the second patch). So there's no need for hard
explanations on how to tune the buffers size.

Hi @Andrey.Borodin, With some considerations and performance checks from @Yura.Sokolov we simplified your approach by the following:

1. Preamble. We feel free to increase any SLRU's, since there's no performance degradation on large Buffers count using your SLRU buckets solution.
2. `slru_buffers_size_scale` is only one config param introduced for all SLRUs. It scales SLRUs upper cap by power 2.
3. All SLRU buffers count are capped by both `MBuffers (shared_buffers)` and `slru_buffers_size_scale`. see
4. Magic initial constants `NUM_*_BUFFERS << slru_buffers_size_scale` are applied for every SLRU.
5. All SLRU buffers are always sized as power of 2, their hash bucket size is always 8.

There's attached patch for your consideration. It does gather and simplify both `v21-0001-Make-all-SLRU-buffer-sizes-configurable.patch` and `v21-0002-Divide-SLRU-buffers-into-8-associative-banks.patch` to much simpler approach.

I like the idea of one knob instead of one per each SLRU. Maybe we even could deduce sane value from NBuffers? That would effectively lead to 0 knobs :)

Your patch have a prefix "v22-0006", does it mean there are 5 previous steps of the patchset?

Thank you!

Best regards, Andrey Borodin.

#88Noname
i.lazarev@postgrespro.ru
In reply to: Andrey Borodin (#87)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

Andrey Borodin wrote 2022-08-18 06:35:

I like the idea of one knob instead of one per each SLRU. Maybe we
even could deduce sane value from NBuffers? That would effectively
lead to 0 knobs :)

Your patch have a prefix "v22-0006", does it mean there are 5 previous
steps of the patchset?

Thank you!

Best regards, Andrey Borodin.

Not sure it's possible to deduce from NBuffers only.
slru_buffers_scale_shift looks like relief valve for systems with ultra
scaled NBuffers.

Regarding v22-0006 I just tried to choose index unique for this thread
so now it's fixed to 0001 indexing.

Attachments:

v23-0001-bucketed-SLRUs-simplified.patchtext/x-diff; name=v23-0001-bucketed-SLRUs-simplified.patchDownload
Index: src/include/miscadmin.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
--- a/src/include/miscadmin.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/miscadmin.h	(date 1660678108730)
@@ -176,6 +176,7 @@
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int slru_buffers_size_scale;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
Index: src/include/access/subtrans.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
--- a/src/include/access/subtrans.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/access/subtrans.h	(date 1660678108698)
@@ -12,7 +12,7 @@
 #define SUBTRANS_H
 
 /* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
+#define NUM_SUBTRANS_BUFFERS	(32 << slru_buffers_size_scale)
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
Index: src/backend/utils/init/globals.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
--- a/src/backend/utils/init/globals.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/utils/init/globals.c	(date 1660678064048)
@@ -150,3 +150,5 @@
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			slru_buffers_size_scale = 2;	/* power 2 scale for SLRU buffers */
Index: src/backend/access/transam/slru.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
--- a/src/backend/access/transam/slru.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/access/transam/slru.c	(date 1660678063980)
@@ -59,6 +59,7 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "port/pg_bitutils.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -71,6 +72,17 @@
  */
 #define MAX_WRITEALL_BUFFERS	16
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
+
+/*
+ * SLRU bank size for slotno hash banks
+ */
+#define SLRU_BANK_SIZE 8
+
 typedef struct SlruWriteAllData
 {
 	int			num_files;		/* # files actually open */
@@ -134,7 +146,7 @@
 static SlruErrorCause slru_errcause;
 static int	slru_errno;
 
-
+static void SlruAdjustNSlots(int *nslots, int *bankmask);
 static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
 static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
 static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
@@ -148,6 +160,25 @@
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
 
+/*
+ * Pick number of slots and bank size optimal for hashed associative SLRU buffers.
+ * We declare SLRU nslots is always power of 2.
+ * We split SLRU to 8-sized hash banks, after some performance benchmarks.
+ * We hash pageno to banks by pageno masked by 3 upper bits.
+ */
+static void
+SlruAdjustNSlots(int *nslots, int *bankmask)
+{
+	Assert(*nslots > 0);
+	Assert(*nslots <= SLRU_MAX_ALLOWED_BUFFERS);
+
+	*nslots = (int) pg_nextpower2_32(Max(SLRU_BANK_SIZE, Min(*nslots, NBuffers / 256)));
+
+	*bankmask = *nslots / SLRU_BANK_SIZE - 1;
+
+	elog(DEBUG5, "nslots %d banksize %d nbanks %d bankmask %x", *nslots, SLRU_BANK_SIZE, *nslots / SLRU_BANK_SIZE, *bankmask);
+}
+
 /*
  * Initialization of shared memory
  */
@@ -156,6 +187,9 @@
 SimpleLruShmemSize(int nslots, int nlsns)
 {
 	Size		sz;
+	int			bankmask_ignore;
+
+	SlruAdjustNSlots(&nslots, &bankmask_ignore);
 
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
@@ -190,6 +224,9 @@
 {
 	SlruShared	shared;
 	bool		found;
+	int			bankmask;
+
+	SlruAdjustNSlots(&nslots, &bankmask);
 
 	shared = (SlruShared) ShmemInitStruct(name,
 										  SimpleLruShmemSize(nslots, nlsns),
@@ -257,7 +294,10 @@
 		Assert(ptr - (char *) shared <= SimpleLruShmemSize(nslots, nlsns));
 	}
 	else
+	{
 		Assert(found);
+		Assert(shared->num_slots == nslots);
+	}
 
 	/*
 	 * Initialize the unshared control struct, including directory path. We
@@ -265,6 +305,7 @@
 	 */
 	ctl->shared = shared;
 	ctl->sync_handler = sync_handler;
+	ctl->bank_mask = bankmask;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
 
@@ -496,12 +537,14 @@
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
+	int			bankstart = (pageno & ctl->bank_mask) * SLRU_BANK_SIZE;
+	int			bankend = bankstart + SLRU_BANK_SIZE;
 
 	/* Try to find the page while holding only shared lock */
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
 		if (shared->page_number[slotno] == pageno &&
 			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
@@ -1030,7 +1073,10 @@
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		int			bankstart = (pageno & ctl->bank_mask) * SLRU_BANK_SIZE;
+		int			bankend = bankstart + SLRU_BANK_SIZE;
+
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			if (shared->page_number[slotno] == pageno &&
 				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
@@ -1065,7 +1111,7 @@
 		 * multiple pages with the same lru_count.
 		 */
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			int			this_delta;
 			int			this_page_number;
Index: src/backend/access/transam/clog.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
--- a/src/backend/access/transam/clog.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/access/transam/clog.c	(date 1660677867877)
@@ -74,6 +74,8 @@
 #define GetLSNIndex(slotno, xid)	((slotno) * CLOG_LSNS_PER_PAGE + \
 	((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) / CLOG_XACTS_PER_LSN_GROUP)
 
+#define NUM_CLOG_BUFFERS 	(128 << slru_buffers_size_scale)
+
 /*
  * The number of subtransactions below which we consider to apply clog group
  * update optimization.  Testing reveals that the number higher than this can
@@ -661,42 +663,20 @@
 	return status;
 }
 
-/*
- * Number of shared CLOG buffers.
- *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
- */
-Size
-CLOGShmemBuffers(void)
-{
-	return Min(128, Max(4, NBuffers / 512));
-}
-
 /*
  * Initialization of shared memory for CLOG
  */
 Size
 CLOGShmemSize(void)
 {
-	return SimpleLruShmemSize(CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE);
+	return SimpleLruShmemSize(NUM_CLOG_BUFFERS, CLOG_LSNS_PER_PAGE);
 }
 
 void
 CLOGShmemInit(void)
 {
 	XactCtl->PagePrecedes = CLOGPagePrecedes;
-	SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
+	SimpleLruInit(XactCtl, "Xact", NUM_CLOG_BUFFERS, CLOG_LSNS_PER_PAGE,
 				  XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
 				  SYNC_HANDLER_CLOG);
 	SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
Index: src/include/storage/predicate.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
--- a/src/include/storage/predicate.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/storage/predicate.h	(date 1660678108718)
@@ -28,7 +28,7 @@
 
 
 /* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
+#define NUM_SERIAL_BUFFERS	(16 << slru_buffers_size_scale)
 
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
Index: src/backend/utils/misc/postgresql.conf.sample
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
--- a/src/backend/utils/misc/postgresql.conf.sample	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/utils/misc/postgresql.conf.sample	(date 1660678108650)
@@ -155,6 +155,8 @@
 					#   mmap
 					# (change requires restart)
 #min_dynamic_shared_memory = 0MB	# (change requires restart)
+#slru_buffers_size_scale = 2 # SLRU buffers size scale of power 2, range 0..7
+					# (change requires restart)
 
 # - Disk -
 
Index: src/include/access/multixact.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
--- a/src/include/access/multixact.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/access/multixact.h	(date 1660678108678)
@@ -30,8 +30,8 @@
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
 /* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
+#define NUM_MULTIXACTOFFSET_BUFFERS		(16 << slru_buffers_size_scale)
+#define NUM_MULTIXACTMEMBER_BUFFERS		(32 << slru_buffers_size_scale)
 
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
Index: src/backend/utils/misc/guc.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
--- a/src/backend/utils/misc/guc.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/utils/misc/guc.c	(date 1660678064216)
@@ -32,9 +32,11 @@
 #endif
 #include <unistd.h>
 
+#include "access/clog.h"
 #include "access/commit_ts.h"
 #include "access/gin.h"
 #include "access/rmgr.h"
+#include "access/slru.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
 #include "access/transam.h"
@@ -2375,6 +2377,16 @@
 		-1, -1, INT_MAX,
 		NULL, NULL, NULL
 	},
+
+	{
+		{"slru_buffers_size_scale", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("SLRU buffers size scale of power 2"),
+			NULL
+		},
+		&slru_buffers_size_scale,
+		2, 0, 7,
+		NULL, NULL, NULL
+	},
 
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
Index: src/include/commands/async.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
--- a/src/include/commands/async.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/commands/async.h	(date 1660678108702)
@@ -18,7 +18,7 @@
 /*
  * The number of SLRU page buffers we use for the notification queue.
  */
-#define NUM_NOTIFY_BUFFERS	8
+#define NUM_NOTIFY_BUFFERS	(16 << slru_buffers_size_scale)
 
 extern bool Trace_notify;
 extern volatile sig_atomic_t notifyInterruptPending;
Index: src/include/access/slru.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
--- a/src/include/access/slru.h	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/include/access/slru.h	(date 1660678108690)
@@ -134,6 +134,11 @@
 	 * it's always the same, it doesn't need to be in shared memory.
 	 */
 	char		Dir[64];
+
+	/*
+	 * mask for slotno hash bank
+	 */
+	Size		bank_mask;
 } SlruCtlData;
 
 typedef SlruCtlData *SlruCtl;
Index: src/backend/access/transam/subtrans.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
--- a/src/backend/access/transam/subtrans.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/access/transam/subtrans.c	(date 1660678064032)
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
Index: doc/src/sgml/config.sgml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
--- a/doc/src/sgml/config.sgml	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/doc/src/sgml/config.sgml	(date 1660677867861)
@@ -1953,6 +1953,37 @@
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-slru-buffers-size-scale" xreflabel="slru_buffers_size_scale">
+     <term><varname>slru_buffers_size_scale</varname> (<type>integer</type>)
+     <indexterm>
+      <primary><varname>slru_buffers_size_scale</varname> configuration parameter</primary>
+     </indexterm>
+     </term>
+     <listitem>
+      <para>
+       Specifies power 2 scale for all SLRU shared memory buffers sizes. Buffers sizes depends on
+       both <literal>guc_slru_buffers_size_scale</literal> and <literal>shared_buffers</literal> params.
+      </para>
+      <para>
+       This affects on buffers in the list below (see also <xref linkend="pgdata-contents-table"/>):
+        <itemizedlist>
+         <listitem><para><literal>NUM_MULTIXACTOFFSET_BUFFERS = Min(32 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_MULTIXACTMEMBER_BUFFERS = Min(64 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_SUBTRANS_BUFFERS = Min(64 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_NOTIFY_BUFFERS = Min(32 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_SERIAL_BUFFERS = Min(32 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_CLOG_BUFFERS = Min(128 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_COMMIT_TS_BUFFERS = Min(128 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+        </itemizedlist>
+      </para>
+      <para>
+       Value is in <literal>0..7</literal> bounds.
+       The default value is <literal>2</literal>.
+       This parameter can only be set at server start.
+      </para>
+     </listitem>
+    </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
Index: src/backend/access/transam/commit_ts.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
--- a/src/backend/access/transam/commit_ts.c	(revision 020258fbd30d37ddd03d0ec68264d1544f8d2838)
+++ b/src/backend/access/transam/commit_ts.c	(date 1660677867889)
@@ -73,6 +73,8 @@
 #define TransactionIdToCTsEntry(xid)	\
 	((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
 
+#define NUM_COMMIT_TS_BUFFERS	(128 << slru_buffers_size_scale)
+
 /*
  * Link to shared-memory data structures for CommitTs control
  */
@@ -508,26 +510,13 @@
 	PG_RETURN_DATUM(HeapTupleGetDatum(htup));
 }
 
-/*
- * Number of shared CommitTS buffers.
- *
- * We use a very similar logic as for the number of CLOG buffers (except we
- * scale up twice as fast with shared buffers, and the maximum is twice as
- * high); see comments in CLOGShmemBuffers.
- */
-Size
-CommitTsShmemBuffers(void)
-{
-	return Min(256, Max(4, NBuffers / 256));
-}
-
 /*
  * Shared memory sizing for CommitTs
  */
 Size
 CommitTsShmemSize(void)
 {
-	return SimpleLruShmemSize(CommitTsShmemBuffers(), 0) +
+	return SimpleLruShmemSize(NUM_COMMIT_TS_BUFFERS, 0) +
 		sizeof(CommitTimestampShared);
 }
 
@@ -541,7 +530,7 @@
 	bool		found;
 
 	CommitTsCtl->PagePrecedes = CommitTsPagePrecedes;
-	SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
+	SimpleLruInit(CommitTsCtl, "CommitTs", NUM_COMMIT_TS_BUFFERS, 0,
 				  CommitTsSLRULock, "pg_commit_ts",
 				  LWTRANCHE_COMMITTS_BUFFER,
 				  SYNC_HANDLER_COMMIT_TS);
#89Andrey Borodin
amborodin86@gmail.com
In reply to: Thomas Munro (#85)
Re: MultiXact\SLRU buffers configuration

On Sat, Jul 23, 2022 at 1:48 AM Thomas Munro <thomas.munro@gmail.com> wrote:

On Sat, Jul 23, 2022 at 8:41 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

Thomas, do you still have any doubts? Or is it certain that SLRU will be replaced by any better subsystem in 16?

Hi Andrey,

Sorry for my lack of replies on this and the other SLRU thread -- I'm
thinking and experimenting. More soon.

Hi Thomas,

PostgreSQL 16 feature freeze is approaching again. Let's choose
something from possible solutions, even if the chosen one is
temporary.
Thank you!

Best regards, Andrey Borodin.

#90vignesh C
vignesh21@gmail.com
In reply to: Noname (#88)
Re: MultiXact\SLRU buffers configuration

On Fri, 19 Aug 2022 at 21:18, <i.lazarev@postgrespro.ru> wrote:

Andrey Borodin wrote 2022-08-18 06:35:

I like the idea of one knob instead of one per each SLRU. Maybe we
even could deduce sane value from NBuffers? That would effectively
lead to 0 knobs :)

Your patch have a prefix "v22-0006", does it mean there are 5 previous
steps of the patchset?

Thank you!

Best regards, Andrey Borodin.

Not sure it's possible to deduce from NBuffers only.
slru_buffers_scale_shift looks like relief valve for systems with ultra
scaled NBuffers.

Regarding v22-0006 I just tried to choose index unique for this thread
so now it's fixed to 0001 indexing.

The patch does not apply on top of HEAD as in [1]http://cfbot.cputube.org/patch_41_2627.log, please post a rebased patch:

=== Applying patches on top of PostgreSQL commit ID
325bc54eed4ea0836a0bb715bb18342f0c1c668a ===
=== applying patch ./v23-0001-bucketed-SLRUs-simplified.patch
patching file src/include/miscadmin.h
...
patching file src/backend/utils/misc/guc.c
Hunk #1 FAILED at 32.
Hunk #2 FAILED at 2375.
2 out of 2 hunks FAILED -- saving rejects to file
src/backend/utils/misc/guc.c.rej

[1]: http://cfbot.cputube.org/patch_41_2627.log

Regards,
Vignesh

#91Andrey Borodin
amborodin86@gmail.com
In reply to: vignesh C (#90)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Tue, Jan 3, 2023 at 5:02 AM vignesh C <vignesh21@gmail.com> wrote:

does not apply on top of HEAD as in [1], please post a rebased patch:

Thanks! Here's the rebase.

Best regards, Andrey Borodin.

Attachments:

v24-0001-Divide-SLRU-buffers-into-8-associative-banks.patchapplication/octet-stream; name=v24-0001-Divide-SLRU-buffers-into-8-associative-banks.patchDownload
From e0a990996b2b5fe78747b82718b4806038d439c8 Mon Sep 17 00:00:00 2001
From: "Andrey M. Borodin" <x4mmm@flight.local>
Date: Sun, 8 Jan 2023 20:15:15 -0800
Subject: [PATCH v24] Divide SLRU buffers into 8-associative banks

We want to eliminate linear search within SLRU buffers.
To do so we divide SLRU buffers into banks. Each bank holds
approximately 8 buffers. Each SLRU pageno may reside only in one bank.
Adjacent pagenos reside in different banks.

Also invent slru_buffers_size_scale to control SLRU buffers.
---
 doc/src/sgml/config.sgml                      | 31 +++++++++++
 src/backend/access/transam/clog.c             | 28 ++--------
 src/backend/access/transam/commit_ts.c        | 19 ++-----
 src/backend/access/transam/slru.c             | 54 +++++++++++++++++--
 src/backend/access/transam/subtrans.c         |  1 +
 src/backend/utils/init/globals.c              |  2 +
 src/backend/utils/misc/guc_tables.c           | 10 ++++
 src/backend/utils/misc/postgresql.conf.sample |  2 +
 src/include/access/multixact.h                |  4 +-
 src/include/access/slru.h                     |  5 ++
 src/include/access/subtrans.h                 |  2 +-
 src/include/commands/async.h                  |  2 +-
 src/include/miscadmin.h                       |  2 +
 src/include/storage/predicate.h               |  2 +-
 14 files changed, 116 insertions(+), 48 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 05b3862d09..4ebc4bc17b 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1968,6 +1968,37 @@ include_dir 'conf.d'
       </listitem>
      </varlistentry>
 
+    <varlistentry id="guc-slru-buffers-size-scale" xreflabel="slru_buffers_size_scale">
+     <term><varname>slru_buffers_size_scale</varname> (<type>integer</type>)
+     <indexterm>
+      <primary><varname>slru_buffers_size_scale</varname> configuration parameter</primary>
+     </indexterm>
+     </term>
+     <listitem>
+      <para>
+       Specifies power 2 scale for all SLRU shared memory buffers sizes. Buffers sizes depends on
+       both <literal>guc_slru_buffers_size_scale</literal> and <literal>shared_buffers</literal> params.
+      </para>
+      <para>
+       This affects on buffers in the list below (see also <xref linkend="pgdata-contents-table"/>):
+        <itemizedlist>
+         <listitem><para><literal>NUM_MULTIXACTOFFSET_BUFFERS = Min(32 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_MULTIXACTMEMBER_BUFFERS = Min(64 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_SUBTRANS_BUFFERS = Min(64 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_NOTIFY_BUFFERS = Min(32 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_SERIAL_BUFFERS = Min(32 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_CLOG_BUFFERS = Min(128 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+         <listitem><para><literal>NUM_COMMIT_TS_BUFFERS = Min(128 &lt;&lt; slru_buffers_size_scale, shared_buffers/256)</literal></para></listitem>
+        </itemizedlist>
+      </para>
+      <para>
+       Value is in <literal>0..7</literal> bounds.
+       The default value is <literal>2</literal>.
+       This parameter can only be set at server start.
+      </para>
+     </listitem>
+    </varlistentry>
+
      <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth">
       <term><varname>max_stack_depth</varname> (<type>integer</type>)
       <indexterm>
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..29d58f1eb3 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -74,6 +74,8 @@
 #define GetLSNIndex(slotno, xid)	((slotno) * CLOG_LSNS_PER_PAGE + \
 	((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) / CLOG_XACTS_PER_LSN_GROUP)
 
+#define NUM_CLOG_BUFFERS 	(128 << slru_buffers_size_scale)
+
 /*
  * The number of subtransactions below which we consider to apply clog group
  * update optimization.  Testing reveals that the number higher than this can
@@ -660,42 +662,20 @@ TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
 	return status;
 }
 
-/*
- * Number of shared CLOG buffers.
- *
- * On larger multi-processor systems, it is possible to have many CLOG page
- * requests in flight at one time which could lead to disk access for CLOG
- * page if the required page is not found in memory.  Testing revealed that we
- * can get the best performance by having 128 CLOG buffers, more than that it
- * doesn't improve performance.
- *
- * Unconditionally keeping the number of CLOG buffers to 128 did not seem like
- * a good idea, because it would increase the minimum amount of shared memory
- * required to start, which could be a problem for people running very small
- * configurations.  The following formula seems to represent a reasonable
- * compromise: people with very low values for shared_buffers will get fewer
- * CLOG buffers as well, and everyone else will get 128.
- */
-Size
-CLOGShmemBuffers(void)
-{
-	return Min(128, Max(4, NBuffers / 512));
-}
-
 /*
  * Initialization of shared memory for CLOG
  */
 Size
 CLOGShmemSize(void)
 {
-	return SimpleLruShmemSize(CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE);
+	return SimpleLruShmemSize(NUM_CLOG_BUFFERS, CLOG_LSNS_PER_PAGE);
 }
 
 void
 CLOGShmemInit(void)
 {
 	XactCtl->PagePrecedes = CLOGPagePrecedes;
-	SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
+	SimpleLruInit(XactCtl, "Xact", NUM_CLOG_BUFFERS, CLOG_LSNS_PER_PAGE,
 				  XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
 				  SYNC_HANDLER_CLOG);
 	SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..54422f2780 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -70,6 +70,8 @@ typedef struct CommitTimestampEntry
 #define TransactionIdToCTsEntry(xid)	\
 	((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
 
+#define NUM_COMMIT_TS_BUFFERS	(128 << slru_buffers_size_scale)
+
 /*
  * Link to shared-memory data structures for CommitTs control
  */
@@ -487,26 +489,13 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)
 	PG_RETURN_DATUM(HeapTupleGetDatum(htup));
 }
 
-/*
- * Number of shared CommitTS buffers.
- *
- * We use a very similar logic as for the number of CLOG buffers (except we
- * scale up twice as fast with shared buffers, and the maximum is twice as
- * high); see comments in CLOGShmemBuffers.
- */
-Size
-CommitTsShmemBuffers(void)
-{
-	return Min(256, Max(4, NBuffers / 256));
-}
-
 /*
  * Shared memory sizing for CommitTs
  */
 Size
 CommitTsShmemSize(void)
 {
-	return SimpleLruShmemSize(CommitTsShmemBuffers(), 0) +
+	return SimpleLruShmemSize(NUM_COMMIT_TS_BUFFERS, 0) +
 		sizeof(CommitTimestampShared);
 }
 
@@ -520,7 +509,7 @@ CommitTsShmemInit(void)
 	bool		found;
 
 	CommitTsCtl->PagePrecedes = CommitTsPagePrecedes;
-	SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
+	SimpleLruInit(CommitTsCtl, "CommitTs", NUM_COMMIT_TS_BUFFERS, 0,
 				  CommitTsSLRULock, "pg_commit_ts",
 				  LWTRANCHE_COMMITTS_BUFFER,
 				  SYNC_HANDLER_COMMIT_TS);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 5ab86238a9..67dd967236 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,6 +59,7 @@
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/shmem.h"
+#include "port/pg_bitutils.h"
 
 #define SlruFileName(ctl, path, seg) \
 	snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
@@ -71,6 +72,17 @@
  */
 #define MAX_WRITEALL_BUFFERS	16
 
+/*
+ * To avoid overflowing internal arithmetic and the size_t data type, the
+ * number of buffers should not exceed this number.
+ */
+#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
+
+/*
+ * SLRU bank size for slotno hash banks
+ */
+#define SLRU_BANK_SIZE 8
+
 typedef struct SlruWriteAllData
 {
 	int			num_files;		/* # files actually open */
@@ -134,7 +146,7 @@ typedef enum
 static SlruErrorCause slru_errcause;
 static int	slru_errno;
 
-
+static void SlruAdjustNSlots(int *nslots, int *bankmask);
 static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
 static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
 static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
@@ -148,6 +160,25 @@ static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
 									  int segpage, void *data);
 static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
 
+/*
+ * Pick number of slots and bank size optimal for hashed associative SLRU buffers.
+ * We declare SLRU nslots is always power of 2.
+ * We split SLRU to 8-sized hash banks, after some performance benchmarks.
+ * We hash pageno to banks by pageno masked by 3 upper bits.
+ */
+static void
+SlruAdjustNSlots(int *nslots, int *bankmask)
+{
+	Assert(*nslots > 0);
+	Assert(*nslots <= SLRU_MAX_ALLOWED_BUFFERS);
+
+	*nslots = (int) pg_nextpower2_32(Max(SLRU_BANK_SIZE, Min(*nslots, NBuffers / 256)));
+
+	*bankmask = *nslots / SLRU_BANK_SIZE - 1;
+
+	elog(DEBUG5, "nslots %d banksize %d nbanks %d bankmask %x", *nslots, SLRU_BANK_SIZE, *nslots / SLRU_BANK_SIZE, *bankmask);
+}
+
 /*
  * Initialization of shared memory
  */
@@ -156,6 +187,9 @@ Size
 SimpleLruShmemSize(int nslots, int nlsns)
 {
 	Size		sz;
+	int			bankmask_ignore;
+
+	SlruAdjustNSlots(&nslots, &bankmask_ignore);
 
 	/* we assume nslots isn't so large as to risk overflow */
 	sz = MAXALIGN(sizeof(SlruSharedData));
@@ -191,6 +225,9 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 {
 	SlruShared	shared;
 	bool		found;
+	int			bankmask;
+
+	SlruAdjustNSlots(&nslots, &bankmask);
 
 	shared = (SlruShared) ShmemInitStruct(name,
 										  SimpleLruShmemSize(nslots, nlsns),
@@ -258,7 +295,10 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 		Assert(ptr - (char *) shared <= SimpleLruShmemSize(nslots, nlsns));
 	}
 	else
+	{
 		Assert(found);
+		Assert(shared->num_slots == nslots);
+	}
 
 	/*
 	 * Initialize the unshared control struct, including directory path. We
@@ -266,6 +306,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
 	 */
 	ctl->shared = shared;
 	ctl->sync_handler = sync_handler;
+	ctl->bank_mask = bankmask;
 	strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
 }
 
@@ -497,12 +538,14 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
 {
 	SlruShared	shared = ctl->shared;
 	int			slotno;
+	int			bankstart = (pageno & ctl->bank_mask) * SLRU_BANK_SIZE;
+	int			bankend = bankstart + SLRU_BANK_SIZE;
 
 	/* Try to find the page while holding only shared lock */
 	LWLockAcquire(shared->ControlLock, LW_SHARED);
 
 	/* See if page is already in a buffer */
-	for (slotno = 0; slotno < shared->num_slots; slotno++)
+	for (slotno = bankstart; slotno < bankend; slotno++)
 	{
 		if (shared->page_number[slotno] == pageno &&
 			shared->page_status[slotno] != SLRU_PAGE_EMPTY &&
@@ -1031,7 +1074,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		int			best_invalid_page_number = 0;	/* keep compiler quiet */
 
 		/* See if page already has a buffer assigned */
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		int			bankstart = (pageno & ctl->bank_mask) * SLRU_BANK_SIZE;
+		int			bankend = bankstart + SLRU_BANK_SIZE;
+
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			if (shared->page_number[slotno] == pageno &&
 				shared->page_status[slotno] != SLRU_PAGE_EMPTY)
@@ -1066,7 +1112,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
 		 * multiple pages with the same lru_count.
 		 */
 		cur_count = (shared->cur_lru_count)++;
-		for (slotno = 0; slotno < shared->num_slots; slotno++)
+		for (slotno = bankstart; slotno < bankend; slotno++)
 		{
 			int			this_delta;
 			int			this_page_number;
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..125273e235 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -31,6 +31,7 @@
 #include "access/slru.h"
 #include "access/subtrans.h"
 #include "access/transam.h"
+#include "miscadmin.h"
 #include "pg_trace.h"
 #include "utils/snapmgr.h"
 
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index 1b1d814254..65a509ac5a 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -151,3 +151,5 @@ int64		VacuumPageDirty = 0;
 
 int			VacuumCostBalance = 0;	/* working state for vacuum */
 bool		VacuumCostActive = false;
+
+int			slru_buffers_size_scale = 2;	/* power 2 scale for SLRU buffers */
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 68328b1402..3abc06e7e1 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2216,6 +2216,16 @@ struct config_int ConfigureNamesInt[] =
 		NULL, NULL, NULL
 	},
 
+	{
+		{"slru_buffers_size_scale", PGC_POSTMASTER, RESOURCES_MEM,
+			gettext_noop("SLRU buffers size scale of power 2"),
+			NULL
+		},
+		&slru_buffers_size_scale,
+		2, 0, 7,
+		NULL, NULL, NULL
+	},
+
 	{
 		{"temp_buffers", PGC_USERSET, RESOURCES_MEM,
 			gettext_noop("Sets the maximum number of temporary buffers used by each session."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 5afdeb04de..69ba328ea4 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -155,6 +155,8 @@
 					#   mmap
 					# (change requires restart)
 #min_dynamic_shared_memory = 0MB	# (change requires restart)
+#slru_buffers_size_scale = 2 # SLRU buffers size scale of power 2, range 0..7
+					# (change requires restart)
 
 # - Disk -
 
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 246f757f6a..6a2c914d48 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -30,8 +30,8 @@
 #define MaxMultiXactOffset	((MultiXactOffset) 0xFFFFFFFF)
 
 /* Number of SLRU buffers to use for multixact */
-#define NUM_MULTIXACTOFFSET_BUFFERS		8
-#define NUM_MULTIXACTMEMBER_BUFFERS		16
+#define NUM_MULTIXACTOFFSET_BUFFERS		(16 << slru_buffers_size_scale)
+#define NUM_MULTIXACTMEMBER_BUFFERS		(32 << slru_buffers_size_scale)
 
 /*
  * Possible multixact lock modes ("status").  The first four modes are for
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index a8a424d92d..f5f2b5b8b5 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -134,6 +134,11 @@ typedef struct SlruCtlData
 	 * it's always the same, it doesn't need to be in shared memory.
 	 */
 	char		Dir[64];
+
+	/*
+	 * mask for slotno hash bank
+	 */
+	Size		bank_mask;
 } SlruCtlData;
 
 typedef SlruCtlData *SlruCtl;
diff --git a/src/include/access/subtrans.h b/src/include/access/subtrans.h
index 46a473c77f..0dad287550 100644
--- a/src/include/access/subtrans.h
+++ b/src/include/access/subtrans.h
@@ -12,7 +12,7 @@
 #define SUBTRANS_H
 
 /* Number of SLRU buffers to use for subtrans */
-#define NUM_SUBTRANS_BUFFERS	32
+#define NUM_SUBTRANS_BUFFERS	(32 << slru_buffers_size_scale)
 
 extern void SubTransSetParent(TransactionId xid, TransactionId parent);
 extern TransactionId SubTransGetParent(TransactionId xid);
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 02da6ba7e1..b1d59472b1 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -18,7 +18,7 @@
 /*
  * The number of SLRU page buffers we use for the notification queue.
  */
-#define NUM_NOTIFY_BUFFERS	8
+#define NUM_NOTIFY_BUFFERS	(16 << slru_buffers_size_scale)
 
 extern PGDLLIMPORT bool Trace_notify;
 extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 0ffeefc437..789f00a7ea 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -177,6 +177,7 @@ extern PGDLLIMPORT int MaxBackends;
 extern PGDLLIMPORT int MaxConnections;
 extern PGDLLIMPORT int max_worker_processes;
 extern PGDLLIMPORT int max_parallel_workers;
+extern PGDLLIMPORT int slru_buffers_size_scale;
 
 extern PGDLLIMPORT int MyProcPid;
 extern PGDLLIMPORT pg_time_t MyStartTime;
@@ -262,6 +263,7 @@ extern PGDLLIMPORT int work_mem;
 extern PGDLLIMPORT double hash_mem_multiplier;
 extern PGDLLIMPORT int maintenance_work_mem;
 extern PGDLLIMPORT int max_parallel_maintenance_workers;
+extern PGDLLIMPORT int slru_buffers_size_scale;
 
 extern PGDLLIMPORT int VacuumCostPageHit;
 extern PGDLLIMPORT int VacuumCostPageMiss;
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index cd48afa17b..794ecd8169 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -28,7 +28,7 @@ extern PGDLLIMPORT int max_predicate_locks_per_page;
 
 
 /* Number of SLRU buffers to use for Serial SLRU */
-#define NUM_SERIAL_BUFFERS		16
+#define NUM_SERIAL_BUFFERS	(16 << slru_buffers_size_scale)
 
 /*
  * A handle used for sharing SERIALIZABLEXACT objects between the participants
-- 
2.32.0 (Apple Git-132)

#92Dilip Kumar
dilipbalaut@gmail.com
In reply to: Andrey Borodin (#91)
Re: MultiXact\SLRU buffers configuration

On Mon, Jan 9, 2023 at 9:49 AM Andrey Borodin <amborodin86@gmail.com> wrote:

On Tue, Jan 3, 2023 at 5:02 AM vignesh C <vignesh21@gmail.com> wrote:

does not apply on top of HEAD as in [1], please post a rebased patch:

Thanks! Here's the rebase.

I was looking into this patch, it seems like three different
optimizations are squeezed in a single patch
1) dividing buffer space in banks to reduce the seq search cost 2) guc
parameter for buffer size scale 3) some of the buffer size values are
modified compared to what it is on the head. I think these are 3
patches which should be independently committable.

While looking into the first idea of dividing the buffer space in
banks, I see that it will speed up finding the buffers but OTOH while
searching the victim buffer it will actually can hurt the performance
the slru pages which are frequently accessed are not evenly
distributed across the banks. So imagine the cases where we have some
banks with a lot of empty slots and other banks from which we
frequently have to evict out the pages in order to get the new pages
in.

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

#93Andrey Borodin
amborodin86@gmail.com
In reply to: Dilip Kumar (#92)
Re: MultiXact\SLRU buffers configuration

Hi Dilip! Thank you for the review!

On Tue, Jan 10, 2023 at 9:58 PM Dilip Kumar <dilipbalaut@gmail.com> wrote:

On Mon, Jan 9, 2023 at 9:49 AM Andrey Borodin <amborodin86@gmail.com> wrote:

On Tue, Jan 3, 2023 at 5:02 AM vignesh C <vignesh21@gmail.com> wrote:

does not apply on top of HEAD as in [1], please post a rebased patch:

Thanks! Here's the rebase.

I was looking into this patch, it seems like three different
optimizations are squeezed in a single patch
1) dividing buffer space in banks to reduce the seq search cost 2) guc
parameter for buffer size scale 3) some of the buffer size values are
modified compared to what it is on the head. I think these are 3
patches which should be independently committable.

There's no point in dividing SLRU buffers in parts unless the buffer's
size is configurable.
And it's only possible to enlarge default buffers size if SLRU buffers
are divided into banks.
So the features can be viewed as independent commits, but make no
sense separately.

But, probably, it's a good idea to split the patch back anyway, for
easier review.

While looking into the first idea of dividing the buffer space in
banks, I see that it will speed up finding the buffers but OTOH while
searching the victim buffer it will actually can hurt the performance
the slru pages which are frequently accessed are not evenly
distributed across the banks. So imagine the cases where we have some
banks with a lot of empty slots and other banks from which we
frequently have to evict out the pages in order to get the new pages
in.

Yes. Despite the extremely low probability of such a case, this
pattern when a user accesses pages assigned to only one bank may
happen.
This case is equivalent to having just one bank, which means small
buffers. Just as we have now.

Thank you!

Best regards, Andrey Borodin.

#94vignesh C
vignesh21@gmail.com
In reply to: Andrey Borodin (#91)
Re: MultiXact\SLRU buffers configuration

On Mon, 9 Jan 2023 at 09:49, Andrey Borodin <amborodin86@gmail.com> wrote:

On Tue, Jan 3, 2023 at 5:02 AM vignesh C <vignesh21@gmail.com> wrote:

does not apply on top of HEAD as in [1], please post a rebased patch:

Thanks! Here's the rebase.

I'm seeing that there has been no activity in this thread for more
than 1 year now, I'm planning to close this in the current commitfest
unless someone is planning to take it forward.

Regards,
Vignesh

#95Andrey Borodin
x4mmm@yandex-team.ru
In reply to: vignesh C (#94)
Re: MultiXact\SLRU buffers configuration

On 20 Jan 2024, at 08:31, vignesh C <vignesh21@gmail.com> wrote:

On Mon, 9 Jan 2023 at 09:49, Andrey Borodin <amborodin86@gmail.com> wrote:

On Tue, Jan 3, 2023 at 5:02 AM vignesh C <vignesh21@gmail.com> wrote:

does not apply on top of HEAD as in [1], please post a rebased patch:

Thanks! Here's the rebase.

I'm seeing that there has been no activity in this thread for more
than 1 year now, I'm planning to close this in the current commitfest
unless someone is planning to take it forward.

Hi Vignesh,

thanks for the ping! Most important parts of this patch set are discussed in [0]/messages/by-id/CAFiTN-vzDvNz=ExGXz6gdyjtzGixKSqs0mKHMmaQ8sOSEFZ33A@mail.gmail.com. If that patchset will be committed, I'll withdraw entry for this thread from commitfest.
There's a version of Multixact-specific optimizations [1]/messages/by-id/2ECE132B-C042-4489-930E-DBC5D0DAB84A@yandex-team.ru, but I hope they will not be necessary with effective caches developed in [0]/messages/by-id/CAFiTN-vzDvNz=ExGXz6gdyjtzGixKSqs0mKHMmaQ8sOSEFZ33A@mail.gmail.com. It seems to me that most important part of those optimization is removing sleeps under SLRU lock on standby [2]/messages/by-id/20200515.090333.24867479329066911.horikyota.ntt@gmail.com by Kyotaro Horiguchi. But given that cache optimizations took 4 years to get closer to commit, I'm not sure we will get this optimization any time soon...

Thanks!

Best regards, Andrey Borodin.

[0]: /messages/by-id/CAFiTN-vzDvNz=ExGXz6gdyjtzGixKSqs0mKHMmaQ8sOSEFZ33A@mail.gmail.com
[1]: /messages/by-id/2ECE132B-C042-4489-930E-DBC5D0DAB84A@yandex-team.ru
[2]: /messages/by-id/20200515.090333.24867479329066911.horikyota.ntt@gmail.com

#96Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Andrey Borodin (#95)
Re: MultiXact\SLRU buffers configuration

On 2024-Jan-27, Andrey Borodin wrote:

thanks for the ping! Most important parts of this patch set are discussed in [0]. If that patchset will be committed, I'll withdraw entry for this thread from commitfest.
There's a version of Multixact-specific optimizations [1], but I hope they will not be necessary with effective caches developed in [0]. It seems to me that most important part of those optimization is removing sleeps under SLRU lock on standby [2] by Kyotaro Horiguchi. But given that cache optimizations took 4 years to get closer to commit, I'm not sure we will get this optimization any time soon...

I'd appreciate it if you or Horiguchi-san can update his patch to remove
use of usleep in favor of a CV in multixact, and keep this CF entry to
cover it.

Perhaps a test to make the code reach the usleep(1000) can be written
using injection points (49cd2b93d7db)?

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"La experiencia nos dice que el hombre peló millones de veces las patatas,
pero era forzoso admitir la posibilidad de que en un caso entre millones,
las patatas pelarían al hombre" (Ijon Tichy)

#97Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Alvaro Herrera (#96)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

On 28 Jan 2024, at 17:49, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

I'd appreciate it if you or Horiguchi-san can update his patch to remove
use of usleep in favor of a CV in multixact, and keep this CF entry to
cover it.

Sure! Sounds great!

Perhaps a test to make the code reach the usleep(1000) can be written
using injection points (49cd2b93d7db)?

I've tried to prototype something like that. But interesting point between GetNewMultiXactId() and RecordNewMultiXact() is a critical section, and we cannot have injection points in critical sections...
Also, to implement such a test we need "wait" type of injection points, see step 2 in attachment. With this type of injection points I can stop a backend amidst entering information about new MultiXact.

Best regards, Andrey Borodin.

Attachments:

0001-Add-conditional-variable-to-wait-for-next-MultXact-o.patchapplication/octet-stream; name=0001-Add-conditional-variable-to-wait-for-next-MultXact-o.patch; x-unix-mode=0644Download
From 975eb3448acbec97c14d48f21261e44aca7b3acc Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Fri, 22 May 2020 14:13:33 +0500
Subject: [PATCH 1/3] Add conditional variable to wait for next MultXact offset
 in edge case

---
 src/backend/access/transam/multixact.c        | 23 ++++++++++++++++++-
 .../utils/activity/wait_event_names.txt       |  1 +
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 59523be901..03fcd25d4c 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,7 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	ConditionVariable nextoff_cv;
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -894,6 +896,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
 
+	/*
+	 *  Let everybody know the offset of this mxid is recorded now. The waiters
+	 *  are waiting for the offset of the mxid next of the target to know the
+	 *  number of members of the target mxid, so we don't need to wait for
+	 *  members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoff_cv);
+
 	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1388,9 +1398,19 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the offset.
+			 * Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoff_cv);
+
 			LWLockRelease(MultiXactOffsetSLRULock);
 			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoff_cv,
+								   WAIT_EVENT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1875,6 +1895,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoff_cv);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/utils/activity/wait_event_names.txt b/src/backend/utils/activity/wait_event_names.txt
index a5df835dd4..1bb78d5aad 100644
--- a/src/backend/utils/activity/wait_event_names.txt
+++ b/src/backend/utils/activity/wait_event_names.txt
@@ -144,6 +144,7 @@ SYNC_REP	"Waiting for confirmation from a remote server during synchronous repli
 WAL_RECEIVER_EXIT	"Waiting for the WAL receiver to exit."
 WAL_RECEIVER_WAIT_START	"Waiting for startup process to send initial data for streaming replication."
 WAL_SUMMARY_READY	"Waiting for a new WAL summary to be generated."
+NEXT_MXMEMBERS	"Waiting for a next multixact member to be filled."
 XACT_GROUP_UPDATE	"Waiting for the group leader to update transaction status at end of a parallel operation."
 
 
-- 
2.37.1 (Apple Git-137.1)

0002-Add-wait-type-for-injection-points.patchapplication/octet-stream; name=0002-Add-wait-type-for-injection-points.patch; x-unix-mode=0644Download
From 93b4c7dac290d6d2d212522b1a10fef03372315e Mon Sep 17 00:00:00 2001
From: "Andrey M. Borodin" <x4mmm@night.local>
Date: Sun, 28 Jan 2024 22:22:22 +0500
Subject: [PATCH 2/3] Add wait type for injection points

---
 src/backend/utils/misc/injection_point.c      | 20 +++++++++++++++++++
 src/include/utils/injection_point.h           |  1 +
 src/test/modules/injection_points/Makefile    |  1 +
 .../injection_points/injection_points.c       | 16 +++++++++++++++
 4 files changed, 38 insertions(+)

diff --git a/src/backend/utils/misc/injection_point.c b/src/backend/utils/misc/injection_point.c
index 0cf4d51cac..398ef2cf30 100644
--- a/src/backend/utils/misc/injection_point.c
+++ b/src/backend/utils/misc/injection_point.c
@@ -252,6 +252,26 @@ InjectionPointDetach(const char *name)
 #endif
 }
 
+/*
+ * Test if injection point is attached.
+ */
+bool
+InjectionPointIsAttach(const char *name)
+{
+#ifdef USE_INJECTION_POINTS
+	bool		found;
+
+	LWLockAcquire(InjectionPointLock, LW_EXCLUSIVE);
+	hash_search(InjectionPointHash, name, HASH_FIND, &found);
+	LWLockRelease(InjectionPointLock);
+
+	return found;
+
+#else
+	elog(ERROR, "Injection points are not supported by this build");
+#endif
+}
+
 /*
  * Execute an injection point, if defined.
  *
diff --git a/src/include/utils/injection_point.h b/src/include/utils/injection_point.h
index 55524b568f..e07f6b7024 100644
--- a/src/include/utils/injection_point.h
+++ b/src/include/utils/injection_point.h
@@ -33,5 +33,6 @@ extern void InjectionPointAttach(const char *name,
 								 const char *function);
 extern void InjectionPointRun(const char *name);
 extern void InjectionPointDetach(const char *name);
+extern bool InjectionPointIsAttach(const char *name);
 
 #endif							/* INJECTION_POINT_H */
diff --git a/src/test/modules/injection_points/Makefile b/src/test/modules/injection_points/Makefile
index 2cbbae4e0a..543d2ab927 100644
--- a/src/test/modules/injection_points/Makefile
+++ b/src/test/modules/injection_points/Makefile
@@ -7,6 +7,7 @@ DATA = injection_points--1.0.sql
 PGFILEDESC = "injection_points - facility for injection points"
 
 REGRESS = injection_points
+TAP_TESTS = 1
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index e843e6594f..fbb30b15ad 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -18,6 +18,7 @@
 #include "postgres.h"
 
 #include "fmgr.h"
+#include "miscadmin.h"
 #include "storage/lwlock.h"
 #include "storage/shmem.h"
 #include "utils/builtins.h"
@@ -28,6 +29,7 @@ PG_MODULE_MAGIC;
 
 extern PGDLLEXPORT void injection_error(const char *name);
 extern PGDLLEXPORT void injection_notice(const char *name);
+extern PGDLLEXPORT void injection_wait(const char *name);
 
 
 /* Set of callbacks available to be attached to an injection point. */
@@ -43,6 +45,18 @@ injection_notice(const char *name)
 	elog(NOTICE, "notice triggered for injection point %s", name);
 }
 
+void
+injection_wait(const char *name)
+{
+	elog(NOTICE, "waiting triggered for injection point %s", name);
+	do
+	{
+		CHECK_FOR_INTERRUPTS();
+		pg_usleep(1000L);
+	} while (InjectionPointIsAttach(name));
+	elog(NOTICE, "waiting done for injection point %s", name);
+}
+
 /*
  * SQL function for creating an injection point.
  */
@@ -58,6 +72,8 @@ injection_points_attach(PG_FUNCTION_ARGS)
 		function = "injection_error";
 	else if (strcmp(action, "notice") == 0)
 		function = "injection_notice";
+	else if (strcmp(action, "wait") == 0)
+		function = "injection_wait";
 	else
 		elog(ERROR, "incorrect action \"%s\" for injection point creation", action);
 
-- 
2.37.1 (Apple Git-137.1)

0003-Try-to-test-multixact-CV-sleep.patchapplication/octet-stream; name=0003-Try-to-test-multixact-CV-sleep.patch; x-unix-mode=0644Download
From a61958407770b6cb864e0b245a4341e033824f46 Mon Sep 17 00:00:00 2001
From: "Andrey M. Borodin" <x4mmm@night.local>
Date: Sun, 28 Jan 2024 23:10:55 +0500
Subject: [PATCH 3/3] Try to test multixact CV sleep

---
 src/backend/access/transam/multixact.c        |  5 ++
 .../injection_points--1.0.sql                 | 11 ++++
 .../injection_points/injection_points.c       | 26 ++++++++
 .../modules/injection_points/t/001_wait.pl    | 64 +++++++++++++++++++
 4 files changed, 106 insertions(+)
 create mode 100644 src/test/modules/injection_points/t/001_wait.pl

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 03fcd25d4c..15b2a0010a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -89,6 +89,7 @@
 #include "storage/proc.h"
 #include "storage/procarray.h"
 #include "utils/builtins.h"
+#include "utils/injection_point.h"
 #include "utils/memutils.h"
 #include "utils/snapmgr.h"
 
@@ -1200,6 +1201,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
 
 	LWLockRelease(MultiXactGenLock);
 
+	INJECTION_POINT("GetNewMultiXactId-done");
+
 	debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
 	return result;
 }
@@ -1408,6 +1411,8 @@ retry:
 			LWLockRelease(MultiXactOffsetSLRULock);
 			CHECK_FOR_INTERRUPTS();
 
+			INJECTION_POINT("GetMultiXactIdMembers-CV-sleep");
+
 			ConditionVariableSleep(&MultiXactState->nextoff_cv,
 								   WAIT_EVENT_NEXT_MXMEMBERS);
 			ConditionVariableCancelSleep();
diff --git a/src/test/modules/injection_points/injection_points--1.0.sql b/src/test/modules/injection_points/injection_points--1.0.sql
index 5944c41716..d3ebda5964 100644
--- a/src/test/modules/injection_points/injection_points--1.0.sql
+++ b/src/test/modules/injection_points/injection_points--1.0.sql
@@ -33,3 +33,14 @@ CREATE FUNCTION injection_points_detach(IN point_name TEXT)
 RETURNS void
 AS 'MODULE_PATHNAME', 'injection_points_detach'
 LANGUAGE C STRICT PARALLEL UNSAFE;
+
+
+CREATE FUNCTION create_test_multixact()
+RETURNS xid
+AS 'MODULE_PATHNAME', 'create_test_multixact'
+LANGUAGE C STRICT PARALLEL UNSAFE;
+
+CREATE FUNCTION read_test_multixact(xid)
+RETURNS void
+AS 'MODULE_PATHNAME', 'read_test_multixact'
+LANGUAGE C STRICT PARALLEL UNSAFE;
\ No newline at end of file
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index fbb30b15ad..d3d5faaa25 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -109,3 +109,29 @@ injection_points_detach(PG_FUNCTION_ARGS)
 
 	PG_RETURN_VOID();
 }
+
+#include "access/multixact.h"
+#include "access/xact.h"
+
+PG_FUNCTION_INFO_V1(create_test_multixact);
+Datum
+create_test_multixact(PG_FUNCTION_ARGS)
+{
+	MultiXactId id;
+	MultiXactIdSetOldestMember();
+	id = MultiXactIdCreate(GetCurrentTransactionId(), MultiXactStatusUpdate,
+						GetCurrentTransactionId(), MultiXactStatusForShare);
+	PG_RETURN_TRANSACTIONID(id);
+}
+
+PG_FUNCTION_INFO_V1(read_test_multixact);
+Datum
+read_test_multixact(PG_FUNCTION_ARGS)
+{
+	MultiXactId id = PG_GETARG_TRANSACTIONID(0);
+	MultiXactMember *members;
+	INJECTION_POINT("read_test_multixact");
+	if (GetMultiXactIdMembers(id,&members,false, false) == -1)
+		elog(ERROR, "MultiXactId not found");
+	PG_RETURN_VOID();
+}
\ No newline at end of file
diff --git a/src/test/modules/injection_points/t/001_wait.pl b/src/test/modules/injection_points/t/001_wait.pl
new file mode 100644
index 0000000000..6076ffc6ea
--- /dev/null
+++ b/src/test/modules/injection_points/t/001_wait.pl
@@ -0,0 +1,64 @@
+
+# Copyright (c) 2024, PostgreSQL Global Development Group
+
+use strict;
+use warnings FATAL => 'all';
+
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+
+use Test::More;
+
+my ($node, $result);
+
+$node = PostgreSQL::Test::Cluster->new('injection_points');
+$node->init;
+$node->start;
+$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
+
+$result = $node->psql('postgres', q(select injection_points_attach('FIRST','wait')));
+is($result, '0', 'wait injection point set');
+
+my $bg = $node->background_psql('postgres');
+
+$bg->query_until(
+	qr/start/, q(
+\echo start
+select injection_points_run('FIRST');
+select injection_points_attach('SECOND','wait');
+));
+
+$result = $node->psql('postgres', q(
+select injection_points_run('SECOND');
+select injection_points_detach('FIRST');
+));
+is($result, '0', 'wait injection point set');
+
+$bg->quit;
+
+$node->safe_psql('postgres', q(select injection_points_attach('read_test_multixact','wait')));
+$node->safe_psql('postgres', q(select injection_points_attach('GetMultiXactIdMembers-CV-sleep','notice')));
+
+my $observer = $node->background_psql('postgres');
+
+$observer->query_safe(
+	q(
+select read_test_multixact(create_test_multixact());
+));
+
+$node->safe_psql('postgres', q(select injection_points_attach('GetNewMultiXactId-done','wait')));
+
+my $creator = $node->background_psql('postgres');
+
+$creator->query_safe( q(select create_test_multixact();));
+
+$node->safe_psql('postgres', q(select injection_points_detach('read_test_multixact')));
+
+$node->safe_psql('postgres', q(select injection_points_detach('GetNewMultiXactId-done')));
+
+$observer->quit;
+
+$creator->quit;
+
+$node->stop;
+done_testing();
-- 
2.37.1 (Apple Git-137.1)

#98Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Andrey M. Borodin (#97)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

On 28 Jan 2024, at 23:17, Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:

Perhaps a test to make the code reach the usleep(1000) can be written
using injection points (49cd2b93d7db)?

I've tried to prototype something like that. But interesting point between GetNewMultiXactId() and RecordNewMultiXact() is a critical section, and we cannot have injection points in critical sections...
Also, to implement such a test we need "wait" type of injection points, see step 2 in attachment. With this type of injection points I can stop a backend amidst entering information about new MultiXact.

Here's the test draft. This test reliably reproduces sleep on CV when waiting next multixact to be filled into "members" SLRU.
Cost of having this test:
1. We need a new injection point type "wait" (in addition to "error" and "notice"). It cannot be avoided, because we need to sync at least 3 processed to observe condition we want.
2. We need new way to declare injection point that can happen inside critical section. I've called it "prepared injection point".

Complexity of having this test is higher than complexity of CV-sleep patch itself. Do we want it? If so I can produce cleaner version, currently all multixact tests are int injection_points test module.

Best regards, Andrey Borodin.

Attachments:

v2-0003-Test-multixact-CV-sleep.patchapplication/octet-stream; name=v2-0003-Test-multixact-CV-sleep.patch; x-unix-mode=0644Download
From 51ba2eadfd2a4f56130d026febb939ecdaa0ea91 Mon Sep 17 00:00:00 2001
From: "Andrey M. Borodin" <x4mmm@night.local>
Date: Sun, 28 Jan 2024 23:10:55 +0500
Subject: [PATCH v2 3/3] Test multixact CV sleep

---
 src/backend/access/transam/multixact.c        |  7 ++
 src/backend/utils/misc/injection_point.c      | 73 +++++++++++++++++++
 src/include/utils/injection_point.h           |  6 ++
 .../injection_points--1.0.sql                 | 11 +++
 .../injection_points/injection_points.c       | 29 ++++++++
 .../modules/injection_points/t/001_wait.pl    | 43 +++++++++++
 6 files changed, 169 insertions(+)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 03fcd25d4c..363a8bb1d7 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -89,6 +89,7 @@
 #include "storage/proc.h"
 #include "storage/procarray.h"
 #include "utils/builtins.h"
+#include "utils/injection_point.h"
 #include "utils/memutils.h"
 #include "utils/snapmgr.h"
 
@@ -822,8 +823,12 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
 	 * in vacuum.  During vacuum, in particular, it would be unacceptable to
 	 * keep OldestMulti set, in case it runs for long.
 	 */
+	INJECTION_POINT_PREPARE("GetNewMultiXactId-done");
+
 	multi = GetNewMultiXactId(nmembers, &offset);
 
+	INJECTION_POINT_RUN_PREPARED();
+
 	/* Make an XLOG entry describing the new MXID. */
 	xlrec.mid = multi;
 	xlrec.moff = offset;
@@ -1408,6 +1413,8 @@ retry:
 			LWLockRelease(MultiXactOffsetSLRULock);
 			CHECK_FOR_INTERRUPTS();
 
+			INJECTION_POINT("GetMultiXactIdMembers-CV-sleep");
+
 			ConditionVariableSleep(&MultiXactState->nextoff_cv,
 								   WAIT_EVENT_NEXT_MXMEMBERS);
 			ConditionVariableCancelSleep();
diff --git a/src/backend/utils/misc/injection_point.c b/src/backend/utils/misc/injection_point.c
index 398ef2cf30..c021889138 100644
--- a/src/backend/utils/misc/injection_point.c
+++ b/src/backend/utils/misc/injection_point.c
@@ -335,3 +335,76 @@ InjectionPointRun(const char *name)
 	elog(ERROR, "Injection points are not supported by this build");
 #endif
 }
+
+InjectionPointCallback prepared_injection_callback = NULL;
+const char* prepared_injection_callback_name;
+
+void
+InjectionPointPrepare(const char *name)
+{
+#ifdef USE_INJECTION_POINTS
+	InjectionPointEntry *entry_by_name;
+	bool		found;
+	Assert(prepared_injection_callback == NULL);
+
+	LWLockAcquire(InjectionPointLock, LW_SHARED);
+	entry_by_name = (InjectionPointEntry *)
+		hash_search(InjectionPointHash, name,
+					HASH_FIND, &found);
+	LWLockRelease(InjectionPointLock);
+
+	/*
+	 * If not found, do nothing and remove it from the local cache if it
+	 * existed there.
+	 */
+	if (!found)
+	{
+		injection_point_cache_remove(name);
+		return;
+	}
+
+	/*
+	 * Check if the callback exists in the local cache, to avoid unnecessary
+	 * external loads.
+	 */
+	prepared_injection_callback = injection_point_cache_get(name);
+	if (prepared_injection_callback == NULL)
+	{
+		char		path[MAXPGPATH];
+
+		/* not found in local cache, so load and register */
+		snprintf(path, MAXPGPATH, "%s/%s%s", pkglib_path,
+				 entry_by_name->library, DLSUFFIX);
+
+		if (!pg_file_exists(path))
+			elog(ERROR, "could not find library \"%s\" for injection point \"%s\"",
+				 path, name);
+
+		prepared_injection_callback = (InjectionPointCallback)
+			load_external_function(path, entry_by_name->function, false, NULL);
+
+		if (prepared_injection_callback == NULL)
+			elog(ERROR, "could not find function \"%s\" in library \"%s\" for injection point \"%s\"",
+				 entry_by_name->function, path, name);
+
+		/* add it to the local cache when found */
+		injection_point_cache_add(name, prepared_injection_callback);
+	}
+
+	prepared_injection_callback_name = name;
+#else
+	elog(ERROR, "Injection points are not supported by this build");
+#endif
+}
+
+void
+InjectionPointRunPrepared()
+{
+#ifdef USE_INJECTION_POINTS
+	if (prepared_injection_callback != NULL)
+		prepared_injection_callback(prepared_injection_callback_name);
+	prepared_injection_callback = NULL;
+#else
+	elog(ERROR, "Injection points are not supported by this build");
+#endif
+}
diff --git a/src/include/utils/injection_point.h b/src/include/utils/injection_point.h
index e07f6b7024..73d3aeac8a 100644
--- a/src/include/utils/injection_point.h
+++ b/src/include/utils/injection_point.h
@@ -16,8 +16,12 @@
  */
 #ifdef USE_INJECTION_POINTS
 #define INJECTION_POINT(name) InjectionPointRun(name)
+#define INJECTION_POINT_PREPARE(name) InjectionPointPrepare(name)
+#define INJECTION_POINT_RUN_PREPARED() InjectionPointRunPrepared()
 #else
 #define INJECTION_POINT(name) ((void) name)
+#define INJECTION_POINT_PREPARE(name) ((void) name)
+#define INJECTION_POINT_RUN_PREPARED()
 #endif
 
 /*
@@ -34,5 +38,7 @@ extern void InjectionPointAttach(const char *name,
 extern void InjectionPointRun(const char *name);
 extern void InjectionPointDetach(const char *name);
 extern bool InjectionPointIsAttach(const char *name);
+extern void InjectionPointPrepare(const char *name);
+extern void InjectionPointRunPrepared(void);
 
 #endif							/* INJECTION_POINT_H */
diff --git a/src/test/modules/injection_points/injection_points--1.0.sql b/src/test/modules/injection_points/injection_points--1.0.sql
index 5944c41716..d3ebda5964 100644
--- a/src/test/modules/injection_points/injection_points--1.0.sql
+++ b/src/test/modules/injection_points/injection_points--1.0.sql
@@ -33,3 +33,14 @@ CREATE FUNCTION injection_points_detach(IN point_name TEXT)
 RETURNS void
 AS 'MODULE_PATHNAME', 'injection_points_detach'
 LANGUAGE C STRICT PARALLEL UNSAFE;
+
+
+CREATE FUNCTION create_test_multixact()
+RETURNS xid
+AS 'MODULE_PATHNAME', 'create_test_multixact'
+LANGUAGE C STRICT PARALLEL UNSAFE;
+
+CREATE FUNCTION read_test_multixact(xid)
+RETURNS void
+AS 'MODULE_PATHNAME', 'read_test_multixact'
+LANGUAGE C STRICT PARALLEL UNSAFE;
\ No newline at end of file
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index fbb30b15ad..a0b9379886 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -109,3 +109,32 @@ injection_points_detach(PG_FUNCTION_ARGS)
 
 	PG_RETURN_VOID();
 }
+
+#include "access/multixact.h"
+#include "access/xact.h"
+
+PG_FUNCTION_INFO_V1(create_test_multixact);
+Datum
+create_test_multixact(PG_FUNCTION_ARGS)
+{
+	MultiXactId id;
+	MultiXactIdSetOldestMember();
+	id = MultiXactIdCreate(GetCurrentTransactionId(), MultiXactStatusUpdate,
+						GetCurrentTransactionId(), MultiXactStatusForShare);
+	PG_RETURN_TRANSACTIONID(id);
+}
+
+PG_FUNCTION_INFO_V1(read_test_multixact);
+Datum
+read_test_multixact(PG_FUNCTION_ARGS)
+{
+	MultiXactId id = PG_GETARG_TRANSACTIONID(0);
+	MultiXactMember *members;
+	INJECTION_POINT("read_test_multixact");
+	/* discard caches */
+	AtEOXact_MultiXact();
+
+	if (GetMultiXactIdMembers(id,&members,false, false) == -1)
+		elog(ERROR, "MultiXactId not found");
+	PG_RETURN_VOID();
+}
\ No newline at end of file
diff --git a/src/test/modules/injection_points/t/001_wait.pl b/src/test/modules/injection_points/t/001_wait.pl
index 98f7a8bcef..448dc97759 100644
--- a/src/test/modules/injection_points/t/001_wait.pl
+++ b/src/test/modules/injection_points/t/001_wait.pl
@@ -36,5 +36,48 @@ is($result, '0', 'wait injection point set');
 
 $bg->quit;
 
+# Test for Multixact generation edge case
+$node->safe_psql('postgres', q(select injection_points_attach('read_test_multixact','wait')));
+$node->safe_psql('postgres', q(select injection_points_attach('GetMultiXactIdMembers-CV-sleep','notice')));
+
+# This session must observe sleep on CV when generating multixact.
+# To achive this it first will create a multixact, then pause before reading it.
+my $observer = $node->background_psql('postgres');
+
+$observer->query_until(qr/start/,
+q(
+	\echo start
+	select read_test_multixact(create_test_multixact());
+));
+
+# This session will create next Multixact, it's necessary to avoid edge case 1 (see multixact.c)
+my $creator = $node->background_psql('postgres');
+$node->safe_psql('postgres', q(select injection_points_attach('GetNewMultiXactId-done','wait')));
+
+# We expect this query to hand in critical section after generating new multixact,
+# but before filling it's offset into SLRU
+$creator->query_until(qr/start/, q(
+	\echo start
+	select create_test_multixact();
+));
+
+# Now we are sure we can reach edge case 2. Proceed session that is reading that multixact.
+$node->safe_psql('postgres', q(select injection_points_detach('read_test_multixact')));
+
+# Release critical section. We have to do this so everyon can proceed.
+# But this is inherent race condition, I hope the tast will not be unstable here.
+# The only way to stabilize it will be adding some sleep here.
+$node->safe_psql('postgres', q(select injection_points_detach('GetNewMultiXactId-done')));
+
+# Here goes the whole purpose of this test: see that sleep in fact occured.
+ok( pump_until(
+		$observer->{run}, $observer->{timeout},
+		\$observer->{stderr}, qr/notice triggered for injection point GetMultiXactIdMembers-CV-sleep/),
+	"sleep observed");
+
+$observer->quit;
+
+$creator->quit;
+
 $node->stop;
 done_testing();
-- 
2.37.1 (Apple Git-137.1)

v2-0002-Add-wait-type-for-injection-points.patchapplication/octet-stream; name=v2-0002-Add-wait-type-for-injection-points.patch; x-unix-mode=0644Download
From 0924b7cc9f1a516df710677b246d26226cd01624 Mon Sep 17 00:00:00 2001
From: "Andrey M. Borodin" <x4mmm@night.local>
Date: Sun, 28 Jan 2024 22:22:22 +0500
Subject: [PATCH v2 2/3] Add wait type for injection points

---
 src/backend/utils/misc/injection_point.c      | 20 ++++++++++
 src/include/utils/injection_point.h           |  1 +
 src/test/modules/injection_points/Makefile    |  1 +
 .../injection_points/injection_points.c       | 16 ++++++++
 .../modules/injection_points/t/001_wait.pl    | 40 +++++++++++++++++++
 5 files changed, 78 insertions(+)
 create mode 100644 src/test/modules/injection_points/t/001_wait.pl

diff --git a/src/backend/utils/misc/injection_point.c b/src/backend/utils/misc/injection_point.c
index 0cf4d51cac..398ef2cf30 100644
--- a/src/backend/utils/misc/injection_point.c
+++ b/src/backend/utils/misc/injection_point.c
@@ -252,6 +252,26 @@ InjectionPointDetach(const char *name)
 #endif
 }
 
+/*
+ * Test if injection point is attached.
+ */
+bool
+InjectionPointIsAttach(const char *name)
+{
+#ifdef USE_INJECTION_POINTS
+	bool		found;
+
+	LWLockAcquire(InjectionPointLock, LW_EXCLUSIVE);
+	hash_search(InjectionPointHash, name, HASH_FIND, &found);
+	LWLockRelease(InjectionPointLock);
+
+	return found;
+
+#else
+	elog(ERROR, "Injection points are not supported by this build");
+#endif
+}
+
 /*
  * Execute an injection point, if defined.
  *
diff --git a/src/include/utils/injection_point.h b/src/include/utils/injection_point.h
index 55524b568f..e07f6b7024 100644
--- a/src/include/utils/injection_point.h
+++ b/src/include/utils/injection_point.h
@@ -33,5 +33,6 @@ extern void InjectionPointAttach(const char *name,
 								 const char *function);
 extern void InjectionPointRun(const char *name);
 extern void InjectionPointDetach(const char *name);
+extern bool InjectionPointIsAttach(const char *name);
 
 #endif							/* INJECTION_POINT_H */
diff --git a/src/test/modules/injection_points/Makefile b/src/test/modules/injection_points/Makefile
index 2cbbae4e0a..543d2ab927 100644
--- a/src/test/modules/injection_points/Makefile
+++ b/src/test/modules/injection_points/Makefile
@@ -7,6 +7,7 @@ DATA = injection_points--1.0.sql
 PGFILEDESC = "injection_points - facility for injection points"
 
 REGRESS = injection_points
+TAP_TESTS = 1
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index e843e6594f..fbb30b15ad 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -18,6 +18,7 @@
 #include "postgres.h"
 
 #include "fmgr.h"
+#include "miscadmin.h"
 #include "storage/lwlock.h"
 #include "storage/shmem.h"
 #include "utils/builtins.h"
@@ -28,6 +29,7 @@ PG_MODULE_MAGIC;
 
 extern PGDLLEXPORT void injection_error(const char *name);
 extern PGDLLEXPORT void injection_notice(const char *name);
+extern PGDLLEXPORT void injection_wait(const char *name);
 
 
 /* Set of callbacks available to be attached to an injection point. */
@@ -43,6 +45,18 @@ injection_notice(const char *name)
 	elog(NOTICE, "notice triggered for injection point %s", name);
 }
 
+void
+injection_wait(const char *name)
+{
+	elog(NOTICE, "waiting triggered for injection point %s", name);
+	do
+	{
+		CHECK_FOR_INTERRUPTS();
+		pg_usleep(1000L);
+	} while (InjectionPointIsAttach(name));
+	elog(NOTICE, "waiting done for injection point %s", name);
+}
+
 /*
  * SQL function for creating an injection point.
  */
@@ -58,6 +72,8 @@ injection_points_attach(PG_FUNCTION_ARGS)
 		function = "injection_error";
 	else if (strcmp(action, "notice") == 0)
 		function = "injection_notice";
+	else if (strcmp(action, "wait") == 0)
+		function = "injection_wait";
 	else
 		elog(ERROR, "incorrect action \"%s\" for injection point creation", action);
 
diff --git a/src/test/modules/injection_points/t/001_wait.pl b/src/test/modules/injection_points/t/001_wait.pl
new file mode 100644
index 0000000000..98f7a8bcef
--- /dev/null
+++ b/src/test/modules/injection_points/t/001_wait.pl
@@ -0,0 +1,40 @@
+
+# Copyright (c) 2024, PostgreSQL Global Development Group
+
+use strict;
+use warnings FATAL => 'all';
+
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+
+use Test::More;
+
+my ($node, $result);
+
+$node = PostgreSQL::Test::Cluster->new('injection_points');
+$node->init;
+$node->start;
+$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
+
+$result = $node->psql('postgres', q(select injection_points_attach('FIRST','wait')));
+is($result, '0', 'wait injection point set');
+
+my $bg = $node->background_psql('postgres');
+
+$bg->query_until(
+	qr/start/, q(
+\echo start
+select injection_points_run('FIRST');
+select injection_points_attach('SECOND','wait');
+));
+
+$result = $node->psql('postgres', q(
+select injection_points_run('SECOND');
+select injection_points_detach('FIRST');
+));
+is($result, '0', 'wait injection point set');
+
+$bg->quit;
+
+$node->stop;
+done_testing();
-- 
2.37.1 (Apple Git-137.1)

v2-0001-Add-conditional-variable-to-wait-for-next-MultXac.patchapplication/octet-stream; name=v2-0001-Add-conditional-variable-to-wait-for-next-MultXac.patch; x-unix-mode=0644Download
From 975eb3448acbec97c14d48f21261e44aca7b3acc Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Fri, 22 May 2020 14:13:33 +0500
Subject: [PATCH v2 1/3] Add conditional variable to wait for next MultXact
 offset in edge case

---
 src/backend/access/transam/multixact.c        | 23 ++++++++++++++++++-
 .../utils/activity/wait_event_names.txt       |  1 +
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 59523be901..03fcd25d4c 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -82,6 +82,7 @@
 #include "lib/ilist.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
+#include "pgstat.h"
 #include "postmaster/autovacuum.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
@@ -233,6 +234,7 @@ typedef struct MultiXactStateData
 	/* support for members anti-wraparound measures */
 	MultiXactOffset offsetStopLimit;	/* known if oldestOffsetKnown */
 
+	ConditionVariable nextoff_cv;
 	/*
 	 * Per-backend data starts here.  We have two arrays stored in the area
 	 * immediately following the MultiXactStateData struct. Each is indexed by
@@ -894,6 +896,14 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	/* Exchange our lock */
 	LWLockRelease(MultiXactOffsetSLRULock);
 
+	/*
+	 *  Let everybody know the offset of this mxid is recorded now. The waiters
+	 *  are waiting for the offset of the mxid next of the target to know the
+	 *  number of members of the target mxid, so we don't need to wait for
+	 *  members of this mxid are recorded.
+	 */
+	ConditionVariableBroadcast(&MultiXactState->nextoff_cv);
+
 	LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
 
 	prev_pageno = -1;
@@ -1388,9 +1398,19 @@ retry:
 		if (nextMXOffset == 0)
 		{
 			/* Corner case 2: next multixact is still being filled in */
+
+			/*
+			 * The recorder of the next mxid is just before writing the offset.
+			 * Wait for the offset to be written.
+			 */
+			ConditionVariablePrepareToSleep(&MultiXactState->nextoff_cv);
+
 			LWLockRelease(MultiXactOffsetSLRULock);
 			CHECK_FOR_INTERRUPTS();
-			pg_usleep(1000L);
+
+			ConditionVariableSleep(&MultiXactState->nextoff_cv,
+								   WAIT_EVENT_NEXT_MXMEMBERS);
+			ConditionVariableCancelSleep();
 			goto retry;
 		}
 
@@ -1875,6 +1895,7 @@ MultiXactShmemInit(void)
 
 		/* Make sure we zero out the per-backend state */
 		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		ConditionVariableInit(&MultiXactState->nextoff_cv);
 	}
 	else
 		Assert(found);
diff --git a/src/backend/utils/activity/wait_event_names.txt b/src/backend/utils/activity/wait_event_names.txt
index a5df835dd4..1bb78d5aad 100644
--- a/src/backend/utils/activity/wait_event_names.txt
+++ b/src/backend/utils/activity/wait_event_names.txt
@@ -144,6 +144,7 @@ SYNC_REP	"Waiting for confirmation from a remote server during synchronous repli
 WAL_RECEIVER_EXIT	"Waiting for the WAL receiver to exit."
 WAL_RECEIVER_WAIT_START	"Waiting for startup process to send initial data for streaming replication."
 WAL_SUMMARY_READY	"Waiting for a new WAL summary to be generated."
+NEXT_MXMEMBERS	"Waiting for a next multixact member to be filled."
 XACT_GROUP_UPDATE	"Waiting for the group leader to update transaction status at end of a parallel operation."
 
 
-- 
2.37.1 (Apple Git-137.1)

#99Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Andrey M. Borodin (#98)
Re: MultiXact\SLRU buffers configuration

At Sat, 3 Feb 2024 22:32:45 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

Here's the test draft. This test reliably reproduces sleep on CV when waiting next multixact to be filled into "members" SLRU.

By the way, I raised a question about using multiple CVs
simultaneously [1]/messages/by-id/20240227.150709.1766217736683815840.horikyota.ntt@gmail.com. That is, I suspect that the current CV
implementation doesn't allow us to use multiple condition variables at
the same time, because all CVs use the same PCPROC member cvWaitLink
to accommodate different waiter sets. If this assumption is correct,
we should resolve the issue before spreading more uses of CVs.

[1]: /messages/by-id/20240227.150709.1766217736683815840.horikyota.ntt@gmail.com

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#100Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Kyotaro Horiguchi (#99)
Re: MultiXact\SLRU buffers configuration

On 29 Feb 2024, at 06:59, Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote:

At Sat, 3 Feb 2024 22:32:45 +0500, "Andrey M. Borodin" <x4mmm@yandex-team.ru> wrote in

Here's the test draft. This test reliably reproduces sleep on CV when waiting next multixact to be filled into "members" SLRU.

By the way, I raised a question about using multiple CVs
simultaneously [1]. That is, I suspect that the current CV
implementation doesn't allow us to use multiple condition variables at
the same time, because all CVs use the same PCPROC member cvWaitLink
to accommodate different waiter sets. If this assumption is correct,
we should resolve the issue before spreading more uses of CVs.

Alvaro, Kyotaro, what's our plan for this?
It seems to late to deal with this pg_usleep(1000L) for PG17.
I propose following course of action
1. Close this long-standing CF item
2. Start new thread with CV-sleep patch aimed at PG18
3. Create new entry in July CF

What do you think?

Best regards, Andrey Borodin.

#101Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Andrey M. Borodin (#100)
Re: MultiXact\SLRU buffers configuration

On 6 Apr 2024, at 14:24, Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:

What do you think?

OK, I'll follow this plan.
As long as most parts of this thread were committed, I'll mark CF item as "committed".
Thanks to everyone involved!
See you in a followup thread about sleeping on CV.

Best regards, Andrey Borodin.

#102Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Andrey M. Borodin (#98)
Re: MultiXact\SLRU buffers configuration

On 2024-Feb-03, Andrey M. Borodin wrote:

Here's the test draft. This test reliably reproduces sleep on CV when waiting next multixact to be filled into "members" SLRU.
Cost of having this test:
1. We need a new injection point type "wait" (in addition to "error" and "notice"). It cannot be avoided, because we need to sync at least 3 processed to observe condition we want.
2. We need new way to declare injection point that can happen inside critical section. I've called it "prepared injection point".

Complexity of having this test is higher than complexity of CV-sleep patch itself. Do we want it? If so I can produce cleaner version, currently all multixact tests are int injection_points test module.

Well, it would be nice to have *some* test, but as you say it is way
more complex than the thing being tested, and it zooms in on the
functioning of the multixact creation in insane quantum-physics ways ...
to the point that you can no longer trust that multixact works the same
way with the test than without it. So what I did is manually run other
tests (pgbench) to verify that the corner case in multixact creation is
being handled correctly, and pushed the patch after a few corrections,
in particular so that it would follow the CV sleeping protocol a little
more closely to what the CV documentation suggests, which is not at all
what the patch did. I also fixed a few comments that had been neglected
and changed the name and description of the CV in the docs.

Now, maybe we can still add the test later, but it needs a rebase.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
“Cuando no hay humildad las personas se degradan” (A. Christie)

#103Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Alvaro Herrera (#102)
Re: MultiXact\SLRU buffers configuration

On 7 Apr 2024, at 21:41, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

Well, it would be nice to have *some* test, but as you say it is way
more complex than the thing being tested, and it zooms in on the
functioning of the multixact creation in insane quantum-physics ways ...
to the point that you can no longer trust that multixact works the same
way with the test than without it. So what I did is manually run other
tests (pgbench) to verify that the corner case in multixact creation is
being handled correctly, and pushed the patch after a few corrections,
in particular so that it would follow the CV sleeping protocol a little
more closely to what the CV documentation suggests, which is not at all
what the patch did. I also fixed a few comments that had been neglected
and changed the name and description of the CV in the docs.

That's excellent! Thank you!

Now, maybe we can still add the test later, but it needs a rebase.

Sure. 'wait' injection points are there already, so I'll produce patch with "prepared" injection points and re-implement test on top of that. I'll put it on July CF.

Best regards, Andrey Borodin.

#104Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Alvaro Herrera (#102)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

On 5 Jul 2024, at 14:16, Michael Paquier <michael@paquier.xyz> wrote:

On Mon, Jun 10, 2024 at 03:10:33PM +0900, Michael Paquier wrote:

OK, cool. I'll try to get that into the tree once v18 opens up.

And I've spent more time on this one, and applied it to v18 after some
slight tweaks. Please feel free to re-post your tests with
multixacts, Andrey.

Thanks Michael!

On 7 Apr 2024, at 23:41, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

Now, maybe we can still add the test later, but it needs a rebase.

Alvaro, please find attached the test.
I’ve addressed some Michael’s comments in a nearby thread: removed extra load, made injection point names lowercase, fixed some grammar issues.

Best regards, Andrey Borodin.

Attachments:

vJul5-0001-Add-multixact-CV-sleep-test.patchapplication/octet-stream; name=vJul5-0001-Add-multixact-CV-sleep-test.patch; x-unix-mode=0644Download
From 942d44872f6e6a71282127c5e748578c17d720a9 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Mon, 20 May 2024 15:20:31 +0500
Subject: [PATCH vJul5] Add multixact CV sleep test

Previously we used 1ms sleep when we are reading multixact before
another multixact without offset yet. a0e0fb1ba changed this behavior
to CV sleep. This commit adds test for this edge case.
To test such race condition we have to use waiting injection point under
critical section. Such point requires special injection point loading.

Author: Andrey Borodin
Reviewed-by: Michael Paquier
---
 src/backend/access/transam/multixact.c        |  5 +
 src/test/modules/test_slru/Makefile           |  4 +
 src/test/modules/test_slru/meson.build        |  8 ++
 src/test/modules/test_slru/t/001_multixact.pl | 92 +++++++++++++++++++
 src/test/modules/test_slru/test_slru--1.0.sql |  6 ++
 src/test/modules/test_slru/test_slru.c        | 38 ++++++++
 6 files changed, 153 insertions(+)
 create mode 100644 src/test/modules/test_slru/t/001_multixact.pl

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 675affe4f7..36c6ed7883 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -88,6 +88,7 @@
 #include "storage/proc.h"
 #include "storage/procarray.h"
 #include "utils/fmgrprotos.h"
+#include "utils/injection_point.h"
 #include "utils/guc_hooks.h"
 #include "utils/memutils.h"
 
@@ -868,6 +869,8 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
 	 */
 	multi = GetNewMultiXactId(nmembers, &offset);
 
+	INJECTION_POINT("get-new-multixact-id");
+
 	/* Make an XLOG entry describing the new MXID. */
 	xlrec.mid = multi;
 	xlrec.moff = offset;
@@ -1480,6 +1483,8 @@ retry:
 			LWLockRelease(lock);
 			CHECK_FOR_INTERRUPTS();
 
+			INJECTION_POINT("get-multixact-member-cv-sleep");
+
 			ConditionVariableSleep(&MultiXactState->nextoff_cv,
 								   WAIT_EVENT_MULTIXACT_CREATION);
 			slept = true;
diff --git a/src/test/modules/test_slru/Makefile b/src/test/modules/test_slru/Makefile
index 936886753b..8f9623b128 100644
--- a/src/test/modules/test_slru/Makefile
+++ b/src/test/modules/test_slru/Makefile
@@ -6,6 +6,10 @@ OBJS = \
 	test_slru.o
 PGFILEDESC = "test_slru - test module for SLRUs"
 
+EXTRA_INSTALL=src/test/modules/injection_points
+export enable_injection_points enable_injection_points
+TAP_TESTS = 1
+
 EXTENSION = test_slru
 DATA = test_slru--1.0.sql
 
diff --git a/src/test/modules/test_slru/meson.build b/src/test/modules/test_slru/meson.build
index ce91e60631..4a5bc6349a 100644
--- a/src/test/modules/test_slru/meson.build
+++ b/src/test/modules/test_slru/meson.build
@@ -32,4 +32,12 @@ tests += {
     'regress_args': ['--temp-config', files('test_slru.conf')],
     'runningcheck': false,
   },
+  'tap': {
+    'env': {
+       'enable_injection_points': get_option('injection_points') ? 'yes' : 'no',
+    },
+    'tests': [
+      't/001_multixact.pl'
+    ],
+  },
 }
diff --git a/src/test/modules/test_slru/t/001_multixact.pl b/src/test/modules/test_slru/t/001_multixact.pl
new file mode 100644
index 0000000000..4e1ca5e7f4
--- /dev/null
+++ b/src/test/modules/test_slru/t/001_multixact.pl
@@ -0,0 +1,92 @@
+# Copyright (c) 2024, PostgreSQL Global Development Group
+
+# This test verifies edge case of reading a multixact:
+# when we have multixact that is followed by exactly one another multixact,
+# and another multixact have no offset yet, we must wait until this offset
+# becomes observable. Previously we used to wait for 1ms in a loop in this
+# case, but now we use CV for this. This test is exercising such a sleep.
+
+use strict;
+use warnings FATAL => 'all';
+
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+
+use Test::More;
+
+if ($ENV{enable_injection_points} ne 'yes')
+{
+	plan skip_all => 'Injection points not supported by this build';
+}
+
+my ($node, $result);
+
+$node = PostgreSQL::Test::Cluster->new('multixact_CV_sleep');
+$node->init;
+$node->append_conf('postgresql.conf',
+	"shared_preload_libraries = 'test_slru'");
+$node->start;
+$node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
+$node->safe_psql('postgres', q(CREATE EXTENSION test_slru));
+
+# Test for Multixact generation edge case
+$node->safe_psql('postgres', q(select injection_points_attach('test-read-multixact','wait')));
+$node->safe_psql('postgres', q(select injection_points_attach('get-multixact-member-cv-sleep','wait')));
+
+# This session must observe sleep on CV when generating multixact.
+# To achieve this it first will create a multixact, then pause before reading it.
+my $observer = $node->background_psql('postgres');
+
+# This query will create multixact, and hand just before reading it.
+$observer->query_until(qr/start/,
+q(
+	\echo start
+	select test_read_multixact(test_create_multixact());
+));
+$node->wait_for_event('client backend', 'test-read-multixact');
+
+# This session will create next Multixact, it's necessary to avoid edge case 1
+# (see multixact.c)
+my $creator = $node->background_psql('postgres');
+$node->safe_psql('postgres', q(select injection_points_attach('get-new-multixact-id','wait');));
+
+# We expect this query to hand in critical section after generating new multixact,
+# but before filling it's offset into SLRU.
+# Running injection point under SLRU requires special loading of cache.
+$creator->query_until(qr/start/, q(
+	\echo start
+	select injection_points_load('get-new-multixact-id');
+	select test_create_multixact();
+));
+
+$node->wait_for_event('client backend', 'get-new-multixact-id');
+
+# Now we are sure we can reach edge case 2.
+# Observer is going to read multixact, which has next, but next lacks offset.
+$node->safe_psql('postgres', q(select injection_points_wakeup('test-read-multixact')));
+
+
+$node->wait_for_event('client backend', 'get-multixact-member-cv-sleep');
+
+# Now we have two backends waiting in get-new-multixact-id and
+# get-multixact-member-cv-sleep. Also we have 3 injections points set to wait.
+# If we wakeup get-multixact-member-cv-sleep it will happen again, so we must
+# detach it first. So let's detach all injection points, then wake up all
+# backends.
+
+$node->safe_psql('postgres', q(select injection_points_detach('test-read-multixact')));
+$node->safe_psql('postgres', q(select injection_points_detach('get-new-multixact-id')));
+$node->safe_psql('postgres', q(select injection_points_detach('get-multixact-member-cv-sleep')));
+
+$node->safe_psql('postgres', q(select injection_points_wakeup('get-new-multixact-id')));
+$node->safe_psql('postgres', q(select injection_points_wakeup('get-multixact-member-cv-sleep')));
+
+# Background psql will now be able to read the result and disconnect.
+$observer->quit;
+$creator->quit;
+
+$node->stop;
+
+# If we reached this point - everything is OK.
+ok(1);
+done_testing();
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 202e8da3fd..58300c59a7 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -19,3 +19,9 @@ CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
   AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
 CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
   AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
+
+
+CREATE OR REPLACE FUNCTION test_create_multixact() RETURNS xid
+  AS 'MODULE_PATHNAME', 'test_create_multixact' LANGUAGE C;
+CREATE OR REPLACE FUNCTION test_read_multixact(xid) RETURNS VOID
+  AS 'MODULE_PATHNAME', 'test_read_multixact'LANGUAGE C;
\ No newline at end of file
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index d227b06703..56136bc117 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -14,13 +14,16 @@
 
 #include "postgres.h"
 
+#include "access/multixact.h"
 #include "access/slru.h"
+#include "access/xact.h"
 #include "access/transam.h"
 #include "miscadmin.h"
 #include "storage/fd.h"
 #include "storage/ipc.h"
 #include "storage/shmem.h"
 #include "utils/builtins.h"
+#include "utils/injection_point.h"
 
 PG_MODULE_MAGIC;
 
@@ -36,6 +39,8 @@ PG_FUNCTION_INFO_V1(test_slru_page_sync);
 PG_FUNCTION_INFO_V1(test_slru_page_delete);
 PG_FUNCTION_INFO_V1(test_slru_page_truncate);
 PG_FUNCTION_INFO_V1(test_slru_delete_all);
+PG_FUNCTION_INFO_V1(test_create_multixact);
+PG_FUNCTION_INFO_V1(test_read_multixact);
 
 /* Number of SLRU page slots */
 #define NUM_TEST_BUFFERS		16
@@ -260,3 +265,36 @@ _PG_init(void)
 	prev_shmem_startup_hook = shmem_startup_hook;
 	shmem_startup_hook = test_slru_shmem_startup;
 }
+
+/*
+ * Produces multixact with 2 current xids
+ */
+Datum
+test_create_multixact(PG_FUNCTION_ARGS)
+{
+	MultiXactId id;
+	MultiXactIdSetOldestMember();
+	id = MultiXactIdCreate(GetCurrentTransactionId(), MultiXactStatusUpdate,
+						GetCurrentTransactionId(), MultiXactStatusForShare);
+	PG_RETURN_TRANSACTIONID(id);
+}
+
+/*
+ * Reads given multixact after running an injection point. Discards local cache
+ * to make real read.
+ * This function is expected to be used in conjunction with test_create_multixact
+ * to test CV sleep when reading recent multixact.
+ */
+Datum
+test_read_multixact(PG_FUNCTION_ARGS)
+{
+	MultiXactId id = PG_GETARG_TRANSACTIONID(0);
+	MultiXactMember *members;
+	INJECTION_POINT("test-read-multixact");
+	/* discard caches */
+	AtEOXact_MultiXact();
+
+	if (GetMultiXactIdMembers(id,&members,false, false) == -1)
+		elog(ERROR, "MultiXactId not found");
+	PG_RETURN_VOID();
+}
-- 
2.39.3 (Apple Git-146)

#105Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Andrey M. Borodin (#104)
Re: MultiXact\SLRU buffers configuration

On 5 Jul 2024, at 23:18, Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:

Alvaro, please find attached the test.
I’ve addressed some Michael’s comments in a nearby thread: removed extra load, made injection point names lowercase, fixed some grammar issues.

I’ve made several runs on Github to test stability [0, 1, 2, 4]. CI seems to be stable.

Thanks!

Best regards, Andrey Borodin.

[0]: https://github.com/x4m/postgres_g/commit/c9c362679f244
[1]: https://github.com/x4m/postgres_g/commit/9d7e43cc1
[2]: https://github.com/x4m/postgres_g/commit/18cf186617
[3]: https://github.com/x4m/postgres_g/commit/4fbce73997

#106Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Andrey M. Borodin (#105)
Re: MultiXact\SLRU buffers configuration

On 2024-Aug-19, Andrey M. Borodin wrote:

On 5 Jul 2024, at 23:18, Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:

Alvaro, please find attached the test.
I’ve addressed some Michael’s comments in a nearby thread: removed
extra load, made injection point names lowercase, fixed some grammar
issues.

I’ve made several runs on Github to test stability [0, 1, 2, 4]. CI seems to be stable.

OK, I've made some minor adjustments and pushed. CI seemed OK for me,
let's see what does the BF have to say.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/

#107Michael Paquier
michael@paquier.xyz
In reply to: Alvaro Herrera (#106)
1 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Tue, Aug 20, 2024 at 02:37:34PM -0400, Alvaro Herrera wrote:

OK, I've made some minor adjustments and pushed. CI seemed OK for me,
let's see what does the BF have to say.

I see that you've gone the way with the SQL function doing a load().
Would it be worth switching the test to rely on the two macros for
load and caching instead? I've mentioned that previously but never
got down to present a patch for the sake of this test.

This requires some more tweaks in the module to disable the stats when
loaded through a GUC, and two shmem callbacks, then the test is able
to work correctly. Please see attached.

Thoughts?
--
Michael

Attachments:

0001-Refactor-injection-point-test-with-loading.patchtext/x-diff; charset=us-asciiDownload
From db4b4601a6e930a374f6d03b622f66589d620fe2 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Wed, 21 Aug 2024 08:17:19 +0900
Subject: [PATCH] Refactor injection point test with loading

This relies on the two macros INJECTION_POINT_LOAD and
INJECTION_POINT_CACHED to trigger the test.

This adds to the test module injection_points a GUC to be able to
disable injection point stats, in case a cached point is run in a
critical section, and a code path to initialize the shmem state data of
the module when loading the module.
---
 src/backend/access/transam/multixact.c        |  5 +-
 .../injection_points/injection_points.c       | 80 ++++++++++++++++++-
 .../injection_points/injection_stats.c        |  8 +-
 .../injection_points/injection_stats.h        |  3 +
 .../injection_points/injection_stats_fixed.c  |  4 +-
 src/test/modules/test_slru/t/001_multixact.pl |  5 +-
 6 files changed, 93 insertions(+), 12 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 14c2b929e2..d2d0298ac3 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -855,6 +855,9 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
 		}
 	}
 
+	/* Load the injection point before entering the critical section */
+	INJECTION_POINT_LOAD("multixact-create-from-members");
+
 	/*
 	 * Assign the MXID and offsets range to use, and make sure there is space
 	 * in the OFFSETs and MEMBERs files.  NB: this routine does
@@ -869,7 +872,7 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
 	 */
 	multi = GetNewMultiXactId(nmembers, &offset);
 
-	INJECTION_POINT("multixact-create-from-members");
+	INJECTION_POINT_CACHED("multixact-create-from-members");
 
 	/* Make an XLOG entry describing the new MXID. */
 	xlrec.mid = multi;
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index 4e775c7ec6..8b14f5fc19 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -28,6 +28,7 @@
 #include "storage/lwlock.h"
 #include "storage/shmem.h"
 #include "utils/builtins.h"
+#include "utils/guc.h"
 #include "utils/injection_point.h"
 #include "utils/memutils.h"
 #include "utils/wait_event.h"
@@ -68,7 +69,12 @@ typedef struct InjectionPointCondition
  */
 static List *inj_list_local = NIL;
 
-/* Shared state information for injection points. */
+/*
+ * Shared state information for injection points.
+ *
+ * This state data can be initialized in two ways: dynamically with a DSM
+ * or when loading the module.
+ */
 typedef struct InjectionPointSharedState
 {
 	/* Protects access to other fields */
@@ -97,8 +103,16 @@ extern PGDLLEXPORT void injection_wait(const char *name,
 /* track if injection points attached in this process are linked to it */
 static bool injection_point_local = false;
 
+/* GUC variable */
+bool inj_stats_enabled = true;
+
+/* Shared memory init callbacks */
+static shmem_request_hook_type prev_shmem_request_hook = NULL;
+static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
+
 /*
- * Callback for shared memory area initialization.
+ * Routine for shared memory area initialization, used as a callback
+ * when initializing dynamically with a DSM or when loading the module.
  */
 static void
 injection_point_init_state(void *ptr)
@@ -111,8 +125,51 @@ injection_point_init_state(void *ptr)
 	ConditionVariableInit(&state->wait_point);
 }
 
+/* Shared memory initialization when loading module */
+static void
+injection_shmem_request(void)
+{
+	Size		size;
+
+	if (prev_shmem_request_hook)
+		prev_shmem_request_hook();
+
+	size = MAXALIGN(sizeof(InjectionPointSharedState));
+	RequestAddinShmemSpace(size);
+}
+
+static void
+injection_shmem_startup(void)
+{
+	bool		found;
+
+	if (prev_shmem_startup_hook)
+		prev_shmem_startup_hook();
+
+	/* reset in case this is a restart within the postmaster */
+	inj_state = NULL;
+
+	/* Create or attach to the shared memory state */
+	LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE);
+
+	inj_state = ShmemInitStruct("injection_points",
+								sizeof(InjectionPointSharedState),
+								&found);
+
+	if (!found)
+	{
+		/*
+		 * First time through, so initialize.  This is shared with the
+		 * dynamic initialization using a DSM.
+		 */
+		injection_point_init_state(inj_state);
+	}
+
+	LWLockRelease(AddinShmemInitLock);
+}
+
 /*
- * Initialize shared memory area for this module.
+ * Initialize shared memory area for this module through DSM.
  */
 static void
 injection_init_shmem(void)
@@ -460,9 +517,26 @@ injection_points_detach(PG_FUNCTION_ARGS)
 void
 _PG_init(void)
 {
+	DefineCustomBoolVariable("injection_points.stats",
+							 "Enables statistics for injection points.",
+							 NULL,
+							 &inj_stats_enabled,
+							 true,
+							 PGC_SIGHUP,
+							 0,
+							 NULL,
+							 NULL,
+							 NULL);
+
 	if (!process_shared_preload_libraries_in_progress)
 		return;
 
+	/* Shared memory initialization */
+	prev_shmem_request_hook = shmem_request_hook;
+	shmem_request_hook = injection_shmem_request;
+	prev_shmem_startup_hook = shmem_startup_hook;
+	shmem_startup_hook = injection_shmem_startup;
+
 	pgstat_register_inj();
 	pgstat_register_inj_fixed();
 }
diff --git a/src/test/modules/injection_points/injection_stats.c b/src/test/modules/injection_points/injection_stats.c
index 78042074ff..582686a0a8 100644
--- a/src/test/modules/injection_points/injection_stats.c
+++ b/src/test/modules/injection_points/injection_stats.c
@@ -91,7 +91,7 @@ pgstat_fetch_stat_injentry(const char *name)
 {
 	PgStat_StatInjEntry *entry = NULL;
 
-	if (!inj_stats_loaded)
+	if (!inj_stats_loaded || !inj_stats_enabled)
 		return NULL;
 
 	/* Compile the lookup key as a hash of the point name */
@@ -123,7 +123,7 @@ pgstat_create_inj(const char *name)
 	PgStatShared_InjectionPoint *shstatent;
 
 	/* leave if disabled */
-	if (!inj_stats_loaded)
+	if (!inj_stats_loaded || !inj_stats_enabled)
 		return;
 
 	entry_ref = pgstat_get_entry_ref_locked(PGSTAT_KIND_INJECTION, InvalidOid,
@@ -142,7 +142,7 @@ void
 pgstat_drop_inj(const char *name)
 {
 	/* leave if disabled */
-	if (!inj_stats_loaded)
+	if (!inj_stats_loaded || !inj_stats_enabled)
 		return;
 
 	if (!pgstat_drop_entry(PGSTAT_KIND_INJECTION, InvalidOid,
@@ -164,7 +164,7 @@ pgstat_report_inj(const char *name)
 	PgStat_StatInjEntry *statent;
 
 	/* leave if disabled */
-	if (!inj_stats_loaded)
+	if (!inj_stats_loaded || !inj_stats_enabled)
 		return;
 
 	entry_ref = pgstat_get_entry_ref_locked(PGSTAT_KIND_INJECTION, InvalidOid,
diff --git a/src/test/modules/injection_points/injection_stats.h b/src/test/modules/injection_points/injection_stats.h
index 126c110169..c48d533b4b 100644
--- a/src/test/modules/injection_points/injection_stats.h
+++ b/src/test/modules/injection_points/injection_stats.h
@@ -15,6 +15,9 @@
 #ifndef INJECTION_STATS
 #define INJECTION_STATS
 
+/* GUC variable */
+extern bool inj_stats_enabled;
+
 /* injection_stats.c */
 extern void pgstat_register_inj(void);
 extern void pgstat_create_inj(const char *name);
diff --git a/src/test/modules/injection_points/injection_stats_fixed.c b/src/test/modules/injection_points/injection_stats_fixed.c
index 82b07e5332..2fed178b7a 100644
--- a/src/test/modules/injection_points/injection_stats_fixed.c
+++ b/src/test/modules/injection_points/injection_stats_fixed.c
@@ -146,7 +146,7 @@ pgstat_report_inj_fixed(uint32 numattach,
 	PgStatShared_InjectionPointFixed *stats_shmem;
 
 	/* leave if disabled */
-	if (!inj_fixed_loaded)
+	if (!inj_fixed_loaded || !inj_stats_enabled)
 		return;
 
 	stats_shmem = pgstat_get_custom_shmem_data(PGSTAT_KIND_INJECTION_FIXED);
@@ -172,7 +172,7 @@ injection_points_stats_fixed(PG_FUNCTION_ARGS)
 	bool		nulls[5] = {0};
 	PgStat_StatInjFixedEntry *stats;
 
-	if (!inj_fixed_loaded)
+	if (!inj_fixed_loaded || !inj_stats_enabled)
 		PG_RETURN_NULL();
 
 	pgstat_snapshot_fixed(PGSTAT_KIND_INJECTION_FIXED);
diff --git a/src/test/modules/test_slru/t/001_multixact.pl b/src/test/modules/test_slru/t/001_multixact.pl
index f07406bf9d..793706c5f2 100644
--- a/src/test/modules/test_slru/t/001_multixact.pl
+++ b/src/test/modules/test_slru/t/001_multixact.pl
@@ -24,7 +24,9 @@ my ($node, $result);
 $node = PostgreSQL::Test::Cluster->new('mike');
 $node->init;
 $node->append_conf('postgresql.conf',
-	"shared_preload_libraries = 'test_slru'");
+	"shared_preload_libraries = 'test_slru,injection_points'");
+$node->append_conf('postgresql.conf',
+	"injection_points.stats = false");
 $node->start;
 $node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
 $node->safe_psql('postgres', q(CREATE EXTENSION test_slru));
@@ -64,7 +66,6 @@ $node->safe_psql('postgres',
 $creator->query_until(
 	qr/start/, q{
 	\echo start
-	SELECT injection_points_load('multixact-create-from-members');
 	SELECT test_create_multixact();
 });
 
-- 
2.45.2

#108Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Michael Paquier (#107)
Re: MultiXact\SLRU buffers configuration

On 2024-Aug-21, Michael Paquier wrote:

I see that you've gone the way with the SQL function doing a load().
Would it be worth switching the test to rely on the two macros for
load and caching instead? I've mentioned that previously but never
got down to present a patch for the sake of this test.

Hmm, I have no opinion on which way is best. You probably have a better
sense of what's better for the injections point interface, so I'm happy
to defer to you on this.

+	/* reset in case this is a restart within the postmaster */
+	inj_state = NULL;

I'm not sure that this assignment actually accomplishes anything ...

I don't understand what do the inj_stats_enabled stuff have to do with
this patch. I suspect it's a git operation error, ie., you seem to have
squashed two different things together.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Industry suffers from the managerial dogma that for the sake of stability
and continuity, the company should be independent of the competence of
individual employees." (E. Dijkstra)

#109Michael Paquier
michael@paquier.xyz
In reply to: Alvaro Herrera (#108)
Re: MultiXact\SLRU buffers configuration

On Tue, Aug 20, 2024 at 08:13:12PM -0400, Alvaro Herrera wrote:

I don't understand what do the inj_stats_enabled stuff have to do with
this patch. I suspect it's a git operation error, ie., you seem to have
squashed two different things together.

Sorry, I should have split that for clarity (one patch for the GUC,
one to change the test to use CACHED/LOAD). It is not an error
though: if we don't have a controlled way to disable the stats of the
module, then the test would fail when calling the cached callback
because we'd try to allocate some memory for the dshash entry in
pgstats.

The second effect of initializing the shmem state of the module with
shared_preload_libraries is condition variables are set up for the
sake if the test, removing the dependency to the SQL load() call.
Both are OK, but I'd prefer introducing one use case for these two
macros in the tree, so as these can be used as a reference in the
future when developing new tests.
--
Michael

#110Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#109)
3 attachment(s)
Re: MultiXact\SLRU buffers configuration

On Wed, Aug 21, 2024 at 12:46:31PM +0900, Michael Paquier wrote:

Sorry, I should have split that for clarity (one patch for the GUC,
one to change the test to use CACHED/LOAD). It is not an error
though: if we don't have a controlled way to disable the stats of the
module, then the test would fail when calling the cached callback
because we'd try to allocate some memory for the dshash entry in
pgstats.

The second effect of initializing the shmem state of the module with
shared_preload_libraries is condition variables are set up for the
sake if the test, removing the dependency to the SQL load() call.
Both are OK, but I'd prefer introducing one use case for these two
macros in the tree, so as these can be used as a reference in the
future when developing new tests.

In short, here is a better patch set, with 0001 and 0002 introducing
the pieces that the test would need to be able to use the LOAD() and
CACHED() macros in 0003:
- 0001: Add shmem callbacks to initialize shmem state of
injection_points with shared_preload_libraries.
- 0002: Add a GUC to control if the stats of the module are enabled.
By default, they are disabled as they are only needed in the TAP test
of injection_points for the stats.
- 0003: Update the SLRU test to use INJECTION_POINT_LOAD and
INJECTION_POINT_CACHED with injection_points loaded via
shared_preload_libraries, removing the call to
injection_points_load() in the perl test.

What do you think?
--
Michael

Attachments:

0001-injection_points-Add-initialization-of-shmem-state-a.patchtext/x-diff; charset=us-asciiDownload
From 48a3b8b469ec52d184999d2617134ec680db378f Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Wed, 21 Aug 2024 15:12:08 +0900
Subject: [PATCH 1/3] injection_points: Add initialization of shmem state at
 loading

This commits adds callbacks to initialize the shared memory state of the
module when loaded with shared_preload_libraries.  This is necessary for
a upcoming change for a SLRU test, that relies on a critical section
where no allocation.  Initializing the shared memory state of the module
while loading provides a control on the timing where this data is set
up.
---
 .../injection_points/injection_points.c       | 65 ++++++++++++++++++-
 1 file changed, 62 insertions(+), 3 deletions(-)

diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index 4e775c7ec6..8d83d8c401 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -68,7 +68,12 @@ typedef struct InjectionPointCondition
  */
 static List *inj_list_local = NIL;
 
-/* Shared state information for injection points. */
+/*
+ * Shared state information for injection points.
+ *
+ * This state data can be initialized in two ways: dynamically with a DSM
+ * or when loading the module.
+ */
 typedef struct InjectionPointSharedState
 {
 	/* Protects access to other fields */
@@ -97,8 +102,13 @@ extern PGDLLEXPORT void injection_wait(const char *name,
 /* track if injection points attached in this process are linked to it */
 static bool injection_point_local = false;
 
+/* Shared memory init callbacks */
+static shmem_request_hook_type prev_shmem_request_hook = NULL;
+static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
+
 /*
- * Callback for shared memory area initialization.
+ * Routine for shared memory area initialization, used as a callback
+ * when initializing dynamically with a DSM or when loading the module.
  */
 static void
 injection_point_init_state(void *ptr)
@@ -111,8 +121,51 @@ injection_point_init_state(void *ptr)
 	ConditionVariableInit(&state->wait_point);
 }
 
+/* Shared memory initialization when loading module */
+static void
+injection_shmem_request(void)
+{
+	Size		size;
+
+	if (prev_shmem_request_hook)
+		prev_shmem_request_hook();
+
+	size = MAXALIGN(sizeof(InjectionPointSharedState));
+	RequestAddinShmemSpace(size);
+}
+
+static void
+injection_shmem_startup(void)
+{
+	bool		found;
+
+	if (prev_shmem_startup_hook)
+		prev_shmem_startup_hook();
+
+	/* reset in case this is a restart within the postmaster */
+	inj_state = NULL;
+
+	/* Create or attach to the shared memory state */
+	LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE);
+
+	inj_state = ShmemInitStruct("injection_points",
+								sizeof(InjectionPointSharedState),
+								&found);
+
+	if (!found)
+	{
+		/*
+		 * First time through, so initialize.  This is shared with the
+		 * dynamic initialization using a DSM.
+		 */
+		injection_point_init_state(inj_state);
+	}
+
+	LWLockRelease(AddinShmemInitLock);
+}
+
 /*
- * Initialize shared memory area for this module.
+ * Initialize shared memory area for this module through DSM.
  */
 static void
 injection_init_shmem(void)
@@ -463,6 +516,12 @@ _PG_init(void)
 	if (!process_shared_preload_libraries_in_progress)
 		return;
 
+	/* Shared memory initialization */
+	prev_shmem_request_hook = shmem_request_hook;
+	shmem_request_hook = injection_shmem_request;
+	prev_shmem_startup_hook = shmem_startup_hook;
+	shmem_startup_hook = injection_shmem_startup;
+
 	pgstat_register_inj();
 	pgstat_register_inj_fixed();
 }
-- 
2.45.2

0002-injection_point-Add-injection_points.stats.patchtext/x-diff; charset=us-asciiDownload
From fd8ab7b6845a2c56aa2c8d9c60f404f6b3407338 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Wed, 21 Aug 2024 15:16:06 +0900
Subject: [PATCH 2/3] injection_point: Add injection_points.stats

This GUC controls if statistics should be used or not in the module.
Custom statistics require the module to be loaded with
shared_preload_libraries, hence this GUC is made PGC_POSTMASTER.  By
default, stats are disabled.

This will be used by an upcoming change in a test where stats should not
be used, as the test has a dependency on a critical section.
---
 .../modules/injection_points/injection_points.c | 17 +++++++++++++++++
 .../modules/injection_points/injection_stats.c  |  8 ++++----
 .../modules/injection_points/injection_stats.h  |  3 +++
 .../injection_points/injection_stats_fixed.c    |  4 ++--
 .../modules/injection_points/t/001_stats.pl     |  6 ++++--
 5 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index 8d83d8c401..fb5eb3b586 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -28,6 +28,7 @@
 #include "storage/lwlock.h"
 #include "storage/shmem.h"
 #include "utils/builtins.h"
+#include "utils/guc.h"
 #include "utils/injection_point.h"
 #include "utils/memutils.h"
 #include "utils/wait_event.h"
@@ -102,6 +103,9 @@ extern PGDLLEXPORT void injection_wait(const char *name,
 /* track if injection points attached in this process are linked to it */
 static bool injection_point_local = false;
 
+/* GUC variable */
+bool inj_stats_enabled = false;
+
 /* Shared memory init callbacks */
 static shmem_request_hook_type prev_shmem_request_hook = NULL;
 static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
@@ -516,6 +520,19 @@ _PG_init(void)
 	if (!process_shared_preload_libraries_in_progress)
 		return;
 
+	DefineCustomBoolVariable("injection_points.stats",
+							 "Enables statistics for injection points.",
+							 NULL,
+							 &inj_stats_enabled,
+							 false,
+							 PGC_POSTMASTER,
+							 0,
+							 NULL,
+							 NULL,
+							 NULL);
+
+	MarkGUCPrefixReserved("injection_points");
+
 	/* Shared memory initialization */
 	prev_shmem_request_hook = shmem_request_hook;
 	shmem_request_hook = injection_shmem_request;
diff --git a/src/test/modules/injection_points/injection_stats.c b/src/test/modules/injection_points/injection_stats.c
index 78042074ff..582686a0a8 100644
--- a/src/test/modules/injection_points/injection_stats.c
+++ b/src/test/modules/injection_points/injection_stats.c
@@ -91,7 +91,7 @@ pgstat_fetch_stat_injentry(const char *name)
 {
 	PgStat_StatInjEntry *entry = NULL;
 
-	if (!inj_stats_loaded)
+	if (!inj_stats_loaded || !inj_stats_enabled)
 		return NULL;
 
 	/* Compile the lookup key as a hash of the point name */
@@ -123,7 +123,7 @@ pgstat_create_inj(const char *name)
 	PgStatShared_InjectionPoint *shstatent;
 
 	/* leave if disabled */
-	if (!inj_stats_loaded)
+	if (!inj_stats_loaded || !inj_stats_enabled)
 		return;
 
 	entry_ref = pgstat_get_entry_ref_locked(PGSTAT_KIND_INJECTION, InvalidOid,
@@ -142,7 +142,7 @@ void
 pgstat_drop_inj(const char *name)
 {
 	/* leave if disabled */
-	if (!inj_stats_loaded)
+	if (!inj_stats_loaded || !inj_stats_enabled)
 		return;
 
 	if (!pgstat_drop_entry(PGSTAT_KIND_INJECTION, InvalidOid,
@@ -164,7 +164,7 @@ pgstat_report_inj(const char *name)
 	PgStat_StatInjEntry *statent;
 
 	/* leave if disabled */
-	if (!inj_stats_loaded)
+	if (!inj_stats_loaded || !inj_stats_enabled)
 		return;
 
 	entry_ref = pgstat_get_entry_ref_locked(PGSTAT_KIND_INJECTION, InvalidOid,
diff --git a/src/test/modules/injection_points/injection_stats.h b/src/test/modules/injection_points/injection_stats.h
index 126c110169..c48d533b4b 100644
--- a/src/test/modules/injection_points/injection_stats.h
+++ b/src/test/modules/injection_points/injection_stats.h
@@ -15,6 +15,9 @@
 #ifndef INJECTION_STATS
 #define INJECTION_STATS
 
+/* GUC variable */
+extern bool inj_stats_enabled;
+
 /* injection_stats.c */
 extern void pgstat_register_inj(void);
 extern void pgstat_create_inj(const char *name);
diff --git a/src/test/modules/injection_points/injection_stats_fixed.c b/src/test/modules/injection_points/injection_stats_fixed.c
index 82b07e5332..2fed178b7a 100644
--- a/src/test/modules/injection_points/injection_stats_fixed.c
+++ b/src/test/modules/injection_points/injection_stats_fixed.c
@@ -146,7 +146,7 @@ pgstat_report_inj_fixed(uint32 numattach,
 	PgStatShared_InjectionPointFixed *stats_shmem;
 
 	/* leave if disabled */
-	if (!inj_fixed_loaded)
+	if (!inj_fixed_loaded || !inj_stats_enabled)
 		return;
 
 	stats_shmem = pgstat_get_custom_shmem_data(PGSTAT_KIND_INJECTION_FIXED);
@@ -172,7 +172,7 @@ injection_points_stats_fixed(PG_FUNCTION_ARGS)
 	bool		nulls[5] = {0};
 	PgStat_StatInjFixedEntry *stats;
 
-	if (!inj_fixed_loaded)
+	if (!inj_fixed_loaded || !inj_stats_enabled)
 		PG_RETURN_NULL();
 
 	pgstat_snapshot_fixed(PGSTAT_KIND_INJECTION_FIXED);
diff --git a/src/test/modules/injection_points/t/001_stats.pl b/src/test/modules/injection_points/t/001_stats.pl
index 0d72cd86df..9df79b5168 100644
--- a/src/test/modules/injection_points/t/001_stats.pl
+++ b/src/test/modules/injection_points/t/001_stats.pl
@@ -20,8 +20,10 @@ if ($ENV{enable_injection_points} ne 'yes')
 # Node initialization
 my $node = PostgreSQL::Test::Cluster->new('master');
 $node->init;
-$node->append_conf('postgresql.conf',
-	"shared_preload_libraries = 'injection_points'");
+$node->append_conf('postgresql.conf', qq(
+shared_preload_libraries = 'injection_points'
+injection_points.stats = true
+));
 $node->start;
 $node->safe_psql('postgres', 'CREATE EXTENSION injection_points;');
 
-- 
2.45.2

0003-Rework-new-SLRU-test-with-injection-points.patchtext/x-diff; charset=us-asciiDownload
From e5329d080b9d8436af8f65aac118745cf1f81ca2 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Wed, 21 Aug 2024 15:09:06 +0900
Subject: [PATCH 3/3] Rework new SLRU test with injection points

Rather than the SQL injection_points_load, this commit makes the test
rely on the two macros to load and run an injection point from the
cache, acting as an example of how to use them.
---
 src/backend/access/transam/multixact.c        | 5 ++++-
 src/test/modules/test_slru/t/001_multixact.pl | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 14c2b929e2..d2d0298ac3 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -855,6 +855,9 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
 		}
 	}
 
+	/* Load the injection point before entering the critical section */
+	INJECTION_POINT_LOAD("multixact-create-from-members");
+
 	/*
 	 * Assign the MXID and offsets range to use, and make sure there is space
 	 * in the OFFSETs and MEMBERs files.  NB: this routine does
@@ -869,7 +872,7 @@ MultiXactIdCreateFromMembers(int nmembers, MultiXactMember *members)
 	 */
 	multi = GetNewMultiXactId(nmembers, &offset);
 
-	INJECTION_POINT("multixact-create-from-members");
+	INJECTION_POINT_CACHED("multixact-create-from-members");
 
 	/* Make an XLOG entry describing the new MXID. */
 	xlrec.mid = multi;
diff --git a/src/test/modules/test_slru/t/001_multixact.pl b/src/test/modules/test_slru/t/001_multixact.pl
index f07406bf9d..882de7cd20 100644
--- a/src/test/modules/test_slru/t/001_multixact.pl
+++ b/src/test/modules/test_slru/t/001_multixact.pl
@@ -24,7 +24,7 @@ my ($node, $result);
 $node = PostgreSQL::Test::Cluster->new('mike');
 $node->init;
 $node->append_conf('postgresql.conf',
-	"shared_preload_libraries = 'test_slru'");
+	"shared_preload_libraries = 'test_slru,injection_points'");
 $node->start;
 $node->safe_psql('postgres', q(CREATE EXTENSION injection_points));
 $node->safe_psql('postgres', q(CREATE EXTENSION test_slru));
@@ -64,7 +64,6 @@ $node->safe_psql('postgres',
 $creator->query_until(
 	qr/start/, q{
 	\echo start
-	SELECT injection_points_load('multixact-create-from-members');
 	SELECT test_create_multixact();
 });
 
-- 
2.45.2

#111Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Michael Paquier (#110)
Re: MultiXact\SLRU buffers configuration

On 2024-Aug-21, Michael Paquier wrote:

From fd8ab7b6845a2c56aa2c8d9c60f404f6b3407338 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Wed, 21 Aug 2024 15:16:06 +0900
Subject: [PATCH 2/3] injection_point: Add injection_points.stats

This GUC controls if statistics should be used or not in the module.
Custom statistics require the module to be loaded with
shared_preload_libraries, hence this GUC is made PGC_POSTMASTER. By
default, stats are disabled.

This will be used by an upcoming change in a test where stats should not
be used, as the test has a dependency on a critical section.

I find it's strange that the information that stats cannot be used with
injection points that have dependency on critical sections (?), is only
in the commit message and not in the code.

Also, maybe it'd make sense for stats to be globally enabled, and that
only the tests that require it would disable them? (It's probably easy
enough to have a value "injection_points.stats=auto" which means, if the
module is loaded in shared_preload_libraries them set stats on,
otherwise turn them off.) TBH I don't understand why the issue that
stats require shared_preload_libraries only comes up now ... Maybe
another approach is to say that if an injection point is loaded via
_LOAD() rather than the normal way, then stats are disabled for that one
rather than globally? Or give the _LOAD() macro a boolean argument to
indicate whether to collect stats for that injection point or not.

Lastly, it's not clear to me what does it mean that the test has a
"dependency" on a critical section. Do you mean to say that the
injection point runs inside a critical section?

From e5329d080b9d8436af8f65aac118745cf1f81ca2 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Wed, 21 Aug 2024 15:09:06 +0900
Subject: [PATCH 3/3] Rework new SLRU test with injection points

Rather than the SQL injection_points_load, this commit makes the test
rely on the two macros to load and run an injection point from the
cache, acting as an example of how to use them.

No issues with this, feel free to go ahead.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Cada quien es cada cual y baja las escaleras como quiere" (JMSerrat)

#112Michael Paquier
michael@paquier.xyz
In reply to: Alvaro Herrera (#111)
Re: MultiXact\SLRU buffers configuration

On Wed, Aug 21, 2024 at 01:55:06PM -0400, Alvaro Herrera wrote:

I find it's strange that the information that stats cannot be used with
injection points that have dependency on critical sections (?), is only
in the commit message and not in the code.

A comment close to where inj_stats_enabled is declared in
injection_points.c may be adapted for that, say:
"This GUC is useful to control if statistics should be enabled or not
during a test with injection points, like for example if a test relies
on a callback run in a critical section where no allocation should
happen."

Also, maybe it'd make sense for stats to be globally enabled, and that
only the tests that require it would disable them? (It's probably easy
enough to have a value "injection_points.stats=auto" which means, if the
module is loaded in shared_preload_libraries them set stats on,
otherwise turn them off.)

I'm not sure that we need to get down to that until somebody has a
case where they want to rely on stats of injection points for their
stuff. At this stage, I only want the stats to be enabled to provide
automated checks for the custom pgstats APIs, so disabling it by
default and enabling it only in the stats test of the module
injection_points sounds kind of enough to me for now. The module
could always be tweaked to do that in the future, if there's a case.

TBH I don't understand why the issue that
stats require shared_preload_libraries only comes up now ...

Because there was no need to, simply. It is the first test that
relies on a critical section, and we need allocations if we want to
use a wait condition.

Maybe another approach is to say that if an injection point is loaded via
_LOAD() rather than the normal way, then stats are disabled for that one
rather than globally?

One trick would be to force the GUC to be false for the duration of
the callback based on a check of CritSectionCount, a second one would
be to just skip the stats if are under CritSectionCount. A third
option, that I find actually interesting, would be to call
MemoryContextAllowInCriticalSection in some strategic code paths of
the test module injection_points because we're OK to live with this
restriction in the module.

Or give the _LOAD() macro a boolean argument to
indicate whether to collect stats for that injection point or not.

Sticking some knowledge about the stats in the backend part of
injection points does not sound like a good idea to me.

Lastly, it's not clear to me what does it mean that the test has a
"dependency" on a critical section. Do you mean to say that the
injection point runs inside a critical section?

Yes.

No issues with this, feel free to go ahead.

Cool, thanks.
--
Michael

#113Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Michael Paquier (#112)
Re: MultiXact\SLRU buffers configuration

On 2024-Aug-22, Michael Paquier wrote:

On Wed, Aug 21, 2024 at 01:55:06PM -0400, Alvaro Herrera wrote:

Also, maybe it'd make sense for stats to be globally enabled, and that
only the tests that require it would disable them? (It's probably easy
enough to have a value "injection_points.stats=auto" which means, if the
module is loaded in shared_preload_libraries them set stats on,
otherwise turn them off.)

I'm not sure that we need to get down to that until somebody has a
case where they want to rely on stats of injection points for their
stuff. At this stage, I only want the stats to be enabled to provide
automated checks for the custom pgstats APIs, so disabling it by
default and enabling it only in the stats test of the module
injection_points sounds kind of enough to me for now.

Oh! I thought the stats were useful by themselves. That not being the
case, I agree with simplifying; and the other ways to enhance this point
might not be necessary for now.

Or give the _LOAD() macro a boolean argument to
indicate whether to collect stats for that injection point or not.

Sticking some knowledge about the stats in the backend part of
injection points does not sound like a good idea to me.

You could flip this around: have the bool be for "this injection point
is going to be invoked inside a critical section". Then core code just
needs to tell the injection points module what core code does, and it's
injection_points that decides what to do with that information.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Crear es tan difícil como ser libre" (Elsa Triolet)

#114Michael Paquier
michael@paquier.xyz
In reply to: Alvaro Herrera (#113)
Re: MultiXact\SLRU buffers configuration

On Thu, Aug 22, 2024 at 10:36:38AM -0400, Alvaro Herrera wrote:

On 2024-Aug-22, Michael Paquier wrote:

I'm not sure that we need to get down to that until somebody has a
case where they want to rely on stats of injection points for their
stuff. At this stage, I only want the stats to be enabled to provide
automated checks for the custom pgstats APIs, so disabling it by
default and enabling it only in the stats test of the module
injection_points sounds kind of enough to me for now.

Oh! I thought the stats were useful by themselves.

Yep, currently they're not, but I don't want to discard that they'll
never be, either. Perhaps there would be a case where somebody would
like to run a callback N times and trigger a condition? That's
something where the stats could be useful, but I don't have a specific
case for that now. I'm just imagining possibilities.

That not being the case, I agree with simplifying; and the other
ways to enhance this point might not be necessary for now.

Okay.

Sticking some knowledge about the stats in the backend part of
injection points does not sound like a good idea to me.

You could flip this around: have the bool be for "this injection point
is going to be invoked inside a critical section". Then core code just
needs to tell the injection points module what core code does, and it's
injection_points that decides what to do with that information.

Hmm. We could do that, but I'm not really on board with anything that
adds more code footprint into the backend. For this one, this is even
information specific to the code path where the injection point is
added.
--
Michael

#115Thom Brown
thom@linux.com
In reply to: Michael Paquier (#114)
Re: MultiXact\SLRU buffers configuration

On Fri, 23 Aug 2024 at 01:29, Michael Paquier <michael@paquier.xyz> wrote:

On Thu, Aug 22, 2024 at 10:36:38AM -0400, Alvaro Herrera wrote:

On 2024-Aug-22, Michael Paquier wrote:

I'm not sure that we need to get down to that until somebody has a
case where they want to rely on stats of injection points for their
stuff. At this stage, I only want the stats to be enabled to provide
automated checks for the custom pgstats APIs, so disabling it by
default and enabling it only in the stats test of the module
injection_points sounds kind of enough to me for now.

Oh! I thought the stats were useful by themselves.

Yep, currently they're not, but I don't want to discard that they'll
never be, either. Perhaps there would be a case where somebody would
like to run a callback N times and trigger a condition? That's
something where the stats could be useful, but I don't have a specific
case for that now. I'm just imagining possibilities.

I believe I am seeing the problem being discussed occuring on a production
system running 15.6, causing ever-increasing replay lag on the standby,
until I cancel the offending process on the standby and force it to process
its interrupts.

Here's the backtrace before I do that:

#0 0x00007f4503b81876 in select () from /lib64/libc.so.6
#1 0x0000558b0956891a in pg_usleep (microsec=microsec@entry=1000) at
pgsleep.c:56
#2 0x0000558b0917e01a in GetMultiXactIdMembers (from_pgupgrade=false,
onlyLock=<optimized out>, members=0x7ffcd2a9f1e0, multi=109187502) at
multixact.c:1392
#3 GetMultiXactIdMembers (multi=109187502,
members=members@entry=0x7ffcd2a9f1e0,
from_pgupgrade=from_pgupgrade@entry=false, onlyLock=onlyLock@entry=false)
at multixact.c:1224
#4 0x0000558b0913de15 in MultiXactIdGetUpdateXid (xmax=<optimized out>,
t_infomask=<optimized out>) at heapam.c:6924
#5 0x0000558b09146028 in HeapTupleGetUpdateXid
(tuple=tuple@entry=0x7f440d428308)
at heapam.c:6965
#6 0x0000558b0914c02f in HeapTupleSatisfiesMVCC (htup=0x558b0b7cbf20,
htup=0x558b0b7cbf20, buffer=8053429, snapshot=0x558b0b63a2d8) at
heapam_visibility.c:1089
#7 HeapTupleSatisfiesVisibility (tup=tup@entry=0x7ffcd2a9f2b0,
snapshot=snapshot@entry=0x558b0b63a2d8, buffer=buffer@entry=8053429) at
heapam_visibility.c:1771
#8 0x0000558b0913e819 in heapgetpage (sscan=sscan@entry=0x558b0b7ccfa0,
page=page@entry=115) at heapam.c:468
#9 0x0000558b0913eb7e in heapgettup_pagemode (scan=scan@entry=0x558b0b7ccfa0,
dir=ForwardScanDirection, nkeys=0, key=0x0) at heapam.c:1120
#10 0x0000558b0913fb5e in heap_getnextslot (sscan=0x558b0b7ccfa0,
direction=<optimized out>, slot=0x558b0b7cc000) at heapam.c:1352
#11 0x0000558b092c0e7a in table_scan_getnextslot (slot=0x558b0b7cc000,
direction=ForwardScanDirection, sscan=<optimized out>) at
../../../src/include/access/tableam.h:1046
#12 SeqNext (node=0x558b0b7cbe10) at nodeSeqscan.c:80
#13 0x0000558b0929b9bf in ExecScan (node=0x558b0b7cbe10,
accessMtd=0x558b092c0df0 <SeqNext>, recheckMtd=0x558b092c0dc0 <SeqRecheck>)
at execScan.c:198
#14 0x0000558b09292cb2 in ExecProcNode (node=0x558b0b7cbe10) at
../../../src/include/executor/executor.h:262
#15 ExecutePlan (execute_once=<optimized out>, dest=0x558b0bca1350,
direction=<optimized out>, numberTuples=0, sendTuples=<optimized out>,
operation=CMD_SELECT, use_parallel_mode=<optimized out>,
planstate=0x558b0b7cbe10, estate=0x558b0b7cbbe8)
at execMain.c:1636
#16 standard_ExecutorRun (queryDesc=0x558b0b8c9798, direction=<optimized
out>, count=0, execute_once=<optimized out>) at execMain.c:363
#17 0x00007f44f64d43c5 in pgss_ExecutorRun (queryDesc=0x558b0b8c9798,
direction=ForwardScanDirection, count=0, execute_once=<optimized out>) at
pg_stat_statements.c:1010
#18 0x0000558b093fda0f in PortalRunSelect (portal=portal@entry=0x558b0b6ba458,
forward=forward@entry=true, count=0, count@entry=9223372036854775807,
dest=dest@entry=0x558b0bca1350) at pquery.c:924
#19 0x0000558b093fedb8 in PortalRun (portal=portal@entry=0x558b0b6ba458,
count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true,
run_once=run_once@entry=true, dest=dest@entry=0x558b0bca1350,
altdest=altdest@entry=0x558b0bca1350, qc=0x7ffcd2a9f7a0) at pquery.c:768
#20 0x0000558b093fb243 in exec_simple_query (
query_string=0x558b0b6170c8 "<redacted>")
at postgres.c:1250
#21 0x0000558b093fd412 in PostgresMain (dbname=<optimized out>,
username=<optimized out>) at postgres.c:4598
#22 0x0000558b0937e170 in BackendRun (port=<optimized out>, port=<optimized
out>) at postmaster.c:4514
#23 BackendStartup (port=<optimized out>) at postmaster.c:4242
#24 ServerLoop () at postmaster.c:1809
#25 0x0000558b0937f147 in PostmasterMain (argc=argc@entry=5,
argv=argv@entry=0x558b0b5d0a30)
at postmaster.c:1481
#26 0x0000558b09100a2c in main (argc=5, argv=0x558b0b5d0a30) at main.c:202

This occurred twice, meaning 2 processes needed terminating.

Thom

#116Thom Brown
thom@linux.com
In reply to: Thom Brown (#115)
Re: MultiXact\SLRU buffers configuration

On Tue, 29 Oct 2024 at 16:38, Thom Brown <thom@linux.com> wrote:

On Fri, 23 Aug 2024 at 01:29, Michael Paquier <michael@paquier.xyz> wrote:

On Thu, Aug 22, 2024 at 10:36:38AM -0400, Alvaro Herrera wrote:

On 2024-Aug-22, Michael Paquier wrote:

I'm not sure that we need to get down to that until somebody has a
case where they want to rely on stats of injection points for their
stuff. At this stage, I only want the stats to be enabled to provide
automated checks for the custom pgstats APIs, so disabling it by
default and enabling it only in the stats test of the module
injection_points sounds kind of enough to me for now.

Oh! I thought the stats were useful by themselves.

Yep, currently they're not, but I don't want to discard that they'll
never be, either. Perhaps there would be a case where somebody would
like to run a callback N times and trigger a condition? That's
something where the stats could be useful, but I don't have a specific
case for that now. I'm just imagining possibilities.

I believe I am seeing the problem being discussed occuring on a production system running 15.6, causing ever-increasing replay lag on the standby, until I cancel the offending process on the standby and force it to process its interrupts.

Here's the backtrace before I do that:

#0 0x00007f4503b81876 in select () from /lib64/libc.so.6
#1 0x0000558b0956891a in pg_usleep (microsec=microsec@entry=1000) at pgsleep.c:56
#2 0x0000558b0917e01a in GetMultiXactIdMembers (from_pgupgrade=false, onlyLock=<optimized out>, members=0x7ffcd2a9f1e0, multi=109187502) at multixact.c:1392
#3 GetMultiXactIdMembers (multi=109187502, members=members@entry=0x7ffcd2a9f1e0, from_pgupgrade=from_pgupgrade@entry=false, onlyLock=onlyLock@entry=false) at multixact.c:1224
#4 0x0000558b0913de15 in MultiXactIdGetUpdateXid (xmax=<optimized out>, t_infomask=<optimized out>) at heapam.c:6924
#5 0x0000558b09146028 in HeapTupleGetUpdateXid (tuple=tuple@entry=0x7f440d428308) at heapam.c:6965
#6 0x0000558b0914c02f in HeapTupleSatisfiesMVCC (htup=0x558b0b7cbf20, htup=0x558b0b7cbf20, buffer=8053429, snapshot=0x558b0b63a2d8) at heapam_visibility.c:1089
#7 HeapTupleSatisfiesVisibility (tup=tup@entry=0x7ffcd2a9f2b0, snapshot=snapshot@entry=0x558b0b63a2d8, buffer=buffer@entry=8053429) at heapam_visibility.c:1771
#8 0x0000558b0913e819 in heapgetpage (sscan=sscan@entry=0x558b0b7ccfa0, page=page@entry=115) at heapam.c:468
#9 0x0000558b0913eb7e in heapgettup_pagemode (scan=scan@entry=0x558b0b7ccfa0, dir=ForwardScanDirection, nkeys=0, key=0x0) at heapam.c:1120
#10 0x0000558b0913fb5e in heap_getnextslot (sscan=0x558b0b7ccfa0, direction=<optimized out>, slot=0x558b0b7cc000) at heapam.c:1352
#11 0x0000558b092c0e7a in table_scan_getnextslot (slot=0x558b0b7cc000, direction=ForwardScanDirection, sscan=<optimized out>) at ../../../src/include/access/tableam.h:1046
#12 SeqNext (node=0x558b0b7cbe10) at nodeSeqscan.c:80
#13 0x0000558b0929b9bf in ExecScan (node=0x558b0b7cbe10, accessMtd=0x558b092c0df0 <SeqNext>, recheckMtd=0x558b092c0dc0 <SeqRecheck>) at execScan.c:198
#14 0x0000558b09292cb2 in ExecProcNode (node=0x558b0b7cbe10) at ../../../src/include/executor/executor.h:262
#15 ExecutePlan (execute_once=<optimized out>, dest=0x558b0bca1350, direction=<optimized out>, numberTuples=0, sendTuples=<optimized out>, operation=CMD_SELECT, use_parallel_mode=<optimized out>, planstate=0x558b0b7cbe10, estate=0x558b0b7cbbe8)
at execMain.c:1636
#16 standard_ExecutorRun (queryDesc=0x558b0b8c9798, direction=<optimized out>, count=0, execute_once=<optimized out>) at execMain.c:363
#17 0x00007f44f64d43c5 in pgss_ExecutorRun (queryDesc=0x558b0b8c9798, direction=ForwardScanDirection, count=0, execute_once=<optimized out>) at pg_stat_statements.c:1010
#18 0x0000558b093fda0f in PortalRunSelect (portal=portal@entry=0x558b0b6ba458, forward=forward@entry=true, count=0, count@entry=9223372036854775807, dest=dest@entry=0x558b0bca1350) at pquery.c:924
#19 0x0000558b093fedb8 in PortalRun (portal=portal@entry=0x558b0b6ba458, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x558b0bca1350,
altdest=altdest@entry=0x558b0bca1350, qc=0x7ffcd2a9f7a0) at pquery.c:768
#20 0x0000558b093fb243 in exec_simple_query (
query_string=0x558b0b6170c8 "<redacted>")
at postgres.c:1250
#21 0x0000558b093fd412 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4598
#22 0x0000558b0937e170 in BackendRun (port=<optimized out>, port=<optimized out>) at postmaster.c:4514
#23 BackendStartup (port=<optimized out>) at postmaster.c:4242
#24 ServerLoop () at postmaster.c:1809
#25 0x0000558b0937f147 in PostmasterMain (argc=argc@entry=5, argv=argv@entry=0x558b0b5d0a30) at postmaster.c:1481
#26 0x0000558b09100a2c in main (argc=5, argv=0x558b0b5d0a30) at main.c:202

This occurred twice, meaning 2 processes needed terminating.

Taking a look at what's happening under the hood, it seems to be
getting stuck here:

if (nextMXOffset == 0)
{
/* Corner case 2: next multixact is still
being filled in */
LWLockRelease(MultiXactOffsetSLRULock);
CHECK_FOR_INTERRUPTS();
pg_usleep(1000L);
goto retry;
}

It clearly checks for interrupts, but when I saw this issue happen, it
wasn't interruptible.

I looked around for similar reports, and I found a fork of Postgres
reporting the same issue, but with more info than I thought to get at
the time. They determined that the root cause involved a deadlock
where the replay thread is stuck due to an out-of-order multixact
playback sequence. The standby process waits indefinitely for a page
pin to release before proceeding, but the required multixact ID hasn't
yet been replayed due to log ordering. What they did to "fix" the
issue in their version was to add an error when the reading thread
cannot retrieve the next multixact ID, allowing it to exit instead of
becoming indefinitely stuck. This took the form of only allowing it to
loop 100 times before exiting.

Thom

#117Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Thom Brown (#116)
Re: MultiXact\SLRU buffers configuration

On 29 Oct 2024, at 21:45, Thom Brown <thom@linux.com> wrote:

It clearly checks for interrupts, but when I saw this issue happen, it
wasn't interruptible.

Perhaps, that was different multixacts?
When I was observing this pathology on Standby, it was a stream of different reads encountering different multis.

Either way startup can cancel locking process on it's own. Or is it the case that cancel was not enough, did you actually need termination, not cancel?

Thanks!

Best regards, Andrey Borodin.

#118Thom Brown
thom@linux.com
In reply to: Andrey M. Borodin (#117)
Re: MultiXact\SLRU buffers configuration

On Thu, 31 Oct 2024 at 10:47, Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:

On 29 Oct 2024, at 21:45, Thom Brown <thom@linux.com> wrote:

It clearly checks for interrupts, but when I saw this issue happen, it
wasn't interruptible.

Perhaps, that was different multixacts?
When I was observing this pathology on Standby, it was a stream of different reads encountering different multis.

Either way startup can cancel locking process on it's own. Or is it the case that cancel was not enough, did you actually need termination, not cancel?

Termination didn't work on either of the processes.

Thom

#119Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Thom Brown (#118)
Re: MultiXact\SLRU buffers configuration

On 31 Oct 2024, at 17:29, Thom Brown <thom@linux.com> wrote:

On Thu, 31 Oct 2024 at 10:47, Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:

On 29 Oct 2024, at 21:45, Thom Brown <thom@linux.com> wrote:

It clearly checks for interrupts, but when I saw this issue happen, it
wasn't interruptible.

Perhaps, that was different multixacts?
When I was observing this pathology on Standby, it was a stream of different reads encountering different multis.

Either way startup can cancel locking process on it's own. Or is it the case that cancel was not enough, did you actually need termination, not cancel?

Termination didn't work on either of the processes.

How did you force the process to actually terminate?
Did you observe repeated read of the same multixact?
Was offending process holding any locks while waiting?

Best regards, Andrey Borodin.

#120Thom Brown
thom@linux.com
In reply to: Andrey M. Borodin (#119)
Re: MultiXact\SLRU buffers configuration

On Thu, 31 Oct 2024, 17:33 Andrey M. Borodin, <x4mmm@yandex-team.ru> wrote:

On 31 Oct 2024, at 17:29, Thom Brown <thom@linux.com> wrote:

On Thu, 31 Oct 2024 at 10:47, Andrey M. Borodin <x4mmm@yandex-team.ru>

wrote:

On 29 Oct 2024, at 21:45, Thom Brown <thom@linux.com> wrote:

It clearly checks for interrupts, but when I saw this issue happen, it
wasn't interruptible.

Perhaps, that was different multixacts?
When I was observing this pathology on Standby, it was a stream of

different reads encountering different multis.

Either way startup can cancel locking process on it's own. Or is it the

case that cancel was not enough, did you actually need termination, not
cancel?

Termination didn't work on either of the processes.

How did you force the process to actually terminate?
Did you observe repeated read of the same multixact?
Was offending process holding any locks while waiting?

Unfortunately I didn't gather much information when it was occuring, and
prioritised getting rid of the process blocking replay. I just attached gdb
to it, got a backtrace and then "print ProcessInterrupts()".

Thom

Show quoted text
#121Andrey M. Borodin
x4mmm@yandex-team.ru
In reply to: Thom Brown (#120)
Re: MultiXact\SLRU buffers configuration

On 1 Nov 2024, at 00:25, Thom Brown <thom@linux.com> wrote:

Unfortunately I didn't gather much information when it was occuring, and prioritised getting rid of the process blocking replay. I just attached gdb to it, got a backtrace and then "print ProcessInterrupts()".

Currently I do not see how this wait can result in a deadlock.
But I did observe standby in a pathological sequential scan encountering recent multixact again and again (new each time).
I hope this situation will be alleviated by recent cahnges - now there is not a millisecond wait, but hopefully smaller amount of time.

In v17 we also added injection point test which reproduces reading very recent multixact. If there is a deadlock I hope buildfarm will show it to us.

Best regards, Andrey Borodin.

#122Robert Haas
robertmhaas@gmail.com
In reply to: Thom Brown (#116)
Re: MultiXact\SLRU buffers configuration

On Tue, Oct 29, 2024 at 1:45 PM Thom Brown <thom@linux.com> wrote:

Taking a look at what's happening under the hood, it seems to be
getting stuck here:

if (nextMXOffset == 0)
{
/* Corner case 2: next multixact is still
being filled in */
LWLockRelease(MultiXactOffsetSLRULock);
CHECK_FOR_INTERRUPTS();
pg_usleep(1000L);
goto retry;
}

It clearly checks for interrupts, but when I saw this issue happen, it
wasn't interruptible.

I don't understand the underlying issue here; however, if a process
holds an lwlock, it's not interruptible, even if it checks for
interrupts. So it could be that at this point in the code we're
holding some other LWLock, such as a buffer content lock, and that's
why this code fails to achieve its objective.

--
Robert Haas
EDB: http://www.enterprisedb.com

#123Andrey Borodin
x4mmm@yandex-team.ru
In reply to: Thom Brown (#120)
Re: MultiXact\SLRU buffers configuration

Hi Thom!

On 1 Nov 2024, at 00:25, Thom Brown <thom@linux.com> wrote:

Unfortunately I didn't gather much information when it was occuring, and prioritised getting rid of the process blocking replay. I just attached gdb to it, got a backtrace and then "print ProcessInterrupts()".

FWIW we diagnosed that problem in the recent thread "IPC/MultixactCreation on the Standby server" [0]/messages/by-id/172e5723-d65f-4eec-b512-14beacb326ce@yandex.ru.
Proposed fix is non-trivial. I'm trying to asses how many reports we had about this problem. Did you ever observe this problem again?

Thanks!

Best regards, Andrey Borodin.

[0]: /messages/by-id/172e5723-d65f-4eec-b512-14beacb326ce@yandex.ru