]> granicus.if.org Git - postgresql/commitdiff
Adjusted calculation of shared memory requirements to new
authorJan Wieck <JanWieck@Yahoo.com>
Thu, 15 Jan 2004 16:14:26 +0000 (16:14 +0000)
committerJan Wieck <JanWieck@Yahoo.com>
Thu, 15 Jan 2004 16:14:26 +0000 (16:14 +0000)
ARC buffer replacement strategy.

Jan

src/backend/storage/buffer/buf_init.c
src/backend/storage/buffer/freelist.c
src/include/storage/buf_internals.h

index 1a707568b554d6d07bd566472e0e569a493df6af..2f3c818c19167e5dd5608251759467762a43ee47 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.60 2003/12/20 17:31:21 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.61 2004/01/15 16:14:26 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -231,13 +231,19 @@ BufferShmemSize(void)
        size += hash_estimate_size(SHMEM_INDEX_SIZE, sizeof(ShmemIndexEnt));
 
        /* size of buffer descriptors */
-       size += MAXALIGN((NBuffers + 1) * sizeof(BufferDesc));
+       size += MAXALIGN(NBuffers * sizeof(BufferDesc));
+
+       /* size of the shared replacement strategy control block */
+       size += MAXALIGN(sizeof(BufferStrategyControl));
+
+       /* size of the ARC directory blocks */
+       size += MAXALIGN(NBuffers * 2 * sizeof(BufferStrategyCDB));
 
        /* size of data pages */
        size += NBuffers * MAXALIGN(BLCKSZ);
 
        /* size of buffer hash table */
-       size += hash_estimate_size(NBuffers, sizeof(BufferLookupEnt));
+       size += hash_estimate_size(NBuffers * 2, sizeof(BufferLookupEnt));
 
        return size;
 }
index 9668eb6e4368fba7731f4d5051f97f738feba1fd..6388bc724d973f287347c690d6edb4caabc9fd17 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.38 2003/11/29 19:51:56 pgsql Exp $
+ *       $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.39 2004/01/15 16:14:26 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "storage/proc.h"
 #include "access/xact.h"
 
-#define STRAT_LIST_UNUSED      -1
-#define STRAT_LIST_B1          0
-#define STRAT_LIST_T1          1
-#define STRAT_LIST_T2          2
-#define STRAT_LIST_B2          3
-#define STRAT_NUM_LISTS                4
-
 #ifndef MAX
 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
 #endif
 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
 #endif
 
-/*
- * The Cache Directory Block (CDB) of the Adaptive Replacement Cache (ARC)
- */
-typedef struct bufstratcdb
-{
-       int                             prev;           /* links in the queue */
-       int                             next;
-       int                             list;           /* current list */
-       BufferTag               buf_tag;        /* buffer key */
-       Buffer                  buf_id;         /* currently assigned data buffer */
-       TransactionId   t1_xid;         /* the xid this entry went onto T1 */
-} BufferStrategyCDB;
-
-/*
- * The shared ARC control information.
- */
-typedef struct bufstratcontrol
-{
-
-       int             target_T1_size;                         /* What T1 size are we aiming for */
-       int             listUnusedCDB;                          /* All unused StrategyCDB */
-       int             listHead[STRAT_NUM_LISTS];      /* ARC lists B1, T1, T2 and B2 */
-       int             listTail[STRAT_NUM_LISTS];
-       int             listSize[STRAT_NUM_LISTS];
-       Buffer  listFreeBuffers;                        /* List of unused buffers */
-
-       long    num_lookup;                                     /* Some hit statistics */
-       long    num_hit[STRAT_NUM_LISTS];
-       time_t  stat_report;
-
-       BufferStrategyCDB       cdb[1];                 /* The cache directory */
-} BufferStrategyControl;
-
 static BufferStrategyControl   *StrategyControl = NULL;
 static BufferStrategyCDB               *StrategyCDB = NULL;
 
index 9e7864c750812f5d4fe184bb05aeccede8ac4d8a..ce4be5439b4d2a5712643f6ab9f305e82e68e16a 100644 (file)
@@ -1,13 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * buf_internals.h
- *       Internal definitions for buffer manager.
+ *       Internal definitions for buffer manager and the buffer replacement
+ *    strategy.
  *
  *
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.66 2003/12/14 00:34:47 neilc Exp $
+ * $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.67 2004/01/15 16:14:26 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -135,6 +136,49 @@ typedef struct
        Buffer          id;
 } BufferLookupEnt;
 
+/*
+ * Definitions for the buffer replacement strategy
+ */
+#define STRAT_LIST_UNUSED      -1
+#define STRAT_LIST_B1          0
+#define STRAT_LIST_T1          1
+#define STRAT_LIST_T2          2
+#define STRAT_LIST_B2          3
+#define STRAT_NUM_LISTS                4
+
+/*
+ * The Cache Directory Block (CDB) of the Adaptive Replacement Cache (ARC)
+ */
+typedef struct
+{
+       int                             prev;           /* links in the queue */
+       int                             next;
+       int                             list;           /* current list */
+       BufferTag               buf_tag;        /* buffer key */
+       Buffer                  buf_id;         /* currently assigned data buffer */
+       TransactionId   t1_xid;         /* the xid this entry went onto T1 */
+} BufferStrategyCDB;
+
+/*
+ * The shared ARC control information.
+ */
+typedef struct
+{
+
+       int             target_T1_size;                         /* What T1 size are we aiming for */
+       int             listUnusedCDB;                          /* All unused StrategyCDB */
+       int             listHead[STRAT_NUM_LISTS];      /* ARC lists B1, T1, T2 and B2 */
+       int             listTail[STRAT_NUM_LISTS];
+       int             listSize[STRAT_NUM_LISTS];
+       Buffer  listFreeBuffers;                        /* List of unused buffers */
+
+       long    num_lookup;                                     /* Some hit statistics */
+       long    num_hit[STRAT_NUM_LISTS];
+       time_t  stat_report;
+
+       BufferStrategyCDB       cdb[1];                 /* The cache directory */
+} BufferStrategyControl;
 /* counters in buf_init.c */
 extern long int ReadBufferCount;
 extern long int ReadLocalBufferCount;