Hello Tidy Bot, David Ribeiro Alves, Kudu Jenkins, Adar Dembo,
I'd like you to reexamine a change. Please visit
http://gerrit.cloudera.org:8080/8257
to look at the new patch set (#5).
Change subject: thread: improve performance of starting threads
......................................................................
thread: improve performance of starting threads
This improves the performance of starting a new thread using
kudu::Thread::StartThread(). Previously, the process of starting the
thread was a little bit more complicated than necessary, involving a
sequence of the child waiting for the parent to do something, then the
parent waiting for the child to do something. Now, neither one has to
wait for the other to proceed.
The one wrinkle here is that for the parent to know the child's tid, it
does have to wait for it to publish it. However, usage of the 'tid()'
function is relatively rare, so we can defer that waiting until someone
accesses it, and then only wait in the odd case that it hasn't yet
published.
This patch includes a very simple benchmark which starts 1000 threads
and then checks the pid for each.
Timings based on the 'Time spent' log output:
---------------------------------------------
Before:
wall user sys
Min. :0.06500 Min. :0.0080 Min. :0.0160
1st Qu.:0.06975 1st Qu.:0.0160 1st Qu.:0.0200
Median :0.07100 Median :0.0200 Median :0.0240
Mean :0.07080 Mean :0.0198 Mean :0.0234
3rd Qu.:0.07200 3rd Qu.:0.0240 3rd Qu.:0.0280
Max. :0.08200 Max. :0.0280 Max. :0.0320
After:
wall user sys
Min. :0.01800 Min. :0.0040 Min. :0.000
1st Qu.:0.02575 1st Qu.:0.0080 1st Qu.:0.012
Median :0.02700 Median :0.0120 Median :0.016
Mean :0.02680 Mean :0.0126 Mean :0.016
3rd Qu.:0.02925 3rd Qu.:0.0160 3rd Qu.:0.020
Max. :0.03200 Max. :0.0280 Max. :0.028
perf-stat results
------------------
Before:
Performance counter stats for 'build/latest/bin/thread-test
--gtest_filter=*Benchmark* --gtest_repeat=10' (10 runs):
1095.617237 task-clock (msec) # 0.863 CPUs utilized
( +- 0.54% )
29,552 context-switches # 0.027 M/sec
( +- 0.75% )
354 cpu-migrations # 0.323 K/sec
( +- 4.55% )
20,848 page-faults # 0.019 M/sec
( +- 0.11% )
2,424,700,945 cycles # 2.213 GHz
( +- 0.35% )
1,369,266,675 instructions # 0.56 insn per cycle
( +- 0.12% )
286,851,480 branches # 261.817 M/sec
( +- 0.11% )
5,926,839 branch-misses # 2.07% of all branches
( +- 0.39% )
1.269172342 seconds time elapsed
( +- 0.33% )
After:
Performance counter stats for 'build/latest/bin/thread-test
--gtest_filter=*Benchmark* --gtest_repeat=10' (10 runs):
790.618424 task-clock (msec) # 1.677 CPUs utilized
( +- 0.77% )
17,178 context-switches # 0.022 M/sec
( +- 0.91% )
3,869 cpu-migrations # 0.005 M/sec
( +- 0.76% )
20,921 page-faults # 0.026 M/sec
( +- 0.05% )
2,149,909,940 cycles # 2.719 GHz
( +- 0.41% )
1,149,982,930 instructions # 0.53 insn per cycle
( +- 0.09% )
239,776,764 branches # 303.277 M/sec
( +- 0.08% )
4,890,927 branch-misses # 2.04% of all branches
( +- 0.62% )
0.471358038 seconds time elapsed
( +- 0.76% )
Change-Id: I5ce7f409ed33548142d1180c9f9653a8f51a7879
---
M src/kudu/client/client-test.cc
M src/kudu/util/thread-test.cc
M src/kudu/util/thread.cc
M src/kudu/util/thread.h
4 files changed, 105 insertions(+), 53 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/57/8257/5
--
To view, visit http://gerrit.cloudera.org:8080/8257
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I5ce7f409ed33548142d1180c9f9653a8f51a7879
Gerrit-Change-Number: 8257
Gerrit-PatchSet: 5
Gerrit-Owner: Todd Lipcon <[email protected]>
Gerrit-Reviewer: Adar Dembo <[email protected]>
Gerrit-Reviewer: David Ribeiro Alves <[email protected]>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <[email protected]>