Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "final" keyword and make methods protected. #14517

Merged
merged 16 commits into from
Mar 13, 2018

Conversation

makdharma
Copy link
Contributor

This adds extensibility to the API and makes custom implementation
of the server possible.

This adds extensibility to the API and makes custom implementation
of the server possible.
@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +1.1% +2.59Ki [None]                                                                               +6.83Ki  +0.1%
      +1.2% +2.50Ki [Unmapped]                                                                           +6.73Ki  +0.1%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
       +25%      +8 vtable for grpc::CompletionQueue                                                          +8   +25%
       +25%      +8 vtable for grpc::ServerCompletionQueue                                                    +8   +25%
  +0.4%    +140 src/cpp/server/server_cc.cc                                                             +140  +0.4%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +3.0%     +48 grpc::Server::SyncRequestThreadManager::DoWork                                           +48  +3.0%
       +34%     +47 grpc::Server::SyncRequestThreadManager::Wait                                             +47   +34%
      +3.7%     +41 grpc::Server::ShutdownInternal                                                           +41  +3.7%
      +0.8%     +16 grpc::Server::Start                                                                      +16  +0.8%
      +0.8%     +15 grpc::Server::Server                                                                     +15  +0.8%
      +2.5%      +6 [Unmapped]                                                                                +6  +2.5%
  +1.5%     +67 src/cpp/client/channel_cc.cc                                                             +67  +1.5%
      [NEW]     +67 grpc::CompletionQueue::Next                                                              +67  [NEW]
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%

  +0.8% +2.86Ki TOTAL                                                                                +7.09Ki  +0.1%



@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +1.1% +2.59Ki [None]                                                                               +6.83Ki  +0.1%
      +1.2% +2.50Ki [Unmapped]                                                                           +6.73Ki  +0.1%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
       +25%      +8 vtable for grpc::CompletionQueue                                                          +8   +25%
       +25%      +8 vtable for grpc::ServerCompletionQueue                                                    +8   +25%
  +0.4%    +140 src/cpp/server/server_cc.cc                                                             +140  +0.4%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +3.0%     +48 grpc::Server::SyncRequestThreadManager::DoWork                                           +48  +3.0%
       +34%     +47 grpc::Server::SyncRequestThreadManager::Wait                                             +47   +34%
      +3.7%     +41 grpc::Server::ShutdownInternal                                                           +41  +3.7%
      +0.8%     +16 grpc::Server::Start                                                                      +16  +0.8%
      +0.8%     +15 grpc::Server::Server                                                                     +15  +0.8%
      +2.5%      +6 [Unmapped]                                                                                +6  +2.5%
  +1.5%     +67 src/cpp/client/channel_cc.cc                                                             +67  +1.5%
      [NEW]     +67 grpc::CompletionQueue::Next                                                              +67  [NEW]
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%

  +0.8% +2.86Ki TOTAL                                                                                +7.09Ki  +0.1%



@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] Performance differences noted:
Benchmark                                      cpu_time    real_time
---------------------------------------------  ----------  -----------
BM_PumpStreamServerToClient<InProcess>/262144  -5%         -5%

@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
   +14%     +80 src/cpp/common/completion_queue_cc.cc                                                    +80   +14%
      [NEW]     +67 grpc::CompletionQueue::Next                                                              +67  [NEW]
       +43%     +13 [Unmapped]                                                                               +13   +43%
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%

 -------------- SHRINKING                                                                            --------------
  -0.3%    -104 src/cpp/server/server_cc.cc                                                             -104  -0.3%
      [DEL]    -194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    -194  [DEL]
     -10.9%    -121 grpc::Server::ShutdownInternal                                                          -121 -10.9%
     -26.8%     -37 grpc::Server::SyncRequestThreadManager::Wait                                             -37 -26.8%
      -2.3%      -8 grpc::ServerInterface::GenericAsyncRequest::GenericAsyncRequest                           -8  -2.3%
      -3.8%      -8 grpc::ServerInterface::RegisteredAsyncRequest::IssueRequest                               -8  -3.8%
      -5.2%      -8 grpc::Server::AddListeningPort                                                            -8  -5.2%
      -1.4%      -3 grpc::Server::InProcessChannel                                                            -3  -1.4%
     -37.5%      -3 grpc::Server::server                                                                      -3 -37.5%
     -37.5%      -3 grpc::Server::c_server                                                                    -3 -37.5%
  -0.4%     -16 src/cpp/client/channel_cc.cc                                                             -16  -0.4%
      -2.4%     -16 grpc::Channel::WaitForStateChangeImpl                                                    -16  -2.4%

 -+-+-+-+-+-+-+ MIXED                                                                                +-+-+-+-+-+-+-
  +1.1% +2.61Ki [None]                                                                                  -939  -0.0%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
       +23%     +24 [None]                                                                                     0  [ = ]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
       +25%      +8 vtable for grpc::CompletionQueue                                                          +8   +25%
       +25%      +8 vtable for grpc::ServerCompletionQueue                                                    +8   +25%

  +0.7% +2.63Ki TOTAL                                                                                   -912  -0.0%



@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] Performance differences noted:
Benchmark                                                           cpu_time    real_time
------------------------------------------------------------------  ----------  -----------
BM_StreamingPingPong<InProcess, NoOpMutator, NoOpMutator>/262144/2  -5%         -5%

@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
   +14%     +80 src/cpp/common/completion_queue_cc.cc                                                    +80   +14%
      [NEW]     +67 grpc::CompletionQueue::Next                                                              +67  [NEW]
       +43%     +13 [Unmapped]                                                                               +13   +43%
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%

 -------------- SHRINKING                                                                            --------------
  -0.3%    -104 src/cpp/server/server_cc.cc                                                             -104  -0.3%
      [DEL]    -194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    -194  [DEL]
     -10.9%    -121 grpc::Server::ShutdownInternal                                                          -121 -10.9%
     -26.8%     -37 grpc::Server::SyncRequestThreadManager::Wait                                             -37 -26.8%
      -2.3%      -8 grpc::ServerInterface::GenericAsyncRequest::GenericAsyncRequest                           -8  -2.3%
      -3.8%      -8 grpc::ServerInterface::RegisteredAsyncRequest::IssueRequest                               -8  -3.8%
      -5.2%      -8 grpc::Server::AddListeningPort                                                            -8  -5.2%
      -1.4%      -3 grpc::Server::InProcessChannel                                                            -3  -1.4%
     -37.5%      -3 grpc::Server::server                                                                      -3 -37.5%
     -37.5%      -3 grpc::Server::c_server                                                                    -3 -37.5%
  -0.4%     -16 src/cpp/client/channel_cc.cc                                                             -16  -0.4%
      -2.4%     -16 grpc::Channel::WaitForStateChangeImpl                                                    -16  -2.4%

 -+-+-+-+-+-+-+ MIXED                                                                                +-+-+-+-+-+-+-
  +1.1% +2.61Ki [None]                                                                                  -939  -0.0%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
       +23%     +24 [None]                                                                                     0  [ = ]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
       +25%      +8 vtable for grpc::CompletionQueue                                                          +8   +25%
       +25%      +8 vtable for grpc::ServerCompletionQueue                                                    +8   +25%

  +0.7% +2.63Ki TOTAL                                                                                   -912  -0.0%



@grpc-testing
Copy link

[trickle] No significant performance differences

g_core_codegen_interface->gpr_inf_future(
GPR_CLOCK_REALTIME)) != SHUTDOWN);
}
virtual bool Next(void** tag, bool* ok);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to eat a virtual dispatch on CompletionQueue::Next()? This is part of every single gRPC user's datapath. If you want to allow multiple CompletionQueue implementations, consider allowing the user to avoid the virtual dispatch by providing a subclass that is final.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a benchmark showing that this is a problem? I'm not seeing it right now. If there is a benchmark, then that's a different story.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little concerned that CQ::Next() can no longer be inlined even for a minimal implementation of gRPC, but I suppose that FDO solves this problem for anyone who would care. I concede.

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@kumaralokgithub kumaralokgithub self-requested a review March 5, 2018 22:09
makdharma added 2 commits March 9, 2018 09:39
Per style guide, the member variables are not protected but private and
accessed through methods.
Copy link
Member

@vjpai vjpai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also get feedback from @dgquintas particularly wrt codegen header issues.

@@ -175,6 +153,31 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen {
/// \param num_cqs How many completion queues does \a cqs hold.
void Start(ServerCompletionQueue** cqs, size_t num_cqs) override;

grpc_server* server() override { return server_; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this be protected is concerning, for the reason that this means that this is adding an API that exposes gRPC core structures. I'm busy in #14648 trying to remove any APIs that expose gRPC core structures (since they're technically not really API anyway). I thought your plan was to not use gRPC core structures in your derived classes anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan is to not use gRPC core structures unless it makes sense and avoids duplication. This is currently the only instance of using core (so we can reuse the channel creation, connection opening etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without having looked deeply into the details, using inheritance for code reuse is usually an anti-patter. Favor composition over inheritance for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue was a desire to slip in a changed server in a variant library without requiring any application changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, although this is moving the code from private to protected, it doesn't actually change anything because the base-class has it as protected. So this is not an issue.

std::vector<std::reference_wrapper<NamedService>> service_refs;
for (auto &ptr : services_) {
service_refs.push_back(std::ref(*ptr));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a vector of references to unique_ptr? Given that you're not transferring ownership, why not just have this be a vector of dumb pointers acquired through ->get on each element of the iterator? I think that's more consistent with our overall style.

sync_cq_timeout_msec));
if (sync_server_cqs_ != nullptr) {
for (auto it = sync_server_cqs_->begin(); it != sync_server_cqs_->end();
it++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we used to use the begin/end format all the time because of supporting pre-C++11 compilers, but we don't anymore, so can you change this to a range? I'm asking everyone to do this opportunistically any time they make a change in the C++ wrapping that affects one of these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#include <gtest/gtest.h>

namespace grpc {

// Unused implementation for the virtual "Next" method.
bool CompletionQueue::Next(void** tag, bool* ok) { return false; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgquintas : does this feel kosher to you? We need a mechanism to allow the use of codegen headers without crapping out on linker errors now that we're using virtual members for some classes that get used in codegen. Can you comment on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

including codegen headers around is never a problem. The problem is putting non-codegen things into the codegen hierarchy. This should be fine AFAICT.

 Please enter the commit message for your changes. Lines starting
@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.3%    +594 [None]                                                                               +33.9Ki  +0.7%
      +0.2%    +475 [Unmapped]                                                                           +33.8Ki  +0.7%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
       +23%     +24 [None]                                                                                     0  [ = ]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
       +25%      +8 vtable for grpc::CompletionQueue                                                          +8   +25%
       +25%      +8 vtable for grpc::ServerCompletionQueue                                                    +8   +25%
   +14%     +80 src/cpp/common/completion_queue_cc.cc                                                    +80   +14%
      [NEW]     +67 grpc::CompletionQueue::Next                                                              +67  [NEW]
       +43%     +13 [Unmapped]                                                                               +13   +43%
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%

 -------------- SHRINKING                                                                            --------------
  -0.2%     -69 src/cpp/server/server_cc.cc                                                              -69  -0.2%
      [DEL]    -194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    -194  [DEL]
     -10.6%    -118 grpc::Server::ShutdownInternal                                                          -118 -10.6%
     -26.8%     -37 grpc::Server::SyncRequestThreadManager::Wait                                             -37 -26.8%
  -0.4%     -16 src/cpp/client/channel_cc.cc                                                             -16  -0.4%
      -2.4%     -16 grpc::Channel::WaitForStateChangeImpl                                                    -16  -2.4%

  +0.2%    +656 TOTAL                                                                                +34.0Ki  +0.7%



@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.3%    +594 [None]                                                                               +33.9Ki  +0.7%
      +0.2%    +475 [Unmapped]                                                                           +33.8Ki  +0.7%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
       +23%     +24 [None]                                                                                     0  [ = ]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
       +25%      +8 vtable for grpc::CompletionQueue                                                          +8   +25%
       +25%      +8 vtable for grpc::ServerCompletionQueue                                                    +8   +25%
   +14%     +80 src/cpp/common/completion_queue_cc.cc                                                    +80   +14%
      [NEW]     +67 grpc::CompletionQueue::Next                                                              +67  [NEW]
       +43%     +13 [Unmapped]                                                                               +13   +43%
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%

 -------------- SHRINKING                                                                            --------------
  -0.2%     -69 src/cpp/server/server_cc.cc                                                              -69  -0.2%
      [DEL]    -194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    -194  [DEL]
     -10.6%    -118 grpc::Server::ShutdownInternal                                                          -118 -10.6%
     -26.8%     -37 grpc::Server::SyncRequestThreadManager::Wait                                             -37 -26.8%
  -0.4%     -16 src/cpp/client/channel_cc.cc                                                             -16  -0.4%
      -2.4%     -16 grpc::Channel::WaitForStateChangeImpl                                                    -16  -2.4%

  +0.2%    +656 TOTAL                                                                                +34.0Ki  +0.7%



@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] Performance differences noted:
Benchmark                                                                              cpu_time    real_time
-------------------------------------------------------------------------------------  ----------  -----------
BM_StreamingPingPongMsgs<InProcess, NoOpMutator, NoOpMutator>/262144                   -6%         -6%
BM_StreamingPingPongWithCoalescingApi<InProcess, NoOpMutator, NoOpMutator>/262144/2/0  -6%         -6%

Removed unnecessary "virtual" keyword from CompletionQueue::Next.
Reverted two files that no longer need to be changed.
@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.2%    +365 [None]                                                                               +31.5Ki  +0.6%
      +0.1%    +286 [Unmapped]                                                                           +31.4Ki  +0.6%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%
  +0.2%     +64 src/cpp/server/server_cc.cc                                                              +64  +0.2%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +3.0%     +48 grpc::Server::SyncRequestThreadManager::DoWork                                           +48  +3.0%
      +0.8%     +16 grpc::Server::Start                                                                      +16  +0.8%
      +0.4%      +1 [Unmapped]                                                                                +1  +0.4%

  +0.1%    +496 TOTAL                                                                                +31.6Ki  +0.6%



@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

Copy link
Member

@vjpai vjpai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small requests at this point. Please ping me as to why you didn't need to virtualize CompletionQueue as the gRFC suggested.

@@ -175,6 +153,31 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen {
/// \param num_cqs How many completion queues does \a cqs hold.
void Start(ServerCompletionQueue** cqs, size_t num_cqs) override;

grpc_server* server() override { return server_; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, although this is moving the code from private to protected, it doesn't actually change anything because the base-class has it as protected. So this is not an issue.

private:
friend class ::grpc::testing::ServerBuilderPluginTest;

protected:
struct Port {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add experimental tags on these structs that have been moved from private to protected.

struct Port {
grpc::string addr;
std::shared_ptr<ServerCredentials> creds;
int* selected_port;
};

typedef std::unique_ptr<grpc::string> HostString;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise with these pieces.

For "struct Port" and friends, since they are now protected instead of
private.
@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.2%    +365 [None]                                                                               +31.5Ki  +0.6%
      +0.1%    +286 [Unmapped]                                                                           +31.4Ki  +0.6%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%
  +0.2%     +64 src/cpp/server/server_cc.cc                                                              +64  +0.2%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +3.0%     +48 grpc::Server::SyncRequestThreadManager::DoWork                                           +48  +3.0%
      +0.8%     +16 grpc::Server::Start                                                                      +16  +0.8%
      +0.4%      +1 [Unmapped]                                                                                +1  +0.4%

  +0.1%    +496 TOTAL                                                                                +31.6Ki  +0.6%



@grpc-testing
Copy link

[trickle] No significant performance differences

private:
grpc_cq_polling_type polling_type_;
friend class ServerBuilder;
protected:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we have a core leakage again. Sorry for not catching this earlier. By promoting the ServerCompletionQueue constructor to protected, it has become API. However, this API has an argument that is a core enum. Can you look at your callsites and perhaps just elevate a constructor for a specific case to protected (since I assume that you have a subset of the possible polling type choices) and make that a bool argument or something that then delegates something else to the pre-existing private constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

std::mutex mu_;
// Server status
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I'm requesting changes again, can I ask you to dedupe this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad. done.

@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.2%    +365 [None]                                                                               +31.6Ki  +0.6%
      +0.1%    +286 [Unmapped]                                                                           +31.5Ki  +0.6%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%
  +0.2%     +64 src/cpp/server/server_cc.cc                                                              +64  +0.2%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +3.0%     +48 grpc::Server::SyncRequestThreadManager::DoWork                                           +48  +3.0%
      +0.8%     +16 grpc::Server::Start                                                                      +16  +0.8%
      +0.4%      +1 [Unmapped]                                                                                +1  +0.4%

  +0.1%    +496 TOTAL                                                                                +31.8Ki  +0.6%



@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.2%    +365 [None]                                                                               +31.6Ki  +0.6%
      +0.1%    +286 [Unmapped]                                                                           +31.5Ki  +0.6%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%
  +0.2%     +64 src/cpp/server/server_cc.cc                                                              +64  +0.2%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +3.0%     +48 grpc::Server::SyncRequestThreadManager::DoWork                                           +48  +3.0%
      +0.8%     +16 grpc::Server::Start                                                                      +16  +0.8%
      +0.4%      +1 [Unmapped]                                                                                +1  +0.4%

  +0.1%    +496 TOTAL                                                                                +31.8Ki  +0.6%



1 similar comment
@grpc-testing
Copy link

****************************************************************

libgrpc.so

     VM SIZE        FILE SIZE
 ++++++++++++++  ++++++++++++++

  [ = ]       0        0  [ = ]


****************************************************************

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.2%    +365 [None]                                                                               +31.6Ki  +0.6%
      +0.1%    +286 [Unmapped]                                                                           +31.5Ki  +0.6%
      [NEW]     +40 vtable for grpc::ServerBuilder                                                           +40  [NEW]
      [NEW]     +23 typeinfo name for grpc::ServerBuilder                                                    +23  [NEW]
      [NEW]     +16 typeinfo for grpc::ServerBuilder                                                         +16  [NEW]
  +0.6%     +67 src/cpp/server/server_builder.cc                                                         +67  +0.6%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +0.5%     +18 grpc::ServerBuilder::BuildAndStart                                                       +18  +0.5%
      [NEW]     +18 grpc::ServerBuilder::~ServerBuilder                                                      +18  [NEW]
      +2.1%     +16 grpc::ServerBuilder::ServerBuilder                                                       +16  +2.1%
       +11%     +15 [Unmapped]                                                                               +15   +11%
  +0.2%     +64 src/cpp/server/server_cc.cc                                                              +64  +0.2%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
      +3.0%     +48 grpc::Server::SyncRequestThreadManager::DoWork                                           +48  +3.0%
      +0.8%     +16 grpc::Server::Start                                                                      +16  +0.8%
      +0.4%      +1 [Unmapped]                                                                                +1  +0.4%

  +0.1%    +496 TOTAL                                                                                +31.8Ki  +0.6%



@nicolasnoble
Copy link
Member

Force merging this because CLA bot seems broken.

@nicolasnoble nicolasnoble merged commit 129f38a into grpc:master Mar 13, 2018
@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] Performance differences noted:
Benchmark                                                            cpu_time    real_time
-------------------------------------------------------------------  ----------  -----------
BM_UnaryPingPong<InProcess, NoOpMutator, NoOpMutator>/262144/262144  +6%         +6%

@grpc-testing
Copy link

[trickle] No significant performance differences

@vjpai
Copy link
Member

vjpai commented Mar 13, 2018

Nico, I think the CLA bot was legitimately concerned. Makarand's commits were ill-formed because his config had a missing email address.

@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] Performance differences noted:
Benchmark                                                               cpu_time    real_time
----------------------------------------------------------------------  ----------  -----------
BM_UnaryPingPong<InProcess, NoOpMutator, NoOpMutator>/262144/262144     +10%        +10%
BM_UnaryPingPong<MinInProcess, NoOpMutator, NoOpMutator>/0/2097152      +5%         +5%
BM_UnaryPingPong<MinInProcess, NoOpMutator, NoOpMutator>/262144/262144  +4%         +4%

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] Performance differences noted:
Benchmark                                                               cpu_time    real_time
----------------------------------------------------------------------  ----------  -----------
BM_UnaryPingPong<MinInProcess, NoOpMutator, NoOpMutator>/0/262144       +4%         +4%
BM_UnaryPingPong<MinInProcess, NoOpMutator, NoOpMutator>/262144/262144  +4%         +4%

@makdharma makdharma deleted the extensible_api branch March 13, 2018 17:52
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants