> > > 	* Order duplicate index entries by tid
> > 
> > In other words - add tid to index key: very old idea.
> 
> I was thinking during index creation, it would be nice to
> order them by tid, but not do lots of work to keep it that way.

I hear this "not do lots of work" so often from you -:)
Days of simplicity are gone, Bruce. To continue, this project
requires more and more complex solutions.

> > > 	* Add queue of backends waiting for spinlock
> > 
> > We shouldn't mix two different approaches for different
> > kinds of short-time internal locks - in one cases we need in
> > light lmgr (when we're going to keep lock long enough, eg for IO)
> > and in another cases we'd better to proceed with POSIX' mutex-es
> > or semaphores instead of spinlocks. Queueing backends waiting
> > for spinlock sounds like nonsense - how are you going to protect
> > such queue? With spinlocks? -:)
> 
> Yes, I guess so but hopefully we can spin waiting for the queue lock
> rather than sleep. We could use POSIX spinlocks/semaphores now but we
> don't because of performance, right?

No. As long as no one proved with test that mutexes are bad for
performance...
Funny, such test would require ~ 1 day of work.

> Should we be spinning waiting for spinlock on multi-cpu machines?  Is
> that the answer?

What do you mean?

Vadim

Mon, 30 Jul 2001 10:45:30 -0700
"Mikheev, Vadim" <vmikheev@SECTORBASE.COM>
RE: Performance TODO items
> > > > 	* Order duplicate index entries by tid
> > > 
> > > In other words - add tid to index key: very old idea.
> > 
> > I was thinking during index creation, it would be nice to
> > order them by tid, but not do lots of work to keep it that way.
> 
> I hear this "not do lots of work" so often from you -:)
> Days of simplicity are gone, Bruce. To continue, this project
> requires more and more complex solutions.

Yep.  I can dream.  :-)

> > > > 	* Add queue of backends waiting for spinlock
> > > 
> > > We shouldn't mix two different approaches for different
> > > kinds of short-time internal locks - in one cases we need in
> > > light lmgr (when we're going to keep lock long enough, eg for IO)
> > > and in another cases we'd better to proceed with POSIX' mutex-es
> > > or semaphores instead of spinlocks. Queueing backends waiting
> > > for spinlock sounds like nonsense - how are you going to protect
> > > such queue? With spinlocks? -:)
> > 
> > Yes, I guess so but hopefully we can spin waiting for the queue lock
> > rather than sleep. We could use POSIX spinlocks/semaphores now but we
> > don't because of performance, right?
> 
> No. As long as no one proved with test that mutexes are bad for
> performance...
> Funny, such test would require ~ 1 day of work.

Good question.  I know the number of function calls to spinlock stuff is
huge.  Seems real semaphores may be a big win on multi-cpu boxes.

> > Should we be spinning waiting for spinlock on multi-cpu machines?  Is
> > that the answer?
> 
> What do you mean?

On a single-cpu machine, if you can't get the spinlock, you should just
sleep and let the process who had it continue.  On a multi-cpu machine,
you perhaps should just keep trying, hoping that the process who holds
it finishes soon.  I wonder is we should find some kind of test on
postmaster startup that would test to see if we have multiple cpu's and
change from spinlock sleeping to spinlock spin-waiting.

Add to this that fact we can't sleep for less than on clock tick on most
machines, 10ms, and the spinlock stuff needs work.

TODO updated:

* Improve spinlock code, perhaps with OS semaphores, sleeper queue, or 
  spining to obtain lock on multi-cpu systems

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Mon, 30 Jul 2001 13:58:15 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Performance TODO items
On Mon, 30 Jul 2001, Bruce Momjian wrote:

> * Improve spinlock code, perhaps with OS semaphores, sleeper queue, or
>   spining to obtain lock on multi-cpu systems

You may be interested in a discussion which happened over on
linux-kernel a few months ago.

Quite a lot of people want a lightweight userspace semaphore,
and for pretty much the same reasons.

Linus proposed a pretty interesting solution which has the
same minimal overhead as the current spinlocks in the non-
contention case, but avoids the spin where there's contention:

http://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg39615.html

Matthew.


Tue, 31 Jul 2001 10:12:14 +0100 (BST)
Matthew Kirkwood <matthew@hairy.beasts.org>
Re: Performance TODO items
> On Mon, 30 Jul 2001, Bruce Momjian wrote:
> 
> > * Improve spinlock code, perhaps with OS semaphores, sleeper queue, or
> >   spining to obtain lock on multi-cpu systems
> 
> You may be interested in a discussion which happened over on
> linux-kernel a few months ago.
> 
> Quite a lot of people want a lightweight userspace semaphore,
> and for pretty much the same reasons.
> 
> Linus proposed a pretty interesting solution which has the
> same minimal overhead as the current spinlocks in the non-
> contention case, but avoids the spin where there's contention:
> 
> http://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg39615.html

Yes, many OS's have user-space spinlocks, for the same performance
reasons (no kernel call).

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Tue, 31 Jul 2001 09:18:57 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Performance TODO items