Re: s_lock() seems too aggressive for machines with many sockets

From: Nils Goroll <slink(at)schokola(dot)de>
To: Jan Wieck <jan(at)wi3ck(dot)info>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: s_lock() seems too aggressive for machines with many sockets
Date: 2015-06-10 15:06:19
Message-ID: 5578526B.4080507@schokola.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/06/15 16:18, Jan Wieck wrote:
>
> I have played with test code that isolates a stripped down version of s_lock()
> and uses it with multiple threads. I then implemented multiple different
> versions of that s_lock(). The results with 200 concurrent threads are that
> using a __sync_val_compare_and_swap() to acquire the lock and then falling back
> to a futex() is limited to about 500,000 locks/second. Spinning for 10 times and
> then doing a usleep(1000) (one millisecond) gives me 25 million locks/second.
>
> Note that the __sync_val_compare_and_swap() GCC built in seems identical in
> performance with the assembler xchgb operation used by PostgreSQL today on x84_64.

These numbers don't work for me. Do IUC that you are not holding the lock for
any reasonable time? If yes, the test case is invalid (the uncontended case is
never relevant). If No, the numbers don't match up - if you held one lock for
1ms, you'd not get more than 1000 locks/s anyway. If you had 200 locks, you'd
get 200.000 locks/s.

Can you please explain what the message is you are trying to get across?

Thanks, Nils

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-06-10 15:07:38 Re: replication slot restart_lsn initialization
Previous Message Jan Wieck 2015-06-10 15:03:31 Re: s_lock() seems too aggressive for machines with many sockets