Re: libpq Win32 Mutex performance patch

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
Cc: "Andrew Chernow" <ac(at)esilo(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: libpq Win32 Mutex performance patch
Date: 2008-04-15 08:09:44
Message-ID: 20080415100944.5821b768@mha-laptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Merlin Moncure wrote:
> On Fri, Apr 11, 2008 at 2:49 PM, Magnus Hagander
> <magnus(at)hagander(dot)net> wrote:
> > Andrew Chernow wrote:
> > > I noticed several months ago, and came across it again today,
> > > that libpq's pthread-win32.c implementation is using CreateMutex
> > > rather than CRITICAL_SECTION. CreateMutex is like a semaphore
> > > in that it is designed to be accessible via name system-wide.
> > > Even when you don't give it a name, thus bound to process that
> > > created it, it still carries significant overhead compared to
> > > using win32 CRITICAL_SECTIONs.
> > >
> > > The attached patch replaces the win32 mutex calls with critical
> > > section calls. The change will not affect the behavior of the
> > > windows pthread_xxx functions.
> >
> > First of all, I like this in general :-) But a couple of comments.
> >
> > It changes the behavior when the pointer passed in is invalid from
> > crash to silent working, right? This shouldn't actually matter,
> > since these functions are only ever supposed to run from callers
> > *inside libpq*, so it probalby doesn't matter...
>
> I noticed you conjured up a ecpg threading patch sometime around early
> 2007. You used a mutex there deliberately because that's what libpq
> did. Maybe that patch should be adjusted?

Yes, I think it should.

//Magnus

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Brendan Jurd 2008-04-15 08:11:32 Re: printTable API (was: Show INHERIT in \du)
Previous Message Magnus Hagander 2008-04-15 08:07:55 Re: libpq Win32 Mutex performance patch