You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Todd Lipcon (Code Review)" <ge...@cloudera.org> on 2017/05/04 01:06:59 UTC
[kudu-CR] process memory: incrementally track total process consumption
Hello Jean-Daniel Cryans, Adar Dembo,
I'd like you to do a code review. Please visit
http://gerrit.cloudera.org:8080/6793
to review the following change.
Change subject: process_memory: incrementally track total process consumption
......................................................................
process_memory: incrementally track total process consumption
This switches CurrentConsumption() from calling into TCMalloc to instead
using its own tracking, based on installing new/delete hooks into
tcmalloc. The hooks incrementally update a global LongAdder for
consumption, and we just query that object when we need to know the
current value.
This is meant to address a performance regression seen on YCSB where the
tablet server spends a lot of time in tcmalloc::ThreadCache::GetThreadStats
trying to compute memory usage.
I wrote a small micro-benchmark which starts 200 threads which allocate
memory and call CurrentConsumption(). Without the patch, it only
performed about 650K iters/sec. With the patch, it performs around 5M
iters/sec. With no tracking at all (no hooks and no consumption calls)
the performance is around 25M iterations/second. So, we are definitely
paying some cost for the hooks, but this should at least be an
improvement. If it doesn't win back all the performance, we can look for
an even better approach.
On the side, this changes process_memory to use GoogleOnce instead of
std::once. This sped up the microbenchmark significantly (almost 2x),
apparently due to better inlining.
Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
---
M src/kudu/util/CMakeLists.txt
A src/kudu/util/process_memory-test.cc
M src/kudu/util/process_memory.cc
3 files changed, 131 insertions(+), 25 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/93/6793/1
--
To view, visit http://gerrit.cloudera.org:8080/6793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Jean-Daniel Cryans <jd...@apache.org>
[kudu-CR] process memory: incrementally track total process consumption
Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Adar Dembo, Kudu Jenkins,
I'd like you to reexamine a change. Please visit
http://gerrit.cloudera.org:8080/6793
to look at the new patch set (#2).
Change subject: process_memory: incrementally track total process consumption
......................................................................
process_memory: incrementally track total process consumption
This switches CurrentConsumption() from calling into TCMalloc to instead
using its own tracking, based on installing new/delete hooks into
tcmalloc. The hooks incrementally update a global LongAdder for
consumption, and we just query that object when we need to know the
current value.
This is meant to address a performance regression seen on YCSB where the
tablet server spends a lot of time in tcmalloc::ThreadCache::GetThreadStats
trying to compute memory usage.
I wrote a small micro-benchmark which starts 200 threads which allocate
memory and call CurrentConsumption(). Without the patch, it only
performed about 650K iters/sec. With the patch, it performs around 5M
iters/sec. With no tracking at all (no hooks and no consumption calls)
the performance is around 25M iterations/second. So, we are definitely
paying some cost for the hooks, but this should at least be an
improvement. If it doesn't win back all the performance, we can look for
an even better approach.
On the side, this changes process_memory to use GoogleOnce instead of
std::once. This sped up the microbenchmark significantly (almost 2x),
apparently due to better inlining.
Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
---
M src/kudu/tserver/tablet_server-stress-test.cc
M src/kudu/util/CMakeLists.txt
A src/kudu/util/process_memory-test.cc
M src/kudu/util/process_memory.cc
M src/kudu/util/process_memory.h
5 files changed, 151 insertions(+), 26 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/93/6793/2
--
To view, visit http://gerrit.cloudera.org:8080/6793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Jean-Daniel Cryans <jd...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
[kudu-CR] process memory: incrementally track total process consumption
Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.
Change subject: process_memory: incrementally track total process consumption
......................................................................
Patch Set 1:
(3 comments)
http://gerrit.cloudera.org:8080/#/c/6793/1//COMMIT_MSG
Commit Message:
PS1, Line 9: This switches CurrentConsumption() from calling into TCMalloc to instead
: using its own tracking, based on installing new/delete hooks into
: tcmalloc. The hooks incrementally update a global LongAdder for
: consumption, and we just query that object when we need to know the
: current value.
> Is there any deviation between our tracked value and the TCMalloc reported
I'll try running a workload, and also see if I can sneak it into any stress test.
PS1, Line 28: On the side, this changes process_memory to use GoogleOnce instead of
: std::once. This sped up the microbenchmark significantly (almost 2x),
: apparently due to better inlining.
> This is somewhat concerning. I presume your benchmark was on el6? Wondering
my benchmark was on my ubuntu 16.04 laptop with libstdcxx/gcc
http://gerrit.cloudera.org:8080/#/c/6793/1/src/kudu/util/CMakeLists.txt
File src/kudu/util/CMakeLists.txt:
Line 356: ADD_KUDU_TEST(process_memory-test RUN_SERIAL true)
> Nit: out of order.
Done
--
To view, visit http://gerrit.cloudera.org:8080/6793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Jean-Daniel Cryans <jd...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes
[kudu-CR] process memory: incrementally track total process consumption
Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change.
Change subject: process_memory: incrementally track total process consumption
......................................................................
Patch Set 1:
(3 comments)
http://gerrit.cloudera.org:8080/#/c/6793/1//COMMIT_MSG
Commit Message:
PS1, Line 9: This switches CurrentConsumption() from calling into TCMalloc to instead
: using its own tracking, based on installing new/delete hooks into
: tcmalloc. The hooks incrementally update a global LongAdder for
: consumption, and we just query that object when we need to know the
: current value.
Is there any deviation between our tracked value and the TCMalloc reported value? Would be interesting to compare the two on a long-running (or heavily used) server, and perhaps enforce via test in some way.
PS1, Line 28: On the side, this changes process_memory to use GoogleOnce instead of
: std::once. This sped up the microbenchmark significantly (almost 2x),
: apparently due to better inlining.
This is somewhat concerning. I presume your benchmark was on el6? Wondering whether it's still true with a more modern libstdc++; can you try on Ubuntu 16.04?
http://gerrit.cloudera.org:8080/#/c/6793/1/src/kudu/util/CMakeLists.txt
File src/kudu/util/CMakeLists.txt:
Line 356: ADD_KUDU_TEST(process_memory-test RUN_SERIAL true)
Nit: out of order.
--
To view, visit http://gerrit.cloudera.org:8080/6793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Jean-Daniel Cryans <jd...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-HasComments: Yes
[kudu-CR] process memory: incrementally track total process consumption
Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change.
Change subject: process_memory: incrementally track total process consumption
......................................................................
Patch Set 1:
(1 comment)
http://gerrit.cloudera.org:8080/#/c/6793/1//COMMIT_MSG
Commit Message:
PS1, Line 28: On the side, this changes process_memory to use GoogleOnce instead of
: std::once. This sped up the microbenchmark significantly (almost 2x),
: apparently due to better inlining.
> my benchmark was on my ubuntu 16.04 laptop with libstdcxx/gcc
Then I think we should strike std::once from the list of acceptable C++11 libraries and replace any existing calls with GoogleOnce, at least outside of unit tests. What do you think?
--
To view, visit http://gerrit.cloudera.org:8080/6793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Jean-Daniel Cryans <jd...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes
[kudu-CR] process memory: incrementally track total process consumption
Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.
Change subject: process_memory: incrementally track total process consumption
......................................................................
Patch Set 1:
(1 comment)
http://gerrit.cloudera.org:8080/#/c/6793/1//COMMIT_MSG
Commit Message:
PS1, Line 28: On the side, this changes process_memory to use GoogleOnce instead of
: std::once. This sped up the microbenchmark significantly (almost 2x),
: apparently due to better inlining.
> Then I think we should strike std::once from the list of acceptable C++11 l
I don't think the other ones are perf-sensitive.
So, I guess it depends: is it beneficial to be more "standard" in the places that aren't perf sensitive, but be inconsistent? or better to just have one way to do it?
One downside of GoogleOnce is that it isn't lambda-enabled.
--
To view, visit http://gerrit.cloudera.org:8080/6793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Jean-Daniel Cryans <jd...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes
[kudu-CR] process memory: incrementally track total process consumption
Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.
Change subject: process_memory: incrementally track total process consumption
......................................................................
Patch Set 1:
(1 comment)
http://gerrit.cloudera.org:8080/#/c/6793/1//COMMIT_MSG
Commit Message:
PS1, Line 28: On the side, this changes process_memory to use GoogleOnce instead of
: std::once. This sped up the microbenchmark significantly (almost 2x),
: apparently due to better inlining.
> I took a quick look at the existing instances and I agree that they're not
yea, it was pretty obvious in the profile (calls to pthread_once were taking 16% of CPU)
--
To view, visit http://gerrit.cloudera.org:8080/6793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Jean-Daniel Cryans <jd...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes
[kudu-CR] process memory: incrementally track total process consumption
Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has submitted this change and it was merged.
Change subject: process_memory: incrementally track total process consumption
......................................................................
process_memory: incrementally track total process consumption
This switches CurrentConsumption() from calling into TCMalloc to instead
using its own tracking, based on installing new/delete hooks into
tcmalloc. The hooks incrementally update a global LongAdder for
consumption, and we just query that object when we need to know the
current value.
This is meant to address a performance regression seen on YCSB where the
tablet server spends a lot of time in tcmalloc::ThreadCache::GetThreadStats
trying to compute memory usage.
I wrote a small micro-benchmark which starts 200 threads which allocate
memory and call CurrentConsumption(). Without the patch, it only
performed about 650K iters/sec. With the patch, it performs around 5M
iters/sec. With no tracking at all (no hooks and no consumption calls)
the performance is around 25M iterations/second. So, we are definitely
paying some cost for the hooks, but this should at least be an
improvement. If it doesn't win back all the performance, we can look for
an even better approach.
On the side, this changes process_memory to use GoogleOnce instead of
std::once. This sped up the microbenchmark significantly (almost 2x),
apparently due to better inlining.
Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Reviewed-on: http://gerrit.cloudera.org:8080/6793
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins
---
M src/kudu/tserver/tablet_server-stress-test.cc
M src/kudu/util/CMakeLists.txt
A src/kudu/util/process_memory-test.cc
M src/kudu/util/process_memory.cc
M src/kudu/util/process_memory.h
5 files changed, 151 insertions(+), 26 deletions(-)
Approvals:
Adar Dembo: Looks good to me, approved
Kudu Jenkins: Verified
--
To view, visit http://gerrit.cloudera.org:8080/6793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Gerrit-PatchSet: 3
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Jean-Daniel Cryans <jd...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
[kudu-CR] process memory: incrementally track total process consumption
Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change.
Change subject: process_memory: incrementally track total process consumption
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
http://gerrit.cloudera.org:8080/#/c/6793/1//COMMIT_MSG
Commit Message:
PS1, Line 28: On the side, this changes process_memory to use GoogleOnce instead of
: std::once. This sped up the microbenchmark significantly (almost 2x),
: apparently due to better inlining.
> I don't think the other ones are perf-sensitive.
I took a quick look at the existing instances and I agree that they're not perf-sensitive (the closest candidate is the one in InitKrb5Ctx, which I think is invoked on every connection negotiation).
So I think whether it should be allowed depends on whether you think we'd notice its introduction in future perf-sensitive code, and suggesting GoogleOnce then.
--
To view, visit http://gerrit.cloudera.org:8080/6793
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I3293110b7eda7f083bf400e165be3d782c441c49
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Jean-Daniel Cryans <jd...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes