You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Adar Dembo (Code Review)" <ge...@cloudera.org> on 2020/03/18 08:46:18 UTC

[kudu-CR] metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Hello Alexey Serbin, Andrew Wong,

I'd like you to do a code review. Please visit

    http://gerrit.cloudera.org:8080/15474

to review the following change.


Change subject: metrics: replace kudu::Bind usage with lambdas in FunctionGauge
......................................................................

metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Let's start with a little history lesson. Back in 2014, we imported
Chromium's Bind (and associated machinery) into gutil as kudu::Bind. At the
time we hadn't migrated to C++11, so we couldn't use lambdas, and the
kudu::Bind feature set was rich[1], at least as compared to boost::bind.

Now that we're on C++11 and can use lambdas, there's very little that
kudu::Bind can do that lambdas can't. The only thing that comes to mind is
passing ownership of an object to a callback via the kudu::Owned() or
kudu::Passed() wrappers, and we're not using those features. So in the
interest of modernizing the Kudu codebase a bit, I'm going to replace
kudu::Bind with lambdas. Lambdas are simpler, can be more easily inlined by
the compiler, and will result in a reduction of code at the end when we
remove kudu::Bind and friends from the repo.

This patch kicks off the conversion process by using lambdas in
FunctionGauge, which is a heavily used source of kudu::Bind.

1. See commit 66282df07.

Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
---
M src/kudu/clock/builtin_ntp.cc
M src/kudu/clock/hybrid_clock.cc
M src/kudu/clock/logical_clock.cc
M src/kudu/codegen/compilation_manager.cc
M src/kudu/consensus/consensus-test-util.h
M src/kudu/consensus/raft_consensus.cc
M src/kudu/master/ts_manager.cc
M src/kudu/rpc/retriable_rpc.h
M src/kudu/server/tcmalloc_metrics.cc
M src/kudu/tablet/tablet.cc
M src/kudu/tablet/tablet_replica-test.cc
M src/kudu/tablet/tablet_replica.cc
M src/kudu/tserver/scanners.cc
M src/kudu/tserver/tablet_server-test.cc
M src/kudu/tserver/ts_tablet_manager.cc
M src/kudu/util/metrics-test.cc
M src/kudu/util/metrics.cc
M src/kudu/util/metrics.h
M src/kudu/util/net/dns_resolver.cc
M src/kudu/util/spinlock_profiling.cc
M src/kudu/util/thread.cc
21 files changed, 129 insertions(+), 157 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/74/15474/1
-- 
To view, visit http://gerrit.cloudera.org:8080/15474
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
Gerrit-Change-Number: 15474
Gerrit-PatchSet: 1
Gerrit-Owner: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>

[kudu-CR] metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Posted by "Andrew Wong (Code Review)" <ge...@cloudera.org>.
Andrew Wong has posted comments on this change. ( http://gerrit.cloudera.org:8080/15474 )

Change subject: metrics: replace kudu::Bind usage with lambdas in FunctionGauge
......................................................................


Patch Set 2: Code-Review+2

(1 comment)

http://gerrit.cloudera.org:8080/#/c/15474/2/src/kudu/consensus/consensus-test-util.h
File src/kudu/consensus/consensus-test-util.h:

http://gerrit.cloudera.org:8080/#/c/15474/2/src/kudu/consensus/consensus-test-util.h@39
PS2, Line 39: #include "kudu/gutil/bind.h"
:( that this file has boost::bind, std::bind and kudu::Bind. Thanks for making an effort to pare this down.



-- 
To view, visit http://gerrit.cloudera.org:8080/15474
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
Gerrit-Change-Number: 15474
Gerrit-PatchSet: 2
Gerrit-Owner: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Bankim Bhavsar <ba...@cloudera.com>
Gerrit-Comment-Date: Thu, 19 Mar 2020 06:05:11 +0000
Gerrit-HasComments: Yes

[kudu-CR] metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/15474 )

Change subject: metrics: replace kudu::Bind usage with lambdas in FunctionGauge
......................................................................

metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Let's start with a little history lesson. Back in 2014, we imported
Chromium's Bind (and associated machinery) into gutil as kudu::Bind. At the
time we hadn't migrated to C++11, so we couldn't use lambdas, and the
kudu::Bind feature set was rich[1], at least as compared to boost::bind.

Now that we're on C++11 and can use lambdas, there's very little that
kudu::Bind can do that lambdas can't. The only thing that comes to mind is
passing ownership of an object to a callback via the kudu::Owned() or
kudu::Passed() wrappers, and we're not using those features. So in the
interest of modernizing the Kudu codebase a bit, I'm going to replace
kudu::Bind with lambdas. Lambdas are simpler, can be more easily inlined by
the compiler, and will result in a reduction of code at the end when we
remove kudu::Bind and friends from the repo.

This patch kicks off the conversion process by using lambdas in
FunctionGauge, which is a heavily used source of kudu::Bind.

1. See commit 66282df07.

Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
Reviewed-on: http://gerrit.cloudera.org:8080/15474
Reviewed-by: Bankim Bhavsar <ba...@cloudera.com>
Tested-by: Adar Dembo <ad...@cloudera.com>
Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
M src/kudu/clock/builtin_ntp.cc
M src/kudu/clock/hybrid_clock.cc
M src/kudu/clock/logical_clock.cc
M src/kudu/codegen/compilation_manager.cc
M src/kudu/consensus/consensus-test-util.h
M src/kudu/consensus/raft_consensus.cc
M src/kudu/master/ts_manager.cc
M src/kudu/rpc/retriable_rpc.h
M src/kudu/server/tcmalloc_metrics.cc
M src/kudu/tablet/tablet.cc
M src/kudu/tablet/tablet_replica-test.cc
M src/kudu/tablet/tablet_replica.cc
M src/kudu/tserver/scanners.cc
M src/kudu/tserver/tablet_server-test.cc
M src/kudu/tserver/ts_tablet_manager.cc
M src/kudu/util/metrics-test.cc
M src/kudu/util/metrics.cc
M src/kudu/util/metrics.h
M src/kudu/util/net/dns_resolver.cc
M src/kudu/util/spinlock_profiling.cc
M src/kudu/util/thread.cc
21 files changed, 131 insertions(+), 157 deletions(-)

Approvals:
  Bankim Bhavsar: Looks good to me, but someone else must approve
  Adar Dembo: Verified
  Andrew Wong: Looks good to me, approved

-- 
To view, visit http://gerrit.cloudera.org:8080/15474
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
Gerrit-Change-Number: 15474
Gerrit-PatchSet: 3
Gerrit-Owner: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Bankim Bhavsar <ba...@cloudera.com>

[kudu-CR] metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Hello Alexey Serbin, Kudu Jenkins, Andrew Wong, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/15474

to look at the new patch set (#2).

Change subject: metrics: replace kudu::Bind usage with lambdas in FunctionGauge
......................................................................

metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Let's start with a little history lesson. Back in 2014, we imported
Chromium's Bind (and associated machinery) into gutil as kudu::Bind. At the
time we hadn't migrated to C++11, so we couldn't use lambdas, and the
kudu::Bind feature set was rich[1], at least as compared to boost::bind.

Now that we're on C++11 and can use lambdas, there's very little that
kudu::Bind can do that lambdas can't. The only thing that comes to mind is
passing ownership of an object to a callback via the kudu::Owned() or
kudu::Passed() wrappers, and we're not using those features. So in the
interest of modernizing the Kudu codebase a bit, I'm going to replace
kudu::Bind with lambdas. Lambdas are simpler, can be more easily inlined by
the compiler, and will result in a reduction of code at the end when we
remove kudu::Bind and friends from the repo.

This patch kicks off the conversion process by using lambdas in
FunctionGauge, which is a heavily used source of kudu::Bind.

1. See commit 66282df07.

Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
---
M src/kudu/clock/builtin_ntp.cc
M src/kudu/clock/hybrid_clock.cc
M src/kudu/clock/logical_clock.cc
M src/kudu/codegen/compilation_manager.cc
M src/kudu/consensus/consensus-test-util.h
M src/kudu/consensus/raft_consensus.cc
M src/kudu/master/ts_manager.cc
M src/kudu/rpc/retriable_rpc.h
M src/kudu/server/tcmalloc_metrics.cc
M src/kudu/tablet/tablet.cc
M src/kudu/tablet/tablet_replica-test.cc
M src/kudu/tablet/tablet_replica.cc
M src/kudu/tserver/scanners.cc
M src/kudu/tserver/tablet_server-test.cc
M src/kudu/tserver/ts_tablet_manager.cc
M src/kudu/util/metrics-test.cc
M src/kudu/util/metrics.cc
M src/kudu/util/metrics.h
M src/kudu/util/net/dns_resolver.cc
M src/kudu/util/spinlock_profiling.cc
M src/kudu/util/thread.cc
21 files changed, 131 insertions(+), 157 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/74/15474/2
-- 
To view, visit http://gerrit.cloudera.org:8080/15474
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
Gerrit-Change-Number: 15474
Gerrit-PatchSet: 2
Gerrit-Owner: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)

[kudu-CR] metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has removed Kudu Jenkins from this change.  ( http://gerrit.cloudera.org:8080/15474 )

Change subject: metrics: replace kudu::Bind usage with lambdas in FunctionGauge
......................................................................


Removed reviewer Kudu Jenkins with the following votes:

* Verified-1 by Kudu Jenkins (120)
-- 
To view, visit http://gerrit.cloudera.org:8080/15474
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: deleteReviewer
Gerrit-Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
Gerrit-Change-Number: 15474
Gerrit-PatchSet: 2
Gerrit-Owner: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Bankim Bhavsar <ba...@cloudera.com>

[kudu-CR] metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change. ( http://gerrit.cloudera.org:8080/15474 )

Change subject: metrics: replace kudu::Bind usage with lambdas in FunctionGauge
......................................................................


Patch Set 2: Verified+1

Overriding Jenkins, known mt-tablet-test flake.


-- 
To view, visit http://gerrit.cloudera.org:8080/15474
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
Gerrit-Change-Number: 15474
Gerrit-PatchSet: 2
Gerrit-Owner: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Bankim Bhavsar <ba...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Wed, 18 Mar 2020 23:13:30 +0000
Gerrit-HasComments: No

[kudu-CR] metrics: replace kudu::Bind usage with lambdas in FunctionGauge

Posted by "Bankim Bhavsar (Code Review)" <ge...@cloudera.org>.
Bankim Bhavsar has posted comments on this change. ( http://gerrit.cloudera.org:8080/15474 )

Change subject: metrics: replace kudu::Bind usage with lambdas in FunctionGauge
......................................................................


Patch Set 2: Code-Review+1


-- 
To view, visit http://gerrit.cloudera.org:8080/15474
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: If60a0dabde1fde1465d73dd9e8edc244fc780c37
Gerrit-Change-Number: 15474
Gerrit-PatchSet: 2
Gerrit-Owner: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Bankim Bhavsar <ba...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Wed, 18 Mar 2020 22:22:33 +0000
Gerrit-HasComments: No