On Tuesday, May 21, 2013, Simon Riggs wrote:

> I worked up a small patch to support Terabyte setting for memory.
> Which is OK, but it only works for 1TB, not for 2TB or above.
>

I've incorporated my review into a new version, attached.

Added "TB" to the docs, added the macro KB_PER_TB, and made "show" to print
"1TB" rather than "1024GB".

I tested several of the memory settings to see that it can be set and
retrieved.  I haven't tested actual execution as I don't have that kind of
RAM.

I don't see how it could have a performance impact, it passes make check
etc., and I don't think it warrants a new regression test.

I'll set it to ready for committer.

Cheers,

Jeff
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
new file mode 100644
index c7d84b5..940ed6e
*** a/doc/src/sgml/config.sgml
--- b/doc/src/sgml/config.sgml
***************
*** 39,45 ****
       For convenience,
       a different unit can also be specified explicitly.  Valid memory units
       are <literal>kB</literal> (kilobytes), <literal>MB</literal>
!      (megabytes), and <literal>GB</literal> (gigabytes); valid time units
       are <literal>ms</literal> (milliseconds), <literal>s</literal>
       (seconds), <literal>min</literal> (minutes), <literal>h</literal>
       (hours), and <literal>d</literal> (days).  Note that the multiplier
--- 39,45 ----
       For convenience,
       a different unit can also be specified explicitly.  Valid memory units
       are <literal>kB</literal> (kilobytes), <literal>MB</literal>
!      (megabytes), <literal>GB</literal> (gigabytes), and <literal>TB</literal> (terabytes); valid time units
       are <literal>ms</literal> (milliseconds), <literal>s</literal>
       (seconds), <literal>min</literal> (minutes), <literal>h</literal>
       (hours), and <literal>d</literal> (days).  Note that the multiplier
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
new file mode 100644
index ea16c64..0e5b0c9
*** a/src/backend/utils/misc/guc.c
--- b/src/backend/utils/misc/guc.c
***************
*** 105,110 ****
--- 105,111 ----
  
  #define KB_PER_MB (1024)
  #define KB_PER_GB (1024*1024)
+ #define KB_PER_TB (1024*1024*1024)
  
  #define MS_PER_S 1000
  #define S_PER_MIN 60
*************** parse_int(const char *value, int *result
*** 4837,4843 ****
  		{
  			/* Set hint for use if no match or trailing garbage */
  			if (hintmsg)
! 				*hintmsg = gettext_noop("Valid units for this parameter are \"kB\", \"MB\", and \"GB\".");
  
  #if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
  #error BLCKSZ must be between 1KB and 1MB
--- 4838,4844 ----
  		{
  			/* Set hint for use if no match or trailing garbage */
  			if (hintmsg)
! 				*hintmsg = gettext_noop("Valid units for this parameter are \"kB\", \"MB\", \"GB\" and \"TB\".");
  
  #if BLCKSZ < 1024 || BLCKSZ > (1024*1024)
  #error BLCKSZ must be between 1KB and 1MB
*************** parse_int(const char *value, int *result
*** 4891,4896 ****
--- 4892,4913 ----
  						break;
  				}
  			}
+ 			else if (strncmp(endptr, "TB", 2) == 0)
+ 			{
+ 				endptr += 2;
+ 				switch (flags & GUC_UNIT_MEMORY)
+ 				{
+ 					case GUC_UNIT_KB:
+ 						val *= KB_PER_TB;
+ 						break;
+ 					case GUC_UNIT_BLOCKS:
+ 						val *= KB_PER_TB / (BLCKSZ / 1024);
+ 						break;
+ 					case GUC_UNIT_XBLOCKS:
+ 						val *= KB_PER_TB / (XLOG_BLCKSZ / 1024);
+ 						break;
+ 				}
+ 			}
  		}
  		else if (flags & GUC_UNIT_TIME)
  		{
*************** _ShowOption(struct config_generic * reco
*** 7384,7390 ****
  								break;
  						}
  
! 						if (result % KB_PER_GB == 0)
  						{
  							result /= KB_PER_GB;
  							unit = "GB";
--- 7401,7412 ----
  								break;
  						}
  
! 						if (result % KB_PER_TB == 0)
! 						{
! 							result /= KB_PER_TB;
! 							unit = "TB";
! 						}
! 						else if (result % KB_PER_GB == 0)
  						{
  							result /= KB_PER_GB;
  							unit = "GB";
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to