On Tue, 2010-05-04 at 21:34 +0200, Stefan Kaltenbrunner wrote:

> FWIW - I'm seeing a behaviour here under pgbench -S workloads that looks 
> kinda related.
> 
> using -j 16 -c 16 -T 120 I get either 100000tps and around 660000 
> contextswitches per second or on some runs I end up with 150000tps and 
> around 1M contextswitches/s sustained. I mostly get the 100k result but 
> once in a while I get the 150k one. And one even can anticipate the 
> final transaction rate from watching "vmstat 1"...
> 
> I'm not sure yet on what is causing that behaviour but that is with 
> 9.0B1 on a Dual Quadcore Nehalem box with 16 cpu threads (8+HT) on a 
> pure in-memory workload (scale = 20 with 48GB RAM).

Educated guess at a fix: please test this patch. It's good for
performance testing, but doesn't work correctly at failover, which would
obviously be addressed prior to any commit.

-- 
 Simon Riggs           www.2ndQuadrant.com
*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
***************
*** 158,163 **** static XLogRecPtr LastRec;
--- 158,164 ----
   * known, need to check the shared state".
   */
  static bool LocalRecoveryInProgress = true;
+ static bool KnownRecoveryState = false;
  
  /*
   * Local state for XLogInsertAllowed():
***************
*** 6524,6537 **** CheckRecoveryConsistency(void)
  bool
  RecoveryInProgress(void)
  {
! 	/*
! 	 * We check shared state each time only until we leave recovery mode. We
! 	 * can't re-enter recovery, so there's no need to keep checking after the
! 	 * shared variable has once been seen false.
! 	 */
! 	if (!LocalRecoveryInProgress)
! 		return false;
! 	else
  	{
  		/* use volatile pointer to prevent code rearrangement */
  		volatile XLogCtlData *xlogctl = XLogCtl;
--- 6525,6533 ----
  bool
  RecoveryInProgress(void)
  {
! 	if (KnownRecoveryState)
! 		return LocalRecoveryInProgress;
! 	else		
  	{
  		/* use volatile pointer to prevent code rearrangement */
  		volatile XLogCtlData *xlogctl = XLogCtl;
***************
*** 6541,6546 **** RecoveryInProgress(void)
--- 6537,6544 ----
  		LocalRecoveryInProgress = xlogctl->SharedRecoveryInProgress;
  		SpinLockRelease(&xlogctl->info_lck);
  
+ 		KnownRecoveryState = true;
+ 
  		/*
  		 * Initialize TimeLineID and RedoRecPtr when we discover that recovery
  		 * is finished. InitPostgres() relies upon this behaviour to ensure
-- 
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