Re: [HACKERS] SO_SNDBUF size is small on win32?

Поиск
Список
Период
Сортировка
Искать

Re: [HACKERS] SO_SNDBUF size is small on win32?

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Yoshiyuki Asaba wrote:
> Hi,
> 
> I see a performance issue on win32. This problem is causes by the
> following URL. 
> 
> http://support.microsoft.com/kb/823764/EN-US/
> 
> On win32, default SO_SNDBUF value is 8192 bytes. And libpq's buffer is
> 8192 too.
> 
> pqcomm.c:117
>   #define PQ_BUFFER_SIZE 8192
> 
> send() may take as long as 200ms. So, I think we should increase
> SO_SNDBUF to more than 8192. I attache the patch.

Based on this patch and comments, I have applied a patch that sets the
buffer to 32k, and adds the URL in a comment.  I think there was
concensus that there is no need for this to be used on the client side,
only the server.

Thanks.

-- 
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/libpq/pqcomm.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v
retrieving revision 1.186
diff -c -c -r1.186 pqcomm.c
*** src/backend/libpq/pqcomm.c	14 Jul 2006 05:28:27 -0000	1.186
--- src/backend/libpq/pqcomm.c	11 Aug 2006 20:41:35 -0000
***************
*** 593,598 ****
--- 593,612 ----
  			return STATUS_ERROR;
  		}
  
+ #ifdef WIN32
+ 		/*
+ 		 *	This is a Win32 socket optimization.  The ideal size is 32k.
+ 		 *	http://support.microsoft.com/kb/823764/EN-US/
+ 		 */
+ 		on = PQ_BUFFER_SIZE * 4;
+ 		if (setsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &on,
+ 			sizeof(on)) < 0)
+ 		{
+ 			elog(LOG, "setsockopt(SO_SNDBUF) failed: %m");
+ 			return STATUS_ERROR;
+ 		}
+ #endif
+ 
  		/*
  		 * Also apply the current keepalive parameters.  If we fail to set a
  		 * parameter, don't error out, because these aren't universally

Re: [HACKERS] SO_SNDBUF size is small on win32?

От:
Yoshiyuki Asaba <y-asaba@sraoss.co.jp>
Дата:
Hi,

From: Bruce Momjian 
Subject: Re: [PATCHES] [HACKERS] SO_SNDBUF size is small on win32?
Date: Fri, 11 Aug 2006 16:44:23 -0400 (EDT)

> Based on this patch and comments, I have applied a patch that sets the
> buffer to 32k, and adds the URL in a comment. 

Is it backported to 8.1.x and 8.0.x?

Regards,
--
Yoshiyuki Asaba
y-asaba@sraoss.co.jp

Re: [HACKERS] SO_SNDBUF size is small on win32?

От:
Bruce Momjian <bruce@momjian.us>
Дата:
Yoshiyuki Asaba wrote:
> Hi,
> 
> From: Bruce Momjian 
> Subject: Re: [PATCHES] [HACKERS] SO_SNDBUF size is small on win32?
> Date: Fri, 11 Aug 2006 16:44:23 -0400 (EDT)
> 
> > Based on this patch and comments, I have applied a patch that sets the
> > buffer to 32k, and adds the URL in a comment. 
> 
> Is it backported to 8.1.x and 8.0.x?

No, it is too untested for backpatching, in my opinion.

-- 
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
FAQ