public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Torvald Riegel <triegel@redhat.com>
To: Carlos O'Donell <carlos@redhat.com>,
	"H.J. Lu" <hjl.tools@gmail.com>,
	 Szabolcs Nagy <Szabolcs.Nagy@arm.com>,
	libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH] NUMA spinlock [BZ #23962]
Date: Mon, 14 Jan 2019 23:03:00 -0000	[thread overview]
Message-ID: <42b74adc5bb6197df2cc5643b32838301908c0e9.camel@redhat.com> (raw)
In-Reply-To: <d4b9e25e-8884-b01f-040e-b6f40e011033@redhat.com>

On Sat, 2019-01-05 at 07:34 -0500, Carlos O'Donell wrote:
> On 1/3/19 2:58 PM, H.J. Lu wrote:
> > +libpthread {
> > +  GLIBC_2.29 {
> > +    numa_spinlock_alloc;
> > +    numa_spinlock_free;
> > +    numa_spinlock_init;
> > +    numa_spinlock_apply;
> > +  }
> > +}
> 
> Why are we adding these non-standard interfaces to glibc?

I also think that there shouldn't be a new API added for these.  There
would be the option of adding a new pthread_mutex_t type, and thus even get
some more space for the implementation, but I wouldn't like that either.

What I think we should be doing instead:

(1) Finally add proper spinning and back-off throughout our synchronization
abstractions (spinlocks, mutexes, etc.; see my other comment on this
thread).  This should improve performance significantly, either through
less contention during spinning, or through doing more spinning and thus
less trips through futexes and the kernel.

(2) Change the synchronization abstractions (especially mutexes) so that
they can efficiently run different code paths when they are of non-process-
shared type, and then start with doing things like MCS in the non-process-
shared mutexes.

For both of these, add proper benchmarks so that tuning decisions can be
checked automatically and tested for regressions.  IOW, we want tests for
whether the tuning decisions are still the correct ones (in the future, or
on future HW).

The main reason why I think that's a better approach is that the biggest
return on the investments by the glibc community is improving performance
for as many users as possible, even if it may not be ideal performance for
those unchanged programs.  Adding a special API+implementation instead
might enable somewhat larger performance improvements, but it requires
programs to change and programmers to be aware of it, so will likely remain
a niche case in practice.

> It could be implemented as a distinct library, allowed to evolve quickly
> in response to customer need, and eventually integrated into glibc if the
> API proves stable. A similar model has been setup by Boost and C++ just to
> draw some parallels.

I think first of all, we should try hard to get as much as performance out
of the interfaces, POSIX semantics constraints, and ABI constraints we have
today.  Then maybe change the ABI if it really unlocks further benefits.

If that's not sufficient to get decent performance, then I think the next
venue to look at is C++.  That is, if implementing these ideas to the full
extent is not possible in glibc, go to libstdc++ instead and see what's
possible there.  C++'s synchronization constructs have saner semantics than
POSIX's, and ABI breaks in the future are more likely for C++ than for
glibc.
If the current C++ synchronization constructs have semantics that inhibit
performance, then ISO C++ Study Group 1 will likely want to hear about it. 
And they are a much better group to discuss this than the glibc community
is, simply because they are focused on just parallelism and concurrency.

  parent reply	other threads:[~2019-01-14 23:03 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-26  9:51 Ma Ling
2019-01-03  4:05 ` 马凌(彦军)
     [not found]   ` <0a474516-b8c8-48cf-aeea-e57c77b78cbd.ling.ml@antfin.com>
2019-01-03  5:35     ` 转发:[PATCH] " 马凌(彦军)
2019-01-03 14:52       ` Szabolcs Nagy
2019-01-03 19:59         ` H.J. Lu
2019-01-05 12:34           ` [PATCH] " Carlos O'Donell
2019-01-05 16:36             ` H.J. Lu
2019-01-07 19:12               ` Florian Weimer
2019-01-07 19:49                 ` H.J. Lu
2019-01-10 16:31                   ` Carlos O'Donell
2019-01-10 16:32                     ` Florian Weimer
2019-01-10 16:41                       ` Carlos O'Donell
2019-01-10 17:52                         ` Szabolcs Nagy
2019-01-10 19:24                           ` Carlos O'Donell
2019-01-11 12:01                             ` kemi
2019-01-14 22:45                         ` Torvald Riegel
2019-01-15  9:32                           ` Florian Weimer
2019-01-15 12:01                             ` Torvald Riegel
2019-01-15 12:17                               ` Florian Weimer
2019-01-15 12:31                                 ` Torvald Riegel
2019-01-11 16:24                       ` H.J. Lu
2019-01-14 23:03             ` Torvald Riegel [this message]
2019-01-04  4:13         ` 转发:[PATCH] " 马凌(彦军)
2019-01-03 20:43 ` [PATCH] " Rich Felker
2019-01-03 20:55   ` H.J. Lu
2019-01-03 21:21     ` Rich Felker
2019-01-03 21:28       ` H.J. Lu
2019-01-14 23:18       ` Torvald Riegel
2019-01-15  2:33         ` kemi
2019-01-15 12:37           ` Torvald Riegel
2019-01-15 16:44             ` Rich Felker
2019-01-17  3:10             ` kemi
2019-02-04 17:23               ` Torvald Riegel
2019-01-14 22:40     ` Torvald Riegel
2019-01-14 23:26 ` Torvald Riegel
2019-01-15  4:47   ` 马凌(彦军)
2019-01-15  2:56 ` kemi
2019-01-15  4:27   ` 马凌(彦军)
2019-01-10 13:18 马凌(彦军)

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=42b74adc5bb6197df2cc5643b32838301908c0e9.camel@redhat.com \
    --to=triegel@redhat.com \
    --cc=Szabolcs.Nagy@arm.com \
    --cc=carlos@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /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).