[PATCH] benchtests: Add pthread_once common-case test.
Will Newton
will.newton@linaro.org
Mon Mar 31 10:03:00 GMT 2014
On 31 March 2014 10:21, Will Newton <will.newton@linaro.org> wrote:
> On 9 October 2013 03:04, Siddhesh Poyarekar <siddhesh@redhat.com> wrote:
>> On Wed, Oct 09, 2013 at 12:09:46AM +0300, Torvald Riegel wrote:
>>> This adds a benchtest for the common-case scenario for pthread_once.
>>>
>>> We have a single thread that runs a no-op initialization once and then
>>> repeatedly runs checks of the initialization (i.e., an acquire load and
>>> conditional jump) in a tight loop. This gives us, on average, the
>>> best-case latency of pthread_once (the initialization is the
>>> exactly-once slow path, and we're not looking at initialization-related
>>> synchronization overheads in this case). I'm adding this to investigate
>>> whether we still need the x86-custom pthread_once version written in
>>> assembler, or whether we can use the generic version without a
>>> performance loss (both use the same algorithm).
>>>
>>> This needs the other patch that adds the include-sources directive to
>>> scripts/bench.pl.
>>>
>>> OK?
>>
>>> commit a26cb3d5ffd621b756a951a53bd160811d0f3fae
>>> Author: Torvald Riegel <triegel@redhat.com>
>>> Date: Tue Oct 8 14:17:01 2013 +0300
>>>
>>> benchtests: Add pthread_once common-case test.
>>>
>>> * benchtests/pthread_once-inputs: New file.
>>> * benchtests/pthread_once-source.c: New file.
>>> * benchtests/README: Update documentation.
>>>
>>> diff --git a/ChangeLog b/ChangeLog
>>> index 1acd57c..61da75c 100644
>>> --- a/ChangeLog
>>> +++ b/ChangeLog
>>> @@ -1,5 +1,11 @@
>>> 2013-10-08 Torvald Riegel <triegel@redhat.com>
>>>
>>> + * benchtests/pthread_once-inputs: New file.
>>> + * benchtests/pthread_once-source.c: New file.
>>> + * benchtests/README: Update documentation.
>>> +
>>> +2013-10-08 Torvald Riegel <triegel@redhat.com>
>>> +
>>> * scripts/bench.pl: Add include-sources directive.
>>> * benchtests/README: Update documentation.
>>>
>>
>> You don't need to post ChangeLog diffs here. Also, if you have back
>> to back changes on the same day, you could merge the entries by
>> leaving a blank line between the change sets like this:
>>
>> 2013-10-08 Torvald Riegel <triegel@redhat.com>
>>
>> * benchtests/pthread_once-inputs: New file.
>> * benchtests/pthread_once-source.c: New file.
>> * benchtests/README: Update documentation.
>>
>> * scripts/bench.pl: Add include-sources directive.
>> * benchtests/README: Update documentation.
>>
>>> diff --git a/benchtests/Makefile b/benchtests/Makefile
>>> index aec395a..2eb1393 100644
>>> --- a/benchtests/Makefile
>>> +++ b/benchtests/Makefile
>>> @@ -20,8 +20,8 @@
>>> # Add benchmark functions in alphabetical order.
>>>
>>> subdir := benchtests
>>> -bench := acos acosh asin asinh atan atanh cos cosh exp log modf pow rint sin \
>>> - sincos sinh tan tanh
>>> +bench := acos acosh asin asinh atan atanh cos cosh exp log modf pow \
>>> + pthread_once rint sin sincos sinh tan tanh
>>>
>>> # String function benchmarks.
>>> string-bench := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
>>> @@ -45,6 +45,7 @@ LDLIBS-bench-cosh = -lm
>>> LDLIBS-bench-exp = -lm
>>> LDLIBS-bench-log = -lm
>>> LDLIBS-bench-pow = -lm
>>> +LDLIBS-bench-pthread_once = -lpthread
>>> LDLIBS-bench-rint = -lm
>>> LDLIBS-bench-sin = -lm
>>> LDLIBS-bench-sinh = -lm
>>> diff --git a/benchtests/README b/benchtests/README
>>> index 0c643a6..9dcbc53 100644
>>> --- a/benchtests/README
>>> +++ b/benchtests/README
>>> @@ -57,6 +57,8 @@ one to add `foo' to the bench tests:
>>> - include-sources: This should be assigned a comma-separated list of source
>>> files that need to be included to provide definitions of global variables
>>> and functions (specifically, this includes using "#include "source").
>>> + See pthread_once-inputs and pthreads_once-source.c for an example of how
>>> + to use this to benchmark a function that needs state across several calls.
>>> - name: See following section for instructions on how to use this directive.
>>>
>>> Lines beginning with a single hash '#' are treated as comments. See
>>> diff --git a/benchtests/pthread_once-inputs b/benchtests/pthread_once-inputs
>>> new file mode 100644
>>> index 0000000..040bc5c
>>> --- /dev/null
>>> +++ b/benchtests/pthread_once-inputs
>>> @@ -0,0 +1,10 @@
>>> +# This tests the common-case scenario for pthread_once.
>>> +# We have a single thread that runs a no-op initialization once and then
>>> +# repeatedly runs checks of the initialization (i.e., an acquire load and
>>> +# conditional jump) in a tight loop.
>>> +# scripts/bench.pl doesn't handle function pointers, so we just use void *:
Also a minor nit - this should now be bench.py.
--
Will Newton
Toolchain Working Group, Linaro
More information about the Libc-alpha
mailing list