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

Add tracer for handshakers. #15090

Merged
merged 2 commits into from
Apr 19, 2018
Merged

Add tracer for handshakers. #15090

merged 2 commits into from
Apr 19, 2018

Conversation

markdroth
Copy link
Member

This adds some logging needed to debug a handshaker problem being reported internally.

Note that this will require adding the name field to the handshaker vtables in internal code before we import this. Once this PR is ready to merge, I'll prepare the necessary internal change.

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                            FILE SIZE
 ++++++++++++++ GROWING                              ++++++++++++++
  +0.2% +1.12Ki [None]                               +2.64Ki  +0.0%
      +0.2% +1.03Ki [Unmapped]                           +2.62Ki  +0.0%
      +3.4%     +40 [None]                                     0  [ = ]
      [NEW]     +24 grpc_handshaker_trace                      0  [ = ]
       +33%      +8 fail_handshaker_vtable                    +8   +33%
       +33%      +8 security_handshaker_vtable                +8   +33%
       +33%      +8 http_connect_handshaker_vtable            +8   +33%
   +30%    +512 src/core/lib/channel/handshaker.cc      +512   +30%
      +183%    +372 call_next_handshaker_locked             +372  +183%
       +63%     +83 grpc_handshake_manager_add               +83   +63%
      [NEW]     +48 _GLOBAL__sub_I_handshaker.cc             +48  [NEW]
      [NEW]      +8 grpc_handshaker_name                      +8  [NEW]
      +0.9%      +1 [Unmapped]                                +1  +0.9%
  +8.6%    +322 src/core/lib/channel/channel_args.cc    +322  +8.6%
      [NEW]    +312 grpc_channel_args_string                +312  [NEW]
      +5.7%     +10 [Unmapped]                               +10  +5.7%

  +0.1% +1.93Ki TOTAL                                +3.45Ki  +0.0%


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

libgrpc++.so

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

 -------------- SHRINK --------------
  [ = ]       0 [None]     -40  -0.0%

  [ = ]       0 TOTAL      -40  -0.0%



#include "src/core/lib/iomgr/timer.h"

grpc_core::TraceFlag grpc_handshaker_trace(false, "handshaker");
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing the DebugOnlyTraceFlag will not work?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm sure it would work, but I don't know why it would be necessary. In general, DebugOnlyTraceFlag is for cases where enabling the tracer imposes a large amount of overhead that we don't want in opt builds (e.g., things like ref-count tracing, which occurs a lot). That's not the case here, so there's no reason not to allow this tracer even in opt builds.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that the overhead would not be much but I would prefer to not add unnecessary overhead.

Copy link
Member Author

Choose a reason for hiding this comment

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

By that logic, why would we support any tracer in opt mode? I don't understand why this particular tracer would be different than any other.

Note that there is no additional overhead unless the tracer is actually enabled.

Copy link
Member

Choose a reason for hiding this comment

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

Mark, is there a specific reason to want this tracer in opt builds ? We have seen a general downward drift in performance benchmarks, so I would lean towards avoiding this overhead unless there is a specific need.

Copy link
Member Author

Choose a reason for hiding this comment

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

As per our discussion, it is very useful to support tracers in opt mode, because this allows customers to enable them without pushing a debug binary (which they often can't for performance reasons). This makes it easier to gather useful debugging information when a customer runs into a problem.

If we're really worried about the branch-prediction performance impact of a few if statements checking whether the tracer is enabled, I would suggest that we find a structural way to make use of the GPR_UNLIKELY macro that @yashykt recently added in #15009. For example, perhaps we could use that in the TraceFlag::enabled() method.

Copy link
Member

Choose a reason for hiding this comment

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

Based on offline discussion, we will explore adding compiler hints to the tracers to avoid perf impact.

Copy link
Member

@yashykt yashykt left a comment

Choose a reason for hiding this comment

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

LGTM if the DebugOnlyTraceFlag will not be enough

@grpc-testing
Copy link

[microbenchmarks] Performance differences noted:
Benchmark                                                                                 cpu_time    real_time
----------------------------------------------------------------------------------------  ----------  -----------
BM_ErrorGetPresentInt                                                                     -10%        -10%
BM_ErrorGetStatusCode<SimpleError>                                                        -4%         -4%
BM_ErrorHttpError<ErrorWithGrpcStatus>                                                    -5%         -5%
BM_ErrorHttpError<SimpleError>                                                            -7%         -7%
BM_PumpStreamClientToServer<InProcess>/262144                                             +10%        +10%
BM_StreamingPingPongWithCoalescingApi<MinInProcess, NoOpMutator, NoOpMutator>/262144/2/1  -4%         -4%

@markdroth
Copy link
Member Author

Known failures: #14969 #15102 #15103

Copy link
Member

@a11r a11r left a comment

Choose a reason for hiding this comment

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

Looks good overall.

@markdroth markdroth requested a review from AspirinSJL April 18, 2018 19:54
@markdroth
Copy link
Member Author

@AspirinSJL, I need an owners approval for this. Thanks!

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                            FILE SIZE
 ++++++++++++++ GROWING                              ++++++++++++++
  +0.2% +1.13Ki [None]                               +2.92Ki  +0.0%
      +0.2% +1.04Ki [Unmapped]                           +2.89Ki  +0.0%
      +3.4%     +40 [None]                                     0  [ = ]
      [NEW]     +24 grpc_handshaker_trace                      0  [ = ]
       +33%      +8 fail_handshaker_vtable                    +8   +33%
       +33%      +8 security_handshaker_vtable                +8   +33%
       +33%      +8 http_connect_handshaker_vtable            +8   +33%
   +33%    +560 src/core/lib/channel/handshaker.cc      +560   +33%
      +204%    +415 call_next_handshaker_locked             +415  +204%
       +63%     +83 grpc_handshake_manager_add               +83   +63%
      [NEW]     +48 _GLOBAL__sub_I_handshaker.cc             +48  [NEW]
      [NEW]      +8 grpc_handshaker_name                      +8  [NEW]
      +5.1%      +6 [Unmapped]                                +6  +5.1%
  +8.7%    +326 src/core/lib/channel/channel_args.cc    +326  +8.7%
      [NEW]    +316 grpc_channel_args_string                +316  [NEW]
      +5.7%     +10 [Unmapped]                               +10  +5.7%

  +0.1% +1.99Ki TOTAL                                +3.78Ki  +0.0%


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

libgrpc++.so

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

 -------------- SHRINK --------------
  [ = ]       0 [None]     -40  -0.0%

  [ = ]       0 TOTAL      -40  -0.0%



@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@markdroth markdroth merged commit 8892c08 into grpc:master Apr 19, 2018
@markdroth markdroth deleted the handshaker_trace branch April 19, 2018 17:34
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants