lkml.org 
[lkml]   [2014]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 1/2] qspinlock: Introducing a 4-byte queue spinlock implementation
On Wed, Feb 05, 2014 at 10:10:34PM -0500, Waiman Long wrote:
> On 02/03/2014 06:40 AM, Peter Zijlstra wrote:
> >On Fri, Jan 31, 2014 at 02:24:33PM -0500, Waiman Long wrote:
> >>Light contention is the only case where the qspinlock may not perform as
> >>good as the ticket spinlock. I know this is the most common case. However, I
> >>would argue that the slowdown, if any, will not be really noticeable. This
> >>is what I will try to find out.
> >Please also explain why things are slower/faster. Thomas tried to get
> >you to do so a few months back, but you kept deflecting.
>
> It is not easy to have a test case to test light contention. I am
> trying to create custom test case to get that data.

Here are some ways of doing that:

1. Provide (say) a thousand locks for each thread, so that you
have all of these locks in one big array of locks. Have each
thread loop, where each pass through the loop acquires
and releases a randomly selected lock. Then measure the
acquisition/release throughput.

2. As #1 above, but vary the number of locks per thread in order to
vary the level of contention in a controlled manner. Note that
the cache-miss probability is (N-1)/N, where where N is the
number of threads, at least assuming each thread gets its own CPU.

3. Provide each thread with its own lock and have each thread
loop, where each pass through the loop acquires and releases
the thread's lock. This eliminates both contention and
cache misses.

4. As #1 above, but randomly acquire some other thread's lock with
controlled probability to introduce controlled levels of both
contention and cache misses.

5. As #4 above, but provide each thread with multiple locks
randomly selected to allow cache miss rate to be increased
independently of contention.

All approaches require extremely efficient random-number generators,
for example, independent per-thread generators.

Thanx, Paul



\
 
 \ /
  Last update: 2014-02-07 20:01    [W:0.068 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site