Alexey Serbin has submitted this change and it was merged. ( )

Change subject: Fix move constructors to be noexcept

Fix move constructors to be noexcept

I noticed while looking at a profile of a tablet server starting up that
I saw a lot of CPU used in stacks like:

  kudu::subtle::RefCountedThreadSafeBase::AddRef() const
  void std::vector<scoped_refptr<kudu::fs::internal::LogBlock>>::

Digging into the source of std::vector, I saw that the emplace_back_aux
function is used when emplacing requires resizing the underlying array.
Since scoped_refptr has a move constructor I was surprised to see it
using AddRef() here during the array expansion. In fact it turns out
that std::vector<> will only use the move constructor when it is marked
'noexcept', which ours was not.

I verified this with a simple test program as well[1]. If the move
constructor is marked 'noexcept', it is called. Otherwise, it is not.

This patch corrects scoped_refptr as well as a few other spots where we
had move constructors without noexcept.


Change-Id: Idd7487766be3261e3506ff9613a5d733013018b0
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <>
M src/kudu/cfile/block_cache.h
M src/kudu/cfile/block_handle.h
M src/kudu/gutil/ref_counted.h
M src/kudu/tablet/
M src/kudu/tablet/lock_manager.h
M src/kudu/util/cow_object.h
M src/kudu/util/status.h
7 files changed, 17 insertions(+), 17 deletions(-)

  Kudu Jenkins: Verified
  Alexey Serbin: Looks good to me, approved

To view, visit
To unsubscribe, visit

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Idd7487766be3261e3506ff9613a5d733013018b0
Gerrit-Change-Number: 9382
Gerrit-PatchSet: 3
Gerrit-Owner: Todd Lipcon <>
Gerrit-Reviewer: Alexey Serbin <>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <>

Reply via email to