Created
June 12, 2013 05:55
-
-
Save Ilink/5763101 to your computer and use it in GitHub Desktop.
fastgin patch #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e3e7aa2249984e409f077732ee8cd95ff656f2a5 Mon Sep 17 00:00:00 2001 | |
From: Ian Link <Ian@Angler.(none)> | |
Date: Mon, 10 Jun 2013 23:19:07 -0700 | |
Subject: [PATCH 1/3] added separate limit for fastgin memory | |
--- | |
src/backend/access/gin/ginfast.c | 3 ++- | |
src/backend/utils/init/globals.c | 1 + | |
src/backend/utils/misc/guc.c | 12 ++++++++++++ | |
src/include/miscadmin.h | 1 + | |
4 files changed, 16 insertions(+), 1 deletions(-) | |
diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c | |
index 4f2c118..a12e384 100644 | |
--- a/src/backend/access/gin/ginfast.c | |
+++ b/src/backend/access/gin/ginfast.c | |
@@ -426,7 +426,8 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) | |
* | |
* ginInsertCleanup() should not be called inside our CRIT_SECTION. | |
*/ | |
- if (metadata->nPendingPages * GIN_PAGE_FREESIZE > work_mem * 1024L) | |
+ | |
+ if (metadata->nPendingPages * GIN_PAGE_FREESIZE > fastgin_mem * 1024L) | |
needCleanup = true; | |
UnlockReleaseBuffer(metabuffer); | |
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c | |
index 9f51929..e436d24 100644 | |
--- a/src/backend/utils/init/globals.c | |
+++ b/src/backend/utils/init/globals.c | |
@@ -99,6 +99,7 @@ int CTimeZone = 0; | |
bool enableFsync = true; | |
bool allowSystemTableMods = false; | |
int work_mem = 1024; | |
+int fastgin_mem = 128; | |
int maintenance_work_mem = 16384; | |
/* | |
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c | |
index ea16c64..2d46a11 100644 | |
--- a/src/backend/utils/misc/guc.c | |
+++ b/src/backend/utils/misc/guc.c | |
@@ -1711,6 +1711,18 @@ static struct config_int ConfigureNamesInt[] = | |
}, | |
{ | |
+ {"fastgin_mem", PGC_USERSET, RESOURCES_MEM, | |
+ gettext_noop("Sets the maximum memory to be used for fastgin operations."), | |
+ gettext_noop("This represents the maximum amount of space stored in " | |
+ "the fasgin heap."), | |
+ GUC_UNIT_KB | |
+ }, | |
+ &fastgin_mem, | |
+ 128, 64, MAX_KILOBYTES, | |
+ NULL, NULL, NULL | |
+ }, | |
+ | |
+ { | |
{"maintenance_work_mem", PGC_USERSET, RESOURCES_MEM, | |
gettext_noop("Sets the maximum memory to be used for maintenance operations."), | |
gettext_noop("This includes operations such as VACUUM and CREATE INDEX."), | |
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h | |
index be3add9..a8331e3 100644 | |
--- a/src/include/miscadmin.h | |
+++ b/src/include/miscadmin.h | |
@@ -230,6 +230,7 @@ extern int CTimeZone; | |
extern bool enableFsync; | |
extern bool allowSystemTableMods; | |
extern PGDLLIMPORT int work_mem; | |
+extern PGDLLIMPORT int fastgin_mem; | |
extern PGDLLIMPORT int maintenance_work_mem; | |
extern int VacuumCostPageHit; | |
-- | |
1.7.9 | |
From 731132bcf7a0e27c0965c2bef90e2a4b9b2ea63d Mon Sep 17 00:00:00 2001 | |
From: Ian Link <Ian@Angler.(none)> | |
Date: Tue, 11 Jun 2013 21:12:04 -0700 | |
Subject: [PATCH 2/3] added doc, sample config | |
--- | |
doc/src/sgml/config.sgml | 15 +++++++++++++++ | |
src/backend/access/gin/ginfast.c | 1 - | |
src/backend/utils/misc/guc.c | 2 +- | |
src/backend/utils/misc/postgresql.conf.sample | 1 + | |
4 files changed, 17 insertions(+), 2 deletions(-) | |
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml | |
index c7d84b5..7aac6df 100644 | |
--- a/doc/src/sgml/config.sgml | |
+++ b/doc/src/sgml/config.sgml | |
@@ -1162,6 +1162,21 @@ include 'filename' | |
</listitem> | |
</varlistentry> | |
+ <varlistentry id="guc-fastgin-mem" xreflabel="fastgin_mem"> | |
+ <term><varname>fastgin_mem</varname> (<type>integer</type>)</term> | |
+ <indexterm> | |
+ <primary><varname>fastgin_mem</> configuration parameter</primary> | |
+ </indexterm> | |
+ <listitem> | |
+ <para> | |
+ Specifies the amount of memory to be used by the fastgin cache before writing | |
+ to the GIN index itself. The value defaults to <literal>128kB</literal>. | |
+ The fastgin cache is more effective when it is small. The size of <varname>fastgin_mem</varname> | |
+ should be kept significantly lower than <varname>work_mem</varname>. | |
+ </para> | |
+ </listitem> | |
+ </varlistentry> | |
+ | |
<varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth"> | |
<term><varname>max_stack_depth</varname> (<type>integer</type>)</term> | |
<indexterm> | |
diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c | |
index a12e384..5b06626 100644 | |
--- a/src/backend/access/gin/ginfast.c | |
+++ b/src/backend/access/gin/ginfast.c | |
@@ -426,7 +426,6 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) | |
* | |
* ginInsertCleanup() should not be called inside our CRIT_SECTION. | |
*/ | |
- | |
if (metadata->nPendingPages * GIN_PAGE_FREESIZE > fastgin_mem * 1024L) | |
needCleanup = true; | |
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c | |
index 2d46a11..17f3c07 100644 | |
--- a/src/backend/utils/misc/guc.c | |
+++ b/src/backend/utils/misc/guc.c | |
@@ -1714,7 +1714,7 @@ static struct config_int ConfigureNamesInt[] = | |
{"fastgin_mem", PGC_USERSET, RESOURCES_MEM, | |
gettext_noop("Sets the maximum memory to be used for fastgin operations."), | |
gettext_noop("This represents the maximum amount of space stored in " | |
- "the fasgin heap."), | |
+ "the fastgin heap."), | |
GUC_UNIT_KB | |
}, | |
&fastgin_mem, | |
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample | |
index 0303ac7..fed8586 100644 | |
--- a/src/backend/utils/misc/postgresql.conf.sample | |
+++ b/src/backend/utils/misc/postgresql.conf.sample | |
@@ -121,6 +121,7 @@ | |
# It is not advisable to set max_prepared_transactions nonzero unless you | |
# actively intend to use prepared transactions. | |
#work_mem = 1MB # min 64kB | |
+#fasgin_mem = 128kB # min 64kB | |
#maintenance_work_mem = 16MB # min 1MB | |
#max_stack_depth = 2MB # min 100kB | |
-- | |
1.7.9 | |
From 53565ec20d02c19a3a35177f862be887bb2bf73a Mon Sep 17 00:00:00 2001 | |
From: Ian Link <Ian@Angler.(none)> | |
Date: Tue, 11 Jun 2013 22:51:04 -0700 | |
Subject: [PATCH 3/3] changed name | |
--- | |
doc/src/sgml/config.sgml | 8 ++++---- | |
src/backend/access/gin/ginfast.c | 2 +- | |
src/backend/utils/init/globals.c | 2 +- | |
src/backend/utils/misc/guc.c | 4 ++-- | |
src/include/miscadmin.h | 2 +- | |
5 files changed, 9 insertions(+), 9 deletions(-) | |
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml | |
index 7aac6df..c985e1a 100644 | |
--- a/doc/src/sgml/config.sgml | |
+++ b/doc/src/sgml/config.sgml | |
@@ -1162,16 +1162,16 @@ include 'filename' | |
</listitem> | |
</varlistentry> | |
- <varlistentry id="guc-fastgin-mem" xreflabel="fastgin_mem"> | |
- <term><varname>fastgin_mem</varname> (<type>integer</type>)</term> | |
+ <varlistentry id="guc-fastgin-mem" xreflabel="gin_fast_limit"> | |
+ <term><varname>gin_fast_limit</varname> (<type>integer</type>)</term> | |
<indexterm> | |
- <primary><varname>fastgin_mem</> configuration parameter</primary> | |
+ <primary><varname>gin_fast_limit</> configuration parameter</primary> | |
</indexterm> | |
<listitem> | |
<para> | |
Specifies the amount of memory to be used by the fastgin cache before writing | |
to the GIN index itself. The value defaults to <literal>128kB</literal>. | |
- The fastgin cache is more effective when it is small. The size of <varname>fastgin_mem</varname> | |
+ The fastgin cache is more effective when it is small. The size of <varname>gin_fast_limit</varname> | |
should be kept significantly lower than <varname>work_mem</varname>. | |
</para> | |
</listitem> | |
diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c | |
index 5b06626..3a243c3 100644 | |
--- a/src/backend/access/gin/ginfast.c | |
+++ b/src/backend/access/gin/ginfast.c | |
@@ -426,7 +426,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) | |
* | |
* ginInsertCleanup() should not be called inside our CRIT_SECTION. | |
*/ | |
- if (metadata->nPendingPages * GIN_PAGE_FREESIZE > fastgin_mem * 1024L) | |
+ if (metadata->nPendingPages * GIN_PAGE_FREESIZE > gin_fast_limit * 1024L) | |
needCleanup = true; | |
UnlockReleaseBuffer(metabuffer); | |
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c | |
index e436d24..f153b77 100644 | |
--- a/src/backend/utils/init/globals.c | |
+++ b/src/backend/utils/init/globals.c | |
@@ -99,7 +99,7 @@ int CTimeZone = 0; | |
bool enableFsync = true; | |
bool allowSystemTableMods = false; | |
int work_mem = 1024; | |
-int fastgin_mem = 128; | |
+int gin_fast_limit = 128; | |
int maintenance_work_mem = 16384; | |
/* | |
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c | |
index 17f3c07..c906338 100644 | |
--- a/src/backend/utils/misc/guc.c | |
+++ b/src/backend/utils/misc/guc.c | |
@@ -1711,13 +1711,13 @@ static struct config_int ConfigureNamesInt[] = | |
}, | |
{ | |
- {"fastgin_mem", PGC_USERSET, RESOURCES_MEM, | |
+ {"gin_fast_limit", PGC_USERSET, RESOURCES_MEM, | |
gettext_noop("Sets the maximum memory to be used for fastgin operations."), | |
gettext_noop("This represents the maximum amount of space stored in " | |
"the fastgin heap."), | |
GUC_UNIT_KB | |
}, | |
- &fastgin_mem, | |
+ &gin_fast_limit, | |
128, 64, MAX_KILOBYTES, | |
NULL, NULL, NULL | |
}, | |
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h | |
index a8331e3..c538a01 100644 | |
--- a/src/include/miscadmin.h | |
+++ b/src/include/miscadmin.h | |
@@ -230,7 +230,7 @@ extern int CTimeZone; | |
extern bool enableFsync; | |
extern bool allowSystemTableMods; | |
extern PGDLLIMPORT int work_mem; | |
-extern PGDLLIMPORT int fastgin_mem; | |
+extern PGDLLIMPORT int gin_fast_limit; | |
extern PGDLLIMPORT int maintenance_work_mem; | |
extern int VacuumCostPageHit; | |
-- | |
1.7.9 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment