Hi,

I was toying around with idea of converting all the memory related parameters 
in postgresql.conf to kilobytes for simplicity and uniformity.

Attached is a proof of concept patch that converts shared_buffers to kilobytes 
using assign_hook.

It compiled all-right but I experienced a strange behavior. At the time of 
initdb, it demanded 69MB of shared memory. I had to bump up SHMMAX from 32MB 
to 128MB to get initdb through. Certainly I did something wrong somewhere but 
I don't know what and where. This is linux 2.6.4.

The postgresql.conf is properly altered and shows 8000(Though the description 
around is no longer in sync.)

I also don't know where to put the assign_hook. I have put in guc.c for the 
time being. Only other int hook I found was assign_max_stack_depth which is 
in postgres.c

Any comments/pointers?

Regards,
 Shridhar
*** src/backend/utils/misc/guc.c.orig	Sun May 30 17:14:08 2004
--- src/backend/utils/misc/guc.c	Sun May 30 18:02:10 2004
***************
*** 106,111 ****
--- 106,112 ----
  static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);
  static bool assign_log_stats(bool newval, bool doit, GucSource source);
  
+ static bool assign_shared_buffers(int newval, bool doit, GucSource source);
  
  /*
   * Debugging options
***************
*** 967,973 ****
  			NULL
  		},
  		&NBuffers,
! 		1000, 16, INT_MAX, NULL, NULL
  	},
  
  	{
--- 968,974 ----
  			NULL
  		},
  		&NBuffers,
! 		1000, 16, INT_MAX, assign_shared_buffers, NULL
  	},
  
  	{
***************
*** 5130,5133 ****
--- 5131,5147 ----
  }
  
  
+ static bool assign_shared_buffers(int newval, bool doit, GucSource source)
+ {
+ 	
+ 	if(doit)
+ 	{
+ 	 	if(BLCKSZ > 0)
+ 			NBuffers = (newval*1024)/BLCKSZ;				
+ 		else
+ 			return(false);	
+ 	}
+ 	
+ 	return(true);
+ }
  #include "guc-file.c"
*** src/bin/initdb/initdb.c.orig	Sun May 30 17:26:01 2004
--- src/bin/initdb/initdb.c	Sun May 30 17:26:51 2004
***************
*** 886,892 ****
  	snprintf(repltok, sizeof(repltok), "max_connections = %d", n_connections);
  	conflines = replace_token(conflines, "#max_connections = 100", repltok);
  
! 	snprintf(repltok, sizeof(repltok), "shared_buffers = %d", n_buffers);
  	conflines = replace_token(conflines, "#shared_buffers = 1000", repltok);
  
  	snprintf(repltok, sizeof(repltok), "lc_messages = '%s'", lc_messages);
--- 886,892 ----
  	snprintf(repltok, sizeof(repltok), "max_connections = %d", n_connections);
  	conflines = replace_token(conflines, "#max_connections = 100", repltok);
  
! 	snprintf(repltok, sizeof(repltok), "shared_buffers = %d", (n_buffers*BLCKSZ)/1024);
  	conflines = replace_token(conflines, "#shared_buffers = 1000", repltok);
  
  	snprintf(repltok, sizeof(repltok), "lc_messages = '%s'", lc_messages);
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to