Re: [HACKERS] spin locks

From: dg(at)illustra(dot)com (David Gould)
To: maillist(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian)
Cc: scrappy(at)hub(dot)org, dz(at)cs(dot)unitn(dot)it, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] spin locks
Date: 1998-03-16 23:38:10
Message-ID: 9803162338.AA19224@hawk.illustra.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > On Sun, 15 Feb 1998, Bruce Momjian wrote:
> >
> > > > I'm not quite sure I follow this...in a multi-cpu environment,
> > > > would process_yield() introduce a problem? *raised eyebrow*
> > >
> > > Probably. I would leave the code as-is for multi-cpu systems.

My experience with exactly this suggests that it doesn't.

> > So...how would we determine which is which? *raised eyebrow*
> >
> > > Yep, but we need to check for multiple cpu's first before enabling it.
> > > That would be a good trick from configure.
> >
> > I'm curious, still, as to whether this function would help
> > performance on a multi-cpu environment as well...what if 2 processes are
> > running on one of two CPUs, and another 2 on the other? *raised eyebrow*

Unless you have more CPU's than proccesses, having the spinlocks back off
is a win. Since there are not too many lightly loaded 64 cpu machines out
there, for all pratical cases it is a win.

> Good point. You would almost need to know if the one holding the lock
> was currently running. But it wouldn't be un-runnable while it was
> holding the spinlock, so it should be run-able, even if it is not
> currently running.

But, it can't run until everyone else has run out their timeslice pounding
on the spinlock. Even worse, the effect is to convoy all the backends together
so it becomes even more likely that a spinlock will be contended in the future.

The cpu_yield() or (more portably) select() style of backoff works pretty well.

> Bruce Momjian | 830 Blythe Avenue
> maillist(at)candle(dot)pha(dot)pa(dot)us | Drexel Hill, Pennsylvania 19026

-dg

David Gould dg(at)illustra(dot)com 510.628.3783 or 510.305.9468
Informix Software (No, really) 300 Lakeside Drive Oakland, CA 94612
- I realize now that irony has no place in business communications.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jackson, DeJuan 1998-03-17 01:41:38 RE: [QUESTIONS] The Complete and Ccomprehensive list of Newbie qu estion
Previous Message David Gould 1998-03-16 23:27:02 Re: [HACKERS] Re: [PATCHES] patches for 6.2.1p6