public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Torvald Riegel <triegel@redhat.com>
Cc: Florian Weimer <fw@deneb.enyo.de>,
	GLIBC Devel <libc-alpha@sourceware.org>,
	Carlos O'Donell <codonell@redhat.com>
Subject: Re: [PATCH v2] rwlock: Fix explicit hand-over.
Date: Mon, 27 Mar 2017 19:11:00 -0000	[thread overview]
Message-ID: <61697d56-abf5-41fc-9e7d-623e05084cdd@redhat.com> (raw)
In-Reply-To: <58a61371-e31e-055a-d561-c0e1c13eb7c1@redhat.com>

On 03/27/2017 02:59 PM, Waiman Long wrote:
> On 03/27/2017 02:16 PM, Waiman Long wrote:
>> On 03/27/2017 01:53 PM, Torvald Riegel wrote:
>>> On Mon, 2017-03-27 at 12:09 -0400, Waiman Long wrote:
>>>> On 03/25/2017 07:01 PM, Torvald Riegel wrote:
>>>>> On Sat, 2017-03-25 at 21:17 +0100, Florian Weimer wrote:
>>>>>> * Torvald Riegel:
>>>>>>
>>>>>>> +  bool registered_while_in_write_phase = false;
>>>>>>>    if (__glibc_likely ((r & PTHREAD_RWLOCK_WRPHASE) == 0))
>>>>>>>      return 0;
>>>>>>> +  else
>>>>>>> +    registered_while_in_write_phase = true;
>>>>>> Sorry, this doesn't look quite right.  Isn't
>>>>>> registered_while_in_write_phase always true?
>>>>> Attached is a v2 patch.  It's the same logic, but bigger.  Most of this
>>>>> increase is due to reformatting, but I also adapted some of the
>>>>> comments.
>>>>> I get two failures, but I guess these are either due to the bad internet
>>>>> connectivity I currently have, or something at the resolver.
>>>>> FAIL: resolv/mtrace-tst-leaks
>>>>> FAIL: resolv/tst-leaks
>>>>>
>>>>>
>>>> I have verified that the v2 patch did fix the hang that I saw with my
>>>> microbenchmark. I also observed an increase in performance in the new
>>>> rwlock code compared with the old one before the major rewrite.
>>> Thanks!
>>>
>>>> On a
>>>> 4-socket 40-core 80-thread system, 80 parallel locking threads had an
>>>> average per-thread throughput of 32,584 ops/s. The old rwlock code had a
>>>> throughput of 13,411 only. So there is a more than 1.4X increase in
>>>> performance.
>>> Is that with the 50% reads / 50% writes workload (per thread), empty
>>> critical sections, and no delay between critical sections?
>>>
>> Yes, I used the default configuration of 1:1 read/write ratio. The
>> critical section isn't exactly empty as I used 1 pause instruction for
>> both in the critical section and between critical section.
>>
>> Regards,
>> Longman
>>
> Just found out that there is a regression in performance when in writer
> preferring mode. The average per-thread throughput was 4,733 ops/s with
> the old glibc, but 2,300 ops/s with the new implementation vs 32,584
> ops/s for the reader-preferring mode. It was said in the code that
> writer-preferring mode isn't the focus in the rewrite. So I am not
> saying that it is bad, but it is something to keep in mind about.
>
> Regards,
> Longman

Another issue that I saw was lock starvation. IOW, a continuous stream
of readers will block writers from acquiring the lock in
reader-preferring mode. In writer-preferring mode, a continuous stream
of writers will block readers from the acquiring the lock. You can see
that by using the -x option in my rwlock benchmark which will force the
separation of reader and writer threads instead of every thread doing
both reader and writer locks.

Again, this may not be an issue as most workloads won't have this kind
of extreme locking pattern.

Cheers,
Longman


  reply	other threads:[~2017-03-27 19:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-25 19:50 [PATCH] " Torvald Riegel
2017-03-25 20:17 ` Florian Weimer
2017-03-25 20:39   ` Torvald Riegel
2017-03-25 23:01   ` [PATCH v2] " Torvald Riegel
2017-03-27 16:09     ` Waiman Long
2017-03-27 17:54       ` Torvald Riegel
2017-03-27 18:16         ` Waiman Long
2017-03-27 18:59           ` Waiman Long
2017-03-27 19:11             ` Waiman Long [this message]
2017-04-06 10:51               ` Torvald Riegel
2017-04-06 10:47             ` Torvald Riegel
2017-04-06 10:51     ` Ping! " Torvald Riegel
2017-07-28  5:41     ` Carlos O'Donell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61697d56-abf5-41fc-9e7d-623e05084cdd@redhat.com \
    --to=longman@redhat.com \
    --cc=codonell@redhat.com \
    --cc=fw@deneb.enyo.de \
    --cc=libc-alpha@sourceware.org \
    --cc=triegel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).