From c08570c9d33ecdb19ad88a61f5ba5eb442d16aca Mon Sep 17 00:00:00 2001
From: Kirk Jamison <k.jamison@jp.fujitsu.com>
Date: Wed, 6 Jan 2021 10:19:58 +0000
Subject: [PATCH] Test for threshold

This patch is for testing only. This patch should be applied
on top of the V39 patches.
We want to test for the approximate threshold wherein we can
see that the patched will perform worse than master.

In other words, our goal is to get the approximate threshold
and identify where the cost for finding to be invalidated
buffers gets higher in optimized path than the traditional path.
---
 src/backend/storage/buffer/bufmgr.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 9b0e877..77a841d 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -76,7 +76,7 @@
  * being dropped. For the relations with size below this threshold, we find
  * the buffers by doing lookups in BufMapping table.
  */
-#define BUF_DROP_FULL_SCAN_THRESHOLD		(uint32) (NBuffers / 32)
+//#define BUF_DROP_FULL_SCAN_THRESHOLD		(uint32) (NBuffers / 32)
 
 typedef struct PrivateRefCountEntry
 {
@@ -3044,8 +3044,7 @@ DropRelFileNodeBuffers(SMgrRelation smgr_reln, ForkNumber *forkNum,
 	 * We apply the optimization iff the total number of blocks to invalidate
 	 * is below the BUF_DROP_FULL_SCAN_THRESHOLD.
 	 */
-	if (BlockNumberIsValid(nBlocksToInvalidate) &&
-		nBlocksToInvalidate < BUF_DROP_FULL_SCAN_THRESHOLD)
+	if (BlockNumberIsValid(nBlocksToInvalidate))
 	{
 		for (j = 0; j < nforks; j++)
 			FindAndDropRelFileNodeBuffers(rnode.node, forkNum[j],
@@ -3179,7 +3178,7 @@ DropRelFileNodesAllBuffers(SMgrRelation *smgr_reln, int nnodes)
 	 * We apply the optimization iff the total number of blocks to invalidate
 	 * is below the BUF_DROP_FULL_SCAN_THRESHOLD.
 	 */
-	if (cached && nBlocksToInvalidate < BUF_DROP_FULL_SCAN_THRESHOLD)
+	if (cached)
 	{
 		for (i = 0; i < n; i++)
 		{
-- 
1.8.3.1

