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

grpclb re-resolution #13671

Merged
merged 1 commit into from Feb 7, 2018
Merged

Conversation

AspirinSJL
Copy link
Member

@AspirinSJL AspirinSJL commented Dec 7, 2017

Currently, grpclb will hand off the re-resolution decision to its embedded RR policy. This PR lets grpclb to be in charge of its re-resolution. The connectivity of the balancers will also be taken into consideration so that grpclb will re-resolve only when both balancers and backends have been unreachable for some timeout.


This change is Reviewable

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.0%    +248 [None]                                                                               +6.27Ki  +0.1%
  +3.5%    +528 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc                          +528  +3.5%
      [NEW] +1.57Ki rr_handover_locked(grpc_exec_ctx*, glb_lb_policy*) [clone .part.12]                  +1.57Ki  [NEW]
      [NEW] +1.28Ki query_for_backends_locked(grpc_exec_ctx*, glb_lb_policy*) [clone .part.10]           +1.28Ki  [NEW]
      [NEW]    +834 build_lb_channel_args(grpc_exec_ctx*, grpc_lb_addresses const*, grpc_fake_resolver_r    +834  [NEW]
      [NEW]    +303 update_lb_connectivity_status_locked                                                    +303  [NEW]
      +146%    +175 glb_rr_connectivity_changed_locked                                                      +175  +146%
      +9.7%     +96 glb_create                                                                               +96  +9.7%
      [NEW]     +88 on_reresolution_requested_locked                                                         +88  [NEW]
      [NEW]     +66 check_reresolution_need(grpc_exec_ctx*, glb_lb_policy*) [clone .part.5]                  +66  [NEW]
       +12%     +53 lb_on_server_status_received_locked                                                      +53   +12%
      +3.4%     +46 lb_on_response_received_locked                                                           +46  +3.4%
      +9.8%     +38 [Unmapped]                                                                               +38  +9.8%
      +6.4%     +34 glb_shutdown_locked                                                                      +34  +6.4%
  +0.8%     +48 src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc                 +48  +0.8%
      +2.9%     +53 rr_connectivity_changed_locked                                                           +53  +2.9%

  +0.1%    +824 TOTAL                                                                                +6.84Ki  +0.1%


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

libgrpc++.so

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

  [ = ]       0        0  [ = ]



1 similar comment
@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.0%    +248 [None]                                                                               +6.27Ki  +0.1%
  +3.5%    +528 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc                          +528  +3.5%
      [NEW] +1.57Ki rr_handover_locked(grpc_exec_ctx*, glb_lb_policy*) [clone .part.12]                  +1.57Ki  [NEW]
      [NEW] +1.28Ki query_for_backends_locked(grpc_exec_ctx*, glb_lb_policy*) [clone .part.10]           +1.28Ki  [NEW]
      [NEW]    +834 build_lb_channel_args(grpc_exec_ctx*, grpc_lb_addresses const*, grpc_fake_resolver_r    +834  [NEW]
      [NEW]    +303 update_lb_connectivity_status_locked                                                    +303  [NEW]
      +146%    +175 glb_rr_connectivity_changed_locked                                                      +175  +146%
      +9.7%     +96 glb_create                                                                               +96  +9.7%
      [NEW]     +88 on_reresolution_requested_locked                                                         +88  [NEW]
      [NEW]     +66 check_reresolution_need(grpc_exec_ctx*, glb_lb_policy*) [clone .part.5]                  +66  [NEW]
       +12%     +53 lb_on_server_status_received_locked                                                      +53   +12%
      +3.4%     +46 lb_on_response_received_locked                                                           +46  +3.4%
      +9.8%     +38 [Unmapped]                                                                               +38  +9.8%
      +6.4%     +34 glb_shutdown_locked                                                                      +34  +6.4%
  +0.8%     +48 src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc                 +48  +0.8%
      +2.9%     +53 rr_connectivity_changed_locked                                                           +53  +2.9%

  +0.1%    +824 TOTAL                                                                                +6.84Ki  +0.1%


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

libgrpc++.so

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

  [ = ]       0        0  [ = ]



@grpc-testing
Copy link

[trickle] No significant performance differences

1 similar comment
@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

1 similar comment
@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@markdroth
Copy link
Member

This looks really good! In particular, I think you've done a good job checking for all of the various edge cases involved in handling the timeouts and the race conditions for the timer callback.

My comments are mostly nits or structural improvements that are tangentially related to the new functionality. However, we will need to add a test for the new functionality before we can merge.

Please let me know if you have any questions about any of this. Thanks!


Reviewed 3 of 3 files at r1.
Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.


include/grpc/impl/codegen/grpc_types.h, line 299 at r1 (raw file):

   If 0, fallback will never be used. */
#define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms"
/* Timeout in milliseconds to confirm that we have lost contact with all the

Please also document the default if this argument is not specified.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 447 at r1 (raw file):

/* Keeps track and reacts to changes in connectivity of the RR instance */
struct rr_connectivity_data {

I suspect that this struct is not needed anymore. @dgquintas can confirm this, but I think the original reason for allocating a new struct whenever we instantiate a new RR policy is that we used to have a lot of cases where we unreffed and then recreated the RR policy, which meant that there could be connectivity state callbacks for multiple RR policies in flight at the same time, and each one needed its own state. But between David's change to add update functionality to LB policies and your change to allow LB policies to request reresolution instead of shutting down, I don't think we have any more cases where we'll unref and recreate the RR policy. So I think the elements from this struct can be moved directly into glb_lb_policy.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 874 at r1 (raw file):

}

static void check_reresolution_need(grpc_exec_ctx* exec_ctx,

Suggest calling this something like maybe_start_reresolution_timer().


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1052 at r1 (raw file):

    glb_policy->reresolution_timer_active = false;
  }

Nit: Please remove blank lines within functions, both here and below.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1671 at r1 (raw file):

        /* update serverlist */
        if (serverlist->num_servers > 0) {
          glb_policy->lost_lb_connection = false;

Let's move this new code down to line 1704, since that's where we've actually set the new serverlist.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1869 at r1 (raw file):

if (glb_policy->lost_lb_connection &&
glb_policy->rr_state != GRPC_CHANNEL_READY) {
if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE) {

Can combine both of these conditionals into one.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1933 at r1 (raw file):

}

static void glb_set_reresolve_closure_locked(

I think this function is now essentially the same as in the other two LB policies, so we can probably remove this method from the LB policy vtable and implement it just once in the base class.


src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc, line 364 at r1 (raw file):

   *
   * 3) RULE: ALL subchannels are SHUTDOWN =>
   *          if can't re-resolve, policy is TRANSIENT_FAILURE

I don't think it's necessary to change the RR policy in this PR. Instead, we can just have the grpclb code check for either TRANSIENT_FAILURE or IDLE.


Comments from Reviewable

@AspirinSJL
Copy link
Member Author

Thanks for reviewing! I'm still adding the test in grpclb_end2end_test.


Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.


include/grpc/impl/codegen/grpc_types.h, line 299 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Please also document the default if this argument is not specified.

Done.

(Fallback counterpart is added.)


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 447 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

I suspect that this struct is not needed anymore. @dgquintas can confirm this, but I think the original reason for allocating a new struct whenever we instantiate a new RR policy is that we used to have a lot of cases where we unreffed and then recreated the RR policy, which meant that there could be connectivity state callbacks for multiple RR policies in flight at the same time, and each one needed its own state. But between David's change to add update functionality to LB policies and your change to allow LB policies to request reresolution instead of shutting down, I don't think we have any more cases where we'll unref and recreate the RR policy. So I think the elements from this struct can be moved directly into glb_lb_policy.

Done.

Also, should we actually cancel the notification closure somehow? The previous code didn't cancel it. I tried to cancel it in glb_shutdown(), but I got a Closure already scheduled error so I guess that's not the right way to cancel it.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 874 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Suggest calling this something like maybe_start_reresolution_timer().

Done.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1052 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Nit: Please remove blank lines within functions, both here and below.

Looks like this file has been using many blanks in functions. Also the blank line here is preexisting. Should I remove all the blank lines in this function?


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1671 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Let's move this new code down to line 1704, since that's where we've actually set the new serverlist.

Done.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1869 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

if (glb_policy->lost_lb_connection &&
glb_policy->rr_state != GRPC_CHANNEL_READY) {
if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE) {

Can combine both of these conditionals into one.

Done.

(Fallback counterpart is added.)


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1933 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

I think this function is now essentially the same as in the other two LB policies, so we can probably remove this method from the LB policy vtable and implement it just once in the base class.

Yes, except that we are still using shutting_down from each derived policy.

I think checking that we are not shutting down is useful, I proposed to move it into the base policy class. Actually I think some other members (e.g., started_picking) are also common, maybe we should move them too.

But then it's a little more verbose to check glb_policy->base.shutting_down in about 15 locations. I'm fine with that verbosity, which can be simplified when we use native inheritance in the future.


src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc, line 364 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

I don't think it's necessary to change the RR policy in this PR. Instead, we can just have the grpclb code check for either TRANSIENT_FAILURE or IDLE.

Done.

I though this will cause unnecessary re-resolution when the LB connection fails before it starts picking. But after a second thought, it seems impossible because we make LB call after we start picking.


Comments from Reviewable

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +2.0%    +304 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc                          +304  +2.0%
      [NEW]    +303 update_lb_connectivity_status_locked                                                    +303  [NEW]
      [NEW]    +210 extract_backend_addresses_locked(grpc_exec_ctx*, grpc_lb_addresses const*) [clone .i    +210  [NEW]
       +14%    +136 glb_create                                                                              +136   +14%
      [NEW]    +114 maybe_start_reresolution_timer                                                          +114  [NEW]
      [NEW]     +80 on_reresolution_requested_locked                                                         +80  [NEW]
       +61%     +73 glb_rr_connectivity_changed_locked                                                       +73   +61%
       +14%     +53 [Unmapped]                                                                               +53   +14%
      +3.6%     +48 lb_on_response_received_locked                                                           +48  +3.6%
      +5.3%     +34 glb_shutdown_locked                                                                      +34  +5.3%
      +3.7%     +16 lb_on_server_status_received_locked                                                      +16  +3.7%
   +14%     +96 src/core/ext/filters/client_channel/lb_policy.cc                                         +96   +14%
      [NEW]    +112 grpc_lb_policy_set_reresolve_closure                                                    +112  [NEW]

 -------------- SHRINKING                                                                            --------------
  [ = ]       0 [None]                                                                               -1.73Ki  -0.0%
      -9.1%      -8 glb_lb_policy_vtable                                                                      -8  -9.1%
      -9.1%      -8 pick_first_lb_policy_vtable                                                               -8  -9.1%
      -9.1%      -8 round_robin_lb_policy_vtable                                                              -8  -9.1%
  -2.2%    -112 src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc                  -112  -2.2%
      [DEL]    -132 start_picking_locked(grpc_exec_ctx*, pick_first_lb_policy*) [clone .isra.1]             -132  [DEL]
      [DEL]    -112 pf_set_reresolve_closure_locked                                                         -112  [DEL]
      [DEL]     -97 destroy_unselected_subchannels_locked(grpc_exec_ctx*, pick_first_lb_policy*) [clone      -97  [DEL]
  -1.9%    -112 src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc                -112  -1.9%
      [DEL]    -114 start_picking_locked(grpc_exec_ctx*, round_robin_lb_policy*) [clone .isra.1]            -114  [DEL]
      [DEL]    -112 rr_set_reresolve_closure_locked                                                         -112  [DEL]

  +0.0%    +176 TOTAL                                                                                -1.56Ki  -0.0%


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

libgrpc++.so

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

  [ = ]       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_ErrorGetStatus<SimpleError>  +8%         +8%
BM_MetadataRefUnrefExternal     -20%        -20%
BM_MetadataRefUnrefStatic       -20%        -20%

@markdroth
Copy link
Member

Reviewed 7 of 7 files at r2.
Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks failed.


src/core/ext/filters/client_channel/lb_policy.h, line 209 at r2 (raw file):

/** Set the re-resolution closure to \a request_reresolution. */
void grpc_lb_policy_set_reresolve_closure(grpc_lb_policy* policy,

This should still have the _locked suffix, because it still runs in the combiner.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 447 at r1 (raw file):

Previously, AspirinSJL (Juanli Shen) wrote…

Done.

Also, should we actually cancel the notification closure somehow? The previous code didn't cancel it. I tried to cancel it in glb_shutdown(), but I got a Closure already scheduled error so I guess that's not the right way to cancel it.

No, we shouldn't need to cancel it. When we unref the RR policy, that will cause it to go into state SHUTDOWN, and the pending notification callback will be returned telling us that that's happened.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1052 at r1 (raw file):

Previously, AspirinSJL (Juanli Shen) wrote…

Looks like this file has been using many blanks in functions. Also the blank line here is preexisting. Should I remove all the blank lines in this function?

Let's do this opportunistically. When you're working on a function anyway, if it has them, go ahead and remove them -- especially if you might be tempted to add more with your new code.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1933 at r1 (raw file):

Previously, AspirinSJL (Juanli Shen) wrote…

Yes, except that we are still using shutting_down from each derived policy.

I think checking that we are not shutting down is useful, I proposed to move it into the base policy class. Actually I think some other members (e.g., started_picking) are also common, maybe we should move them too.

But then it's a little more verbose to check glb_policy->base.shutting_down in about 15 locations. I'm fine with that verbosity, which can be simplified when we use native inheritance in the future.

I'd prefer not to move shutting_down to the base class, for two reasons.

First, the shutdown code is too deeply embedded in the logic of each implementation. I think it's generally a bad idea to have too much interaction between superclasses and subclasses, because it splits up the logic between them and makes it hard to follow. In fact, the C++ style guide discourages implementation inheritance for exactly this reason.

Second, although all of our implementations currently use a simple bool to indicate shutting down, I could imagine other implementations that do something different. I don't think it makes sense to tie ourselves to this one particular implementation.

So, here are the alternatives I see, in decreasing order of preference:

  • Leave this method in the base class, but drop the assertion about shutting_down, so that that field does not need to be moved to the base class.

  • Leave the method in the subclasses, even though they all basically have the same implementation.

  • Move the method to the base class but add a new vtable method that returns whether the LB policy is shutting down, and use that method to access the subclass's shutting_down value from the base class.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 883 at r2 (raw file):

if (glb_policy->rr_state == GRPC_CHANNEL_TRANSIENT_FAILURE ||
glb_policy->rr_state == GRPC_CHANNEL_IDLE) {

Could just call maybe_start_reresolution_timer() unconditionally here, since the code in that function already checks this condition.


Comments from Reviewable

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +1.6% +3.12Ki [Other]                                                                              +3.12Ki  +1.6%
  +5.0%    +736 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc                          +736  +5.0%
      [NEW] +1.60Ki rr_handover_locked(grpc_exec_ctx*, glb_lb_policy*) [clone .part.10]                  +1.60Ki  [NEW]
      +348% +1.41Ki [Other]                                                                              +1.41Ki  +348%
      [NEW] +1.37Ki lb_on_response_received_locked                                                       +1.37Ki  [NEW]
      [NEW] +1.28Ki query_for_backends_locked(grpc_exec_ctx*, glb_lb_policy*) [clone .part.8]            +1.28Ki  [NEW]
      [NEW] +1.10Ki glb_create                                                                           +1.10Ki  [NEW]
      [NEW]    +834 build_lb_channel_args(grpc_exec_ctx*, grpc_lb_addresses const*, grpc_fake_resolver_r    +834  [NEW]
      [NEW]    +745 glb_update_locked                                                                       +745  [NEW]
      [NEW]    +743 glb_pick_locked                                                                         +743  [NEW]
      [NEW]    +725 pick_from_internal_rr_locked                                                            +725  [NEW]
      [NEW]    +675 glb_shutdown_locked                                                                     +675  [NEW]
      [NEW]    +616 send_client_load_report_locked                                                          +616  [NEW]
      [NEW]    +460 wrapped_rr_closure                                                                      +460  [NEW]
      [NEW]    +446 lb_on_server_status_received_locked                                                     +446  [NEW]
      [NEW]    +385 maybe_restart_lb_call                                                                   +385  [NEW]
      [NEW]    +321 glb_cancel_pick_locked                                                                  +321  [NEW]
      [NEW]    +316 glb_cancel_picks_locked                                                                 +316  [NEW]
      [NEW]    +313 glb_lb_channel_on_connectivity_changed_cb                                               +313  [NEW]
      [NEW]    +303 update_lb_connectivity_status_locked                                                    +303  [NEW]
      [NEW]    +241 glb_destroy                                                                             +241  [NEW]
      [NEW]    +235 glb_ping_one_locked                                                                     +235  [NEW]
      [NEW]    +210 extract_backend_addresses_locked(grpc_exec_ctx*, grpc_lb_addresses const*) [clone .i    +210  [NEW]
  +4.2%    +592 src/core/ext/filters/client_channel/client_channel.cc                                   +592  +4.2%
      [NEW] +2.81Ki on_resolver_result_changed_locked                                                    +2.81Ki  [NEW]
      +533% +1.40Ki [Other]                                                                              +1.40Ki  +533%
      [NEW]    +984 cc_init_channel_elem                                                                    +984  [NEW]
      [NEW]    +962 pick_done_locked                                                                        +962  [NEW]
      [NEW]    +810 start_transport_op_locked                                                               +810  [NEW]
      [NEW]    +754 pick_callback_start_locked                                                              +754  [NEW]
      [NEW]    +752 cc_start_transport_stream_op_batch                                                      +752  [NEW]
      [NEW]    +611 pick_after_resolver_result_done_locked                                                  +611  [NEW]
      [NEW]    +496 watch_connectivity_state_locked                                                         +496  [NEW]
      [NEW]    +407 cc_destroy_call_elem                                                                    +407  [NEW]
      [NEW]    +365 on_external_watch_complete_locked                                                       +365  [NEW]
      [NEW]    +347 start_pick_locked                                                                       +347  [NEW]
      [NEW]    +321 waiting_for_pick_batches_fail(grpc_exec_ctx*, grpc_call_element*, grpc_error*) [clon    +321  [NEW]
      [NEW]    +297 cc_destroy_channel_elem                                                                 +297  [NEW]
      [NEW]    +237 cc_init_call_elem                                                                       +237  [NEW]
      [NEW]    +231 pick_after_resolver_result_cancel_locked                                                +231  [NEW]
      [NEW]    +230 pick_after_resolver_result_start_locked                                                 +230  [NEW]
      [NEW]    +192 set_channel_connectivity_state_locked                                                   +192  [NEW]
      [NEW]    +188 on_lb_policy_state_changed_locked                                                       +188  [NEW]
      [NEW]    +184 pick_callback_done_locked                                                               +184  [NEW]
      [NEW]    +180 grpc_client_channel_watch_connectivity_state                                            +180  [NEW]
  +1.4%    +469 src/core/ext/transport/chttp2/transport/chttp2_transport.cc                             +469  +1.4%
     +14e2% +9.13Ki [Other]                                                                              +9.13Ki +14e2%
      [NEW] +3.45Ki grpc_create_chttp2_transport                                                         +3.45Ki  [NEW]
      [NEW] +3.41Ki perform_stream_op_locked                                                             +3.41Ki  [NEW]
      [NEW] +2.37Ki grpc_chttp2_cancel_stream                                                            +2.37Ki  [NEW]
      [NEW] +1.31Ki grpc_chttp2_mark_stream_closed                                                       +1.31Ki  [NEW]
      [NEW]   +1018 read_action_locked                                                                     +1018  [NEW]
      [NEW]   +1004 grpc_chttp2_initiate_write                                                             +1004  [NEW]
      [NEW]    +987 grpc_chttp2_maybe_complete_recv_message                                                 +987  [NEW]
      [NEW]    +899 destroy_stream_locked                                                                   +899  [NEW]
      [NEW]    +743 incoming_byte_stream_next_locked                                                        +743  [NEW]
      [NEW]    +736 close_transport_locked                                                                  +736  [NEW]
      [NEW]    +690 maybe_start_some_streams                                                                +690  [NEW]
      [NEW]    +682 grpc_chttp2_complete_closure_step                                                       +682  [NEW]
      [NEW]    +637 write_action_begin_locked                                                               +637  [NEW]
      [NEW]    +618 grpc_chttp2_maybe_complete_recv_trailing_metadata                                       +618  [NEW]
      [NEW]    +594 incoming_byte_stream_pull                                                               +594  [NEW]
      [NEW]    +588 grpc_chttp2_unref_transport                                                             +588  [NEW]
      [NEW]    +495 grpc_chttp2_fake_status                                                                 +495  [NEW]
      [NEW]    +439 write_action_end_locked                                                                 +439  [NEW]
      [NEW]    +414 continue_fetching_send_locked                                                           +414  [NEW]
      [NEW]    +382 try_http_parsing(grpc_exec_ctx*, grpc_chttp2_transport*) [clone .isra.6]                +382  [NEW]
  +2.1%    +256 src/core/lib/iomgr/ev_poll_posix.cc                                                     +256  +2.1%
      [NEW] +2.80Ki pollset_work                                                                         +2.80Ki  [NEW]
      [NEW]    +636 pollset_kick_ext                                                                        +636  [NEW]
      [NEW]    +508 fd_end_poll                                                                             +508  [NEW]
      +129%    +395 [Other]                                                                                 +395  +129%
      [NEW]    +377 notify_on_locked                                                                        +377  [NEW]
      [NEW]    +356 fd_orphan                                                                               +356  [NEW]
      [NEW]    +242 pollset_set_add_pollset                                                                 +242  [NEW]
      [NEW]    +232 pollset_set_destroy                                                                     +232  [NEW]
      [NEW]    +231 pollset_shutdown                                                                        +231  [NEW]
      [NEW]    +226 pollset_set_add_pollset_set                                                             +226  [NEW]
      [NEW]    +222 pollset_set_add_fd                                                                      +222  [NEW]
      [NEW]    +219 pollset_set_del_pollset                                                                 +219  [NEW]
      [NEW]    +196 pollset_destroy                                                                         +196  [NEW]
      [NEW]    +194 pollset_add_fd                                                                          +194  [NEW]
      [NEW]    +183 pollset_set_del_fd                                                                      +183  [NEW]
      [NEW]    +158 finish_shutdown                                                                         +158  [NEW]
      [NEW]    +145 init_result(poll_args*) [clone .constprop.14]                                           +145  [NEW]
      [NEW]    +125 fd_shutdown                                                                             +125  [NEW]
      [NEW]    +124 unref_by(grpc_fd*, int) [clone .constprop.16]                                           +124  [NEW]
      [NEW]    +122 pollset_set_del_pollset_set                                                             +122  [NEW]
      [NEW]    +115 set_ready_locked                                                                        +115  [NEW]
  +3.2%    +232 src/core/lib/iomgr/tcp_posix.cc                                                         +232  +3.2%
      [NEW]   +1012 tcp_do_read                                                                            +1012  [NEW]
      [NEW]    +983 tcp_flush                                                                               +983  [NEW]
      [NEW]    +774 grpc_tcp_create                                                                         +774  [NEW]
      [NEW]    +671 tcp_handle_read                                                                         +671  [NEW]
      [NEW]    +636 tcp_write                                                                               +636  [NEW]
      [NEW]    +551 notify_on_write                                                                         +551  [NEW]
      [NEW]    +549 run_poller                                                                              +549  [NEW]
      [NEW]    +394 tcp_drop_uncovered_then_handle_write                                                    +394  [NEW]
      [NEW]    +384 call_read_cb                                                                            +384  [NEW]
      [NEW]    +174 tcp_read                                                                                +174  [NEW]
      [NEW]    +158 tcp_read_allocation_done                                                                +158  [NEW]
      [NEW]    +134 drop_uncovered(grpc_exec_ctx*, grpc_tcp*) [clone .isra.4]                               +134  [NEW]
      [NEW]    +132 grpc_tcp_destroy_and_release_fd                                                         +132  [NEW]
      [NEW]    +121 tcp_unref                                                                               +121  [NEW]
      [NEW]    +119 notify_on_read                                                                          +119  [NEW]
      [NEW]     +82 done_poller                                                                              +82  [NEW]
      [NEW]     +49 tcp_destroy                                                                              +49  [NEW]
      [NEW]     +42 tcp_shutdown                                                                             +42  [NEW]
      [NEW]     +15 [Other]                                                                                  +15  [NEW]
      [NEW]     +15 tcp_add_to_pollset                                                                       +15  [NEW]
      [NEW]     +15 tcp_add_to_pollset_set                                                                   +15  [NEW]
  +3.9%    +224 src/core/ext/filters/client_channel/subchannel.cc                                       +224  +3.9%
      [NEW] +1.13Ki grpc_subchannel_create                                                               +1.13Ki  [NEW]
      [NEW]    +855 subchannel_connected                                                                    +855  [NEW]
      [NEW]    +361 maybe_start_connecting_locked                                                           +361  [NEW]
      [NEW]    +325 grpc_connected_subchannel_create_call                                                   +325  [NEW]
      [NEW]    +315 grpc_subchannel_notify_on_state_change                                                  +315  [NEW]
      [NEW]    +315 on_alarm                                                                                +315  [NEW]
      [NEW]    +302 grpc_subchannel_unref                                                                   +302  [NEW]
      [NEW]    +228 grpc_get_subchannel_address_arg                                                         +228  [NEW]
      [NEW]    +186 on_external_state_watcher_done                                                          +186  [NEW]
      [NEW]    +169 subchannel_on_child_state_changed                                                       +169  [NEW]
      [NEW]    +136 continue_connect_locked                                                                 +136  [NEW]
      [NEW]    +112 subchannel_destroy                                                                      +112  [NEW]
      [NEW]    +102 grpc_subchannel_weak_unref                                                              +102  [NEW]
      [NEW]     +93 grpc_connected_subchannel_notify_on_state_change                                         +93  [NEW]
      [NEW]     +92 subchannel_call_destroy                                                                  +92  [NEW]
      [NEW]     +86 grpc_subchannel_call_process_op                                                          +86  [NEW]
      [NEW]     +74 grpc_connected_subchannel_ping                                                           +74  [NEW]
      [NEW]     +46 grpc_connected_subchannel_process_transport_op                                           +46  [NEW]
      [NEW]     +18 connection_destroy                                                                       +18  [NEW]
      [NEW]      +9 grpc_subchannel_call_unref                                                                +9  [NEW]
      [NEW]      +5 [Other]                                                                                   +5  [NEW]
  +7.6%    +213 src/core/lib/http/httpcli.cc                                                            +213  +7.6%
      [NEW]    +607 internal_request_begin                                                                  +607  [NEW]
      [NEW]    +591 next_address                                                                            +591  [NEW]
      [NEW]    +293 grpc_httpcli_post                                                                       +293  [NEW]
      [NEW]    +275 on_read                                                                                 +275  [NEW]
      [NEW]    +267 grpc_httpcli_get                                                                        +267  [NEW]
      [NEW]    +261 finish                                                                                  +261  [NEW]
      [NEW]    +243 on_handshake_done                                                                       +243  [NEW]
      [NEW]    +128 on_connected                                                                            +128  [NEW]
      [NEW]     +74 done_write                                                                               +74  [NEW]
      [NEW]     +66 on_resolved                                                                              +66  [NEW]
      [NEW]     +55 closure_impl::closure_wrapper                                                            +55  [NEW]
      [NEW]     +15 grpc_httpcli_set_override                                                                +15  [NEW]
       +17%     +14 [Unmapped]                                                                               +14   +17%
      [NEW]      +8 grpc_httpcli_context_destroy                                                              +8  [NEW]
      [NEW]      +3 plaintext_handshake                                                                       +3  [NEW]
  +5.4%    +208 src/core/lib/security/transport/secure_endpoint.cc                                      +208  +5.4%
      [NEW] +1.25Ki endpoint_write                                                                       +1.25Ki  [NEW]
      [NEW] +1.17Ki on_read                                                                              +1.17Ki  [NEW]
      [NEW]    +274 call_read_cb                                                                            +274  [NEW]
      [NEW]    +182 destroy                                                                                 +182  [NEW]
      [NEW]    +176 endpoint_read                                                                           +176  [NEW]
      [NEW]     +57 endpoint_destroy                                                                         +57  [NEW]
      [NEW]      +9 endpoint_shutdown                                                                         +9  [NEW]
      [NEW]      +9 endpoint_add_to_pollset                                                                   +9  [NEW]
      [NEW]      +9 endpoint_add_to_pollset_set                                                               +9  [NEW]
      [NEW]      +9 endpoint_delete_from_pollset_set                                                          +9  [NEW]
      +3.9%      +4 [Unmapped]                                                                                +4  +3.9%
  +7.6%    +192 src/core/ext/filters/client_channel/http_connect_handshaker.cc                          +192  +7.6%
      [NEW]    +849 http_connect_handshaker_do_handshake                                                    +849  [NEW]
      [NEW]    +788 on_read_done                                                                            +788  [NEW]
      [NEW]    +293 handshake_failed_locked                                                                 +293  [NEW]
      [NEW]    +219 handshaker_factory_add_handshakers                                                      +219  [NEW]
      [NEW]    +154 http_connect_handshaker_shutdown                                                        +154  [NEW]
      [NEW]    +147 on_write_done                                                                           +147  [NEW]
      [NEW]    +134 http_connect_handshaker_unref                                                           +134  [NEW]
      [NEW]      +5 http_connect_handshaker_destroy                                                           +5  [NEW]
      [NEW]      +2 handshaker_factory_destroy                                                                +2  [NEW]
      +1.0%      +1 [Unmapped]                                                                                +1  +1.0%
  +3.6%    +176 src/core/ext/filters/http/client/http_client_filter.cc                                  +176  +3.6%
      [NEW] +1.71Ki hc_start_transport_stream_op_batch                                                   +1.71Ki  [NEW]
      [NEW] +1.54Ki init_channel_elem                                                                    +1.54Ki  [NEW]
      [NEW]    +870 client_filter_incoming_metadata(grpc_exec_ctx*, grpc_call_element*, grpc_metadata_ba    +870  [NEW]
      [NEW]    +172 pull_slice_from_send_message                                                            +172  [NEW]
      [NEW]    +136 init_call_elem                                                                          +136  [NEW]
      [NEW]    +114 on_send_message_next_done                                                               +114  [NEW]
      [NEW]     +97 recv_initial_metadata_ready                                                              +97  [NEW]
      [NEW]     +97 recv_trailing_metadata_on_complete                                                       +97  [NEW]
      [NEW]     +84 send_message_on_complete                                                                 +84  [NEW]
      [NEW]     +13 destroy_channel_elem                                                                     +13  [NEW]
      [NEW]      +2 destroy_call_elem                                                                         +2  [NEW]
  +7.2%    +175 src/core/ext/transport/chttp2/server/chttp2_server.cc                                   +175  +7.2%
      [NEW]   +1015 grpc_chttp2_server_add_port                                                            +1015  [NEW]
      [NEW]    +516 on_handshake_done                                                                       +516  [NEW]
      [NEW]    +350 on_accept                                                                               +350  [NEW]
      [NEW]    +207 tcp_server_shutdown_complete                                                            +207  [NEW]
      [NEW]    +162 on_timeout                                                                              +162  [NEW]
      [NEW]     +83 server_destroy_listener                                                                  +83  [NEW]
      [NEW]     +80 server_start_listener                                                                    +80  [NEW]
      [NEW]     +71 server_connection_state_unref                                                            +71  [NEW]
      [NEW]     +51 on_receive_settings                                                                      +51  [NEW]
       +42%     +19 [Unmapped]                                                                               +19   +42%
  +3.8%    +172 src/core/lib/iomgr/udp_server.cc                                                        +172  +3.8%
      [NEW]    +840 grpc_udp_server_add_port                                                                +840  [NEW]
      [NEW]    +410 deactivated_all_ports                                                                   +410  [NEW]
      [NEW]    +391 add_socket_to_server(grpc_udp_server*, int, grpc_resolved_address const*, bool (*)(g    +391  [NEW]
      [NEW]    +369 grpc_udp_server_destroy                                                                 +369  [NEW]
      [NEW]    +338 grpc_udp_server_start                                                                   +338  [NEW]
      [NEW]    +254 on_read                                                                                 +254  [NEW]
      [NEW]    +211 do_write                                                                                +211  [NEW]
      [NEW]    +204 do_read                                                                                 +204  [NEW]
      [NEW]    +157 on_write                                                                                +157  [NEW]
      [NEW]    +154 shutdown_fd                                                                             +154  [NEW]
      [NEW]    +128 finish_shutdown                                                                         +128  [NEW]
      [NEW]     +86 destroyed_port                                                                           +86  [NEW]
      [NEW]     +71 fd_notify_on_write_wrapper                                                               +71  [NEW]
      [NEW]      +2 dummy_cb                                                                                  +2  [NEW]
  +5.2%    +172 src/core/lib/security/transport/client_auth_filter.cc                                   +172  +5.2%
      [NEW]    +921 auth_start_transport_stream_op_batch                                                    +921  [NEW]
      [NEW]    +802 on_host_checked                                                                         +802  [NEW]
      [NEW]    +519 on_credentials_metadata                                                                 +519  [NEW]
      [NEW]    +319 init_channel_elem                                                                       +319  [NEW]
      [NEW]    +122 destroy_call_elem                                                                       +122  [NEW]
      [NEW]     +66 cancel_check_call_host                                                                   +66  [NEW]
      [NEW]     +62 cancel_get_request_metadata                                                              +62  [NEW]
      [NEW]     +28 destroy_channel_elem                                                                     +28  [NEW]
       +36%     +25 [Unmapped]                                                                               +25   +36%
      [NEW]     +21 init_call_elem                                                                           +21  [NEW]
      [NEW]      +9 set_pollset_or_pollset_set                                                                +9  [NEW]
  +4.8%    +160 src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc            +160  +4.8%
      [NEW] +1.64Ki dns_ares_on_resolved_locked                                                          +1.64Ki  [NEW]
      [NEW]    +358 dns_factory_create_resolver                                                             +358  [NEW]
      [NEW]    +247 dns_ares_shutdown_locked                                                                +247  [NEW]
      [NEW]    +196 dns_ares_next_locked                                                                    +196  [NEW]
      [NEW]    +182 dns_ares_start_resolving_locked                                                         +182  [NEW]
      [NEW]    +169 dns_ares_maybe_finish_next_locked                                                       +169  [NEW]
      [NEW]    +125 dns_ares_destroy                                                                        +125  [NEW]
      [NEW]     +64 dns_ares_on_retry_timer_locked                                                           +64  [NEW]
      [NEW]     +57 dns_ares_channel_saw_error_locked                                                        +57  [NEW]
      +9.2%     +11 [Unmapped]                                                                               +11  +9.2%
  +5.0%    +160 src/core/ext/transport/chttp2/transport/frame_data.cc                                   +160  +5.0%
      [NEW] +2.11Ki grpc_deframe_unprocessed_incoming_frames                                             +2.11Ki  [NEW]
      [NEW]    +481 grpc_chttp2_data_parser_parse                                                           +481  [NEW]
      [NEW]    +152 grpc_chttp2_data_parser_destroy                                                         +152  [NEW]
       +26%     +10 [Unmapped]                                                                               +10   +26%
  +3.9%    +160 src/core/lib/security/transport/security_handshaker.cc                                  +160  +3.9%
      [NEW]    +702 on_peer_checked                                                                         +702  [NEW]
      [NEW]    +467 on_handshake_next_done_locked                                                           +467  [NEW]
      [NEW]    +407 move_read_buffer_into_handshake_buffer                                                  +407  [NEW]
      [NEW]    +341 security_handshake_failed_locked                                                        +341  [NEW]
      [NEW]    +274 on_handshake_data_sent_to_peer                                                          +274  [NEW]
      [NEW]    +260 grpc_security_handshaker_create                                                         +260  [NEW]
      [NEW]    +248 on_handshake_data_received_from_peer                                                    +248  [NEW]
      [NEW]    +188 check_peer_locked                                                                       +188  [NEW]
      [NEW]    +171 fail_handshaker_do_handshake                                                            +171  [NEW]
      [NEW]    +167 security_handshaker_unref                                                               +167  [NEW]
      [NEW]    +161 do_handshaker_next_locked                                                               +161  [NEW]
      [NEW]    +154 security_handshaker_shutdown                                                            +154  [NEW]
      [NEW]    +144 security_handshaker_do_handshake                                                        +144  [NEW]
      [NEW]     +40 client_handshaker_factory_add_handshakers                                                +40  [NEW]
      [NEW]     +40 server_handshaker_factory_add_handshakers                                                +40  [NEW]
      [NEW]      +8 fail_handshaker_destroy                                                                   +8  [NEW]
      [NEW]      +8 fail_handshaker_shutdown                                                                  +8  [NEW]
      [NEW]      +5 security_handshaker_destroy                                                               +5  [NEW]
      [NEW]      +2 handshaker_factory_destroy                                                                +2  [NEW]
  +3.0%    +144 src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc            +144  +3.0%
      [NEW] +1.50Ki grpc_dns_lookup_ares_impl                                                            +1.50Ki  [NEW]
      [NEW]    +373 on_dns_lookup_done_cb                                                                   +373  [NEW]
      [NEW]    +239 grpc_ares_request_unref                                                                 +239  [NEW]
      [NEW]    +133 grpc_resolve_address_ares_impl                                                          +133  [NEW]
      [NEW]     +33 grpc_cancel_ares_request                                                                 +33  [NEW]
       +29%     +21 [Unmapped]                                                                               +21   +29%
  +8.8%    +144 src/core/ext/transport/chttp2/client/chttp2_connector.cc                                +144  +8.8%
      [NEW]    +555 connected                                                                               +555  [NEW]
      [NEW]    +503 on_handshake_done                                                                       +503  [NEW]
      [NEW]    +414 chttp2_connector_connect                                                                +414  [NEW]
      [NEW]    +133 chttp2_connector_shutdown                                                               +133  [NEW]
      [NEW]     +72 chttp2_connector_unref                                                                   +72  [NEW]
       +20%      +7 [Unmapped]                                                                                +7   +20%
  +1.5%    +136 src/core/lib/security/transport/security_connector.cc                                   +136  +1.5%
      [NEW]    +666 grpc_ssl_channel_security_connector_create                                              +666  [NEW]
      [NEW]    +537 fake_check_peer(grpc_exec_ctx*, grpc_security_connector*, tsi_peer, grpc_auth_contex    +537  [NEW]
      [NEW]    +526 fake_channel_check_peer                                                                 +526  [NEW]
      [NEW]    +524 grpc_ssl_server_security_connector_create                                               +524  [NEW]
      [NEW]    +215 grpc_security_connector_check_peer                                                      +215  [NEW]
      [NEW]    +202 ssl_channel_check_call_host                                                             +202  [NEW]
      [NEW]    +190 ssl_channel_add_handshakers                                                             +190  [NEW]
      [NEW]    +176 ssl_server_add_handshakers                                                              +176  [NEW]
      [NEW]    +166 grpc_channel_security_connector_check_call_host                                         +166  [NEW]
      [NEW]    +122 ssl_channel_check_peer                                                                  +122  [NEW]
      [NEW]    +107 ssl_server_check_peer                                                                   +107  [NEW]
      [NEW]     +92 ssl_channel_destroy                                                                      +92  [NEW]
      [NEW]     +68 grpc_security_connector_unref                                                            +68  [NEW]
      [NEW]     +53 [Other]                                                                                  +53  [NEW]
      [NEW]     +52 fake_channel_add_handshakers                                                             +52  [NEW]
      [NEW]     +49 fake_server_add_handshakers                                                              +49  [NEW]
      [NEW]     +40 fake_channel_destroy                                                                     +40  [NEW]
      [NEW]     +39 ssl_server_destroy                                                                       +39  [NEW]
      [NEW]     +24 grpc_channel_security_connector_cancel_check_call_host                                   +24  [NEW]
      [NEW]     +20 fake_server_check_peer                                                                   +20  [NEW]
      [NEW]     +18 grpc_server_security_connector_add_handshakers                                           +18  [NEW]
   +20%    +130 src/core/ext/filters/client_channel/lb_policy.cc                                        +130   +20%
      [NEW]    +178 grpc_lb_policy_try_reresolve                                                            +178  [NEW]
      [NEW]    +120 grpc_lb_policy_unref                                                                    +120  [NEW]
      [NEW]    +112 grpc_lb_policy_set_reresolve_closure                                                    +112  [NEW]
      [NEW]     +65 grpc_lb_policy_weak_unref                                                                +65  [NEW]
      [NEW]     +35 shutdown_locked                                                                          +35  [NEW]
      [NEW]      +6 grpc_lb_policy_pick_locked                                                                +6  [NEW]
      [NEW]      +6 grpc_lb_policy_update_locked                                                              +6  [NEW]
      [NEW]      +6 grpc_lb_policy_ping_one_locked                                                            +6  [NEW]
      [NEW]      +6 grpc_lb_policy_exit_idle_locked                                                           +6  [NEW]
      [NEW]      +6 grpc_lb_policy_cancel_pick_locked                                                         +6  [NEW]
      [NEW]      +6 grpc_lb_policy_cancel_picks_locked                                                        +6  [NEW]
      [NEW]      +6 grpc_lb_policy_check_connectivity_locked                                                  +6  [NEW]
      [NEW]      +6 grpc_lb_policy_notify_on_state_change_locked                                              +6  [NEW]

 -------------- SHRINKING                                                                            --------------
  -3.4% -1.79Ki [Other]                                                                              -1.79Ki  -3.4%
 -11.2%    -943 src/core/lib/surface/completion_queue.cc                                                -943 -11.2%
      [DEL]    -576 cq_end_op_for_next                                                                      -576  [DEL]
      [DEL]    -528 cq_end_op_for_pluck                                                                     -528  [DEL]
      [DEL]    -392 non_polling_poller_work                                                                 -392  [DEL]
      [DEL]    -294 ExecCtxPluck::CheckReadyToFinish                                                        -294  [DEL]
      [DEL]    -179 [Other]                                                                                 -179  [DEL]
     -14.0%    -160 cq_next                                                                                 -160 -14.0%
      [DEL]    -159 ExecCtxNext::CheckReadyToFinish                                                         -159  [DEL]
     -11.6%    -158 cq_pluck                                                                                -158 -11.6%
      [DEL]    -156 cq_finish_shutdown_pluck                                                                -156  [DEL]
      [DEL]    -145 cq_finish_shutdown_next                                                                 -145  [DEL]
     -30.6%    -135 cq_event_queue_pop                                                                      -135 -30.6%
     -44.4%    -122 grpc_completion_queue_shutdown                                                          -122 -44.4%
      [DEL]    -121 non_polling_poller_shutdown                                                             -121  [DEL]
     -25.1%    -108 grpc_completion_queue_create_internal                                                   -108 -25.1%
     -24.5%    -106 grpc_completion_queue_thread_local_cache_flush                                          -106 -24.5%
     -39.9%    -105 grpc_completion_queue_destroy                                                           -105 -39.9%
      [DEL]     -74 cq_shutdown_next                                                                         -74  [DEL]
      [DEL]     -74 cq_shutdown_pluck                                                                        -74  [DEL]
      [DEL]     -60 non_polling_poller_kick                                                                  -60  [DEL]
      [DEL]     -56 grpc_cq_internal_unref                                                                   -56  [DEL]
      [DEL]     -56 ExecCtxNext::~ExecCtxNext                                                                -56  [DEL]
 -17.4%    -830 src/core/lib/debug/stats_data.cc                                                        -830 -17.4%
      [DEL]    -363 grpc_stats_inc_tcp_read_size                                                            -363  [DEL]
      [DEL]    -363 grpc_stats_inc_tcp_read_offer                                                           -363  [DEL]
      [DEL]    -363 grpc_stats_inc_tcp_write_size                                                           -363  [DEL]
      [DEL]    -363 grpc_stats_inc_server_cqs_checked                                                       -363  [DEL]
      [DEL]    -363 grpc_stats_inc_tcp_write_iov_size                                                       -363  [DEL]
      [DEL]    -363 grpc_stats_inc_http2_send_message_size                                                  -363  [DEL]
      [DEL]    -363 grpc_stats_inc_tcp_read_offer_iov_size                                                  -363  [DEL]
      [DEL]    -363 grpc_stats_inc_http2_send_flowctl_per_write                                             -363  [DEL]
      [DEL]    -363 grpc_stats_inc_http2_send_message_per_write                                             -363  [DEL]
      [DEL]    -363 grpc_stats_inc_http2_send_initial_metadata_per_write                                    -363  [DEL]
      [DEL]    -363 grpc_stats_inc_http2_send_trailing_metadata_per_write                                   -363  [DEL]
      [DEL]    -360 grpc_stats_inc_poll_events_returned                                                     -360  [DEL]
      [DEL]    -342 grpc_stats_inc_call_initial_size                                                        -342  [DEL]
     -45.6%     -31 [Unmapped]                                                                               -31 -45.6%
  -8.7%    -480 src/core/lib/surface/channel.cc                                                         -480  -8.7%
      [DEL] -1.48Ki grpc_channel_create_with_builder                                                     -1.48Ki  [DEL]
      [DEL]    -422 grpc_channel_create_call_internal                                                       -422  [DEL]
      [DEL]    -348 grpc_channel_create_pollset_set_call                                                    -348  [DEL]
      [DEL]    -206 grpc_channel_get_reffed_status_elem                                                     -206  [DEL]
     -19.0%    -128 grpc_channel_register_call                                                              -128 -19.0%
     -32.3%    -122 grpc_channel_destroy                                                                    -122 -32.3%
     -20.1%    -120 grpc_channel_create_call                                                                -120 -20.1%
      [DEL]    -115 grpc_channel_create                                                                     -115  [DEL]
      [DEL]    -115 destroy_channel                                                                         -115  [DEL]
     -48.3%    -111 grpc_channel_get_info                                                                   -111 -48.3%
     -21.5%    -105 grpc_channel_create_registered_call                                                     -105 -21.5%
     -32.5%     -41 [Unmapped]                                                                               -41 -32.5%
      [DEL]      -9 grpc_channel_internal_unref                                                               -9  [DEL]
  -3.5%    -480 src/core/lib/surface/server.cc                                                          -480  -3.5%
     -34.4% -1.14Ki [Other]                                                                              -1.14Ki -34.4%
      [DEL] -1.13Ki grpc_server_setup_transport                                                          -1.13Ki  [DEL]
      [DEL]    -818 got_initial_metadata                                                                    -818  [DEL]
      [DEL]    -607 maybe_finish_shutdown                                                                   -607  [DEL]
      [DEL]    -601 publish_call(grpc_server*, call_data*, unsigned long, requested_call*) [clone .isra.    -601  [DEL]
      [DEL]    -578 publish_new_rpc                                                                         -578  [DEL]
      [DEL]    -550 server_on_recv_initial_metadata                                                         -550  [DEL]
      [DEL]    -511 queue_call_request                                                                      -511  [DEL]
      [DEL]    -431 channel_broadcaster_shutdown                                                            -431  [DEL]
      [DEL]    -402 channel_connectivity_changed                                                            -402  [DEL]
      [DEL]    -305 finish_start_new_rpc                                                                    -305  [DEL]
      [DEL]    -286 accept_stream                                                                           -286  [DEL]
      [DEL]    -269 server_unref                                                                            -269  [DEL]
      [DEL]    -229 destroy_channel_elem                                                                    -229  [DEL]
      [DEL]    -185 init_channel_elem                                                                       -185  [DEL]
      [DEL]    -162 destroy_call_elem                                                                       -162  [DEL]
     -21.2%    -152 grpc_server_request_registered_call                                                     -152 -21.2%
      [DEL]    -147 init_call_elem                                                                          -147  [DEL]
      [DEL]    -146 request_matcher_kill_requests(grpc_server*, request_matcher*, grpc_error*) [clone .i    -146  [DEL]
     -23.0%    -142 grpc_server_request_call                                                                -142 -23.0%
      [DEL]    -141 kill_pending_work_locked                                                                -141  [DEL]
 -51.5%    -464 src/core/lib/iomgr/fork_posix.cc                                                        -464 -51.5%
      [DEL]    -234 grpc_postfork_child                                                                     -234  [DEL]
     -97.8%    -221 grpc_postfork_parent                                                                    -221 -97.8%
     -32.3%    -133 grpc_prefork                                                                            -133 -32.3%
 -30.0%    -320 src/core/lib/surface/alarm.cc                                                           -320 -30.0%
      [DEL]    -242 alarm_unref(grpc_alarm*) [clone .part.3]                                                -242  [DEL]
     -34.7%    -120 grpc_alarm_set                                                                          -120 -34.7%
     -52.2%    -109 grpc_alarm_cancel                                                                       -109 -52.2%
      [DEL]     -59 alarm_cb                                                                                 -59  [DEL]
      [DEL]     -25 alarm_end_completion                                                                     -25  [DEL]
  -8.7%    -288 src/core/lib/security/credentials/google_default/google_default_credentials.cc          -288  -8.7%
      [DEL] -1.07Ki create_default_creds_from_path                                                       -1.07Ki  [DEL]
      [DEL]    -204 on_compute_engine_detection_http_response                                               -204  [DEL]
     -11.9%    -192 grpc_google_default_credentials_create                                                  -192 -11.9%
     -40.7%    -118 grpc_flush_cached_google_default_credentials                                            -118 -40.7%
     -14.9%     -10 [Unmapped]                                                                               -10 -14.9%
      [DEL]      -5 destroy_pollset                                                                           -5  [DEL]
  -9.8%    -256 src/core/lib/iomgr/combiner.cc                                                          -256  -9.8%
      [DEL]   -1012 grpc_combiner_continue_exec_ctx                                                        -1012  [DEL]
      [DEL]    -392 combiner_exec                                                                           -392  [DEL]
      [DEL]    -362 combiner_finally_exec                                                                   -362  [DEL]
      [DEL]    -170 queue_offload                                                                           -170  [DEL]
      [DEL]    -124 really_destroy                                                                          -124  [DEL]
      [DEL]    -116 grpc_combiner_unref                                                                     -116  [DEL]
      [DEL]     -66 offload                                                                                  -66  [DEL]
      [DEL]     -24 enqueue_finally                                                                          -24  [DEL]
     -25.0%     -23 [Unmapped]                                                                               -23 -25.0%
  -2.7%    -256 src/core/lib/iomgr/ev_epoll1_linux.cc                                                   -256  -2.7%
      [DEL] -3.30Ki pollset_work                                                                         -3.30Ki  [DEL]
      [DEL] -2.32Ki pollset_kick                                                                         -2.32Ki  [DEL]
      [DEL]    -597 check_neighborhood_for_available_poller(pollset_neighborhood*) [clone .isra.7]          -597  [DEL]
      [DEL]    -520 pollset_shutdown                                                                        -520  [DEL]
      [DEL]    -330 fd_orphan                                                                               -330  [DEL]
      [DEL]    -172 pollset_destroy                                                                         -172  [DEL]
      [DEL]     -94 fd_shutdown_internal                                                                     -94  [DEL]
      [DEL]     -60 pollset_maybe_finish_shutdown                                                            -60  [DEL]
     -13.4%     -37 [Unmapped]                                                                               -37 -13.4%
      [DEL]      -9 fd_notify_on_read                                                                         -9  [DEL]
      [DEL]      -9 fd_notify_on_write                                                                        -9  [DEL]
      [DEL]      -5 fd_get_read_notifier_pollset                                                              -5  [DEL]
      [DEL]      -4 fd_shutdown                                                                               -4  [DEL]
      [DEL]      -2 [Other]                                                                                   -2  [DEL]
      [DEL]      -2 pollset_add_fd                                                                            -2  [DEL]
      [DEL]      -2 pollset_set_add_fd                                                                        -2  [DEL]
      [DEL]      -2 pollset_set_del_fd                                                                        -2  [DEL]
      [DEL]      -2 pollset_set_destroy                                                                       -2  [DEL]
      [DEL]      -2 pollset_set_add_pollset                                                                   -2  [DEL]
      [DEL]      -2 pollset_set_del_pollset                                                                   -2  [DEL]
      [DEL]      -2 pollset_set_add_pollset_set                                                               -2  [DEL]
  -8.1%    -256 src/core/lib/security/context/security_context.cc                                       -256  -8.1%
     -30.0%    -133 grpc_call_set_credentials                                                               -133 -30.0%
     -46.4%    -122 grpc_client_security_context_destroy                                                    -122 -46.4%
      [DEL]      -5 auth_context_pointer_arg_destroy                                                          -5  [DEL]
      -2.3%      -4 [Unmapped]                                                                                -4  -2.3%
 -21.6%    -256 src/core/lib/surface/byte_buffer_reader.cc                                              -256 -21.6%
     -25.8%    -128 grpc_byte_buffer_reader_readall                                                         -128 -25.8%
     -27.6%    -121 grpc_byte_buffer_reader_init                                                            -121 -27.6%
     -22.6%      -7 [Unmapped]                                                                                -7 -22.6%
  -8.2%    -240 src/core/lib/iomgr/executor.cc                                                          -240  -8.2%
      [DEL] -1.27Ki executor_push                                                                        -1.27Ki  [DEL]
      [DEL]    -567 grpc_executor_set_threading                                                             -567  [DEL]
      [DEL]    -166 run_closures(grpc_closure_list) [clone .isra.4]                                         -166  [DEL]
     -21.3%    -144 executor_thread                                                                         -144 -21.3%
      [DEL]     -21 grpc_executor_init                                                                       -21  [DEL]
      [DEL]     -10 executor_push_short                                                                      -10  [DEL]
      [DEL]      -7 grpc_executor_shutdown                                                                    -7  [DEL]
      [DEL]      -7 executor_push_long                                                                        -7  [DEL]
      -1.2%      -1 [Unmapped]                                                                                -1  -1.2%
 -13.4%    -240 src/core/lib/iomgr/resolve_address_posix.cc                                             -240 -13.4%
     -18.5%    -274 blocking_resolve_address_impl                                                           -274 -18.5%
      [DEL]    -165 resolve_address_impl                                                                    -165  [DEL]
      [DEL]     -90 do_request_thread                                                                        -90  [DEL]
  -9.7%    -240 src/core/lib/iomgr/timer_manager.cc                                                     -240  -9.7%
     -11.5%    -136 timer_thread                                                                            -136 -11.5%
     -46.7%    -105 grpc_timer_manager_tick                                                                 -105 -46.7%
  -9.7%    -224 src/core/lib/security/credentials/credentials.cc                                        -224  -9.7%
     -41.2%    -105 grpc_call_credentials_release                                                           -105 -41.2%
     -41.2%    -105 grpc_channel_credentials_release                                                        -105 -41.2%
     -41.2%    -105 grpc_server_credentials_release                                                         -105 -41.2%
      [DEL]     -99 grpc_channel_credentials_create_security_connector                                       -99  [DEL]
      [DEL]     -75 grpc_server_credentials_unref                                                            -75  [DEL]
      [DEL]     -69 grpc_server_credentials_create_security_connector                                        -69  [DEL]
      [DEL]     -51 grpc_call_credentials_unref                                                              -51  [DEL]
      [DEL]     -51 grpc_channel_credentials_unref                                                           -51  [DEL]
      [DEL]     -30 grpc_credentials_metadata_request_destroy                                                -30  [DEL]
      [DEL]     -30 grpc_call_credentials_get_request_metadata                                               -30  [DEL]
      [DEL]     -26 grpc_call_credentials_cancel_get_request_metadata                                        -26  [DEL]
      [DEL]      -5 credentials_pointer_arg_destroy                                                           -5  [DEL]
      [DEL]      -5 server_credentials_pointer_arg_destroy                                                    -5  [DEL]
 -14.1%    -201 src/core/lib/iomgr/iomgr.cc                                                             -201 -14.1%
      [DEL]    -836 grpc_iomgr_shutdown                                                                     -836  [DEL]
      [DEL]    -272 grpc_iomgr_init                                                                         -272  [DEL]
      [DEL]     -87 dump_objects(char const*) [clone .constprop.3]                                           -87  [DEL]
      [DEL]      -5 grpc_iomgr_start                                                                          -5  [DEL]
  -9.0%    -192 src/core/lib/compression/stream_compression_gzip.cc                                     -192  -9.0%
     -11.6%    -184 gzip_flate                                                                              -184 -11.6%
     -20.0%      -8 [Unmapped]                                                                                -8 -20.0%
  -4.2%    -181 src/core/lib/slice/slice_buffer.cc                                                      -181  -4.2%
     -51.4%    -107 grpc_slice_buffer_destroy                                                               -107 -51.4%
     -51.4%    -107 grpc_slice_buffer_reset_and_unref                                                       -107 -51.4%
      [DEL]     -88 grpc_slice_buffer_reset_and_unref_internal                                               -88  [DEL]
      [DEL]     -34 grpc_slice_buffer_destroy_internal                                                       -34  [DEL]
 -12.4%    -160 src/core/lib/surface/init.cc                                                            -160 -12.4%
     -24.3%    -102 grpc_shutdown                                                                           -102 -24.3%
      [DEL]     -56 grpc_core::ExecCtx::~ExecCtx                                                             -56  [DEL]
      [DEL]     -53 grpc_core::ExecCtx::~ExecCtx                                                             -53  [DEL]
     -58.8%     -30 [Unmapped]                                                                               -30 -58.8%
      [DEL]      -9 append_filter                                                                             -9  [DEL]
      [DEL]      -9 prepend_filter                                                                            -9  [DEL]
      [DEL]      -3 grpc_core::ExecCtx::CheckReadyToFinish                                                    -3  [DEL]
 -21.2%    -139 src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc                   -139 -21.2%
     -21.2%    -139 grpc_insecure_channel_create_from_fd                                                    -139 -21.2%

 -+-+-+-+-+-+-+ MIXED                                                                                +-+-+-+-+-+-+-
  +1.5% +8.79Ki [None]                                                                               -55.4Ki  -1.0%
      [NEW]    +192 init_transport(grpc_exec_ctx*, grpc_chttp2_transport*, grpc_channel_args const*, grp    +192  [NEW]
      [NEW]     +60 CSWTCH.2                                                                                 +60  [NEW]
      [NEW]     +32 grpc_lb_policy_grpclb_build_lb_channel_args(grpc_exec_ctx*, grpc_slice_hash_table*,      +32  [NEW]
      [NEW]     +32 parse_lithdr_incidx_v(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const     +32  [NEW]
      [NEW]     +32 parse_lithdr_notidx_v(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const     +32  [NEW]
      [NEW]     +32 parse_lithdr_nvridx_v(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const     +32  [NEW]
      [NEW]     +24 parse_lithdr_incidx_x(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const     +24  [NEW]
      [NEW]     +24 parse_lithdr_notidx_x(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const     +24  [NEW]
      [NEW]     +24 parse_lithdr_nvridx_x(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const     +24  [NEW]
      [NEW]     +16 grpc_lb_subchannel_list_create(grpc_exec_ctx*, grpc_lb_policy*, grpc_core::TraceFlag     +16  [NEW]
      [NEW]     +16 parse_lithdr_incidx(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const*,     +16  [NEW]
      [NEW]     +16 parse_lithdr_notidx(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const*,     +16  [NEW]
      [NEW]     +16 parse_lithdr_nvridx(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const*,     +16  [NEW]
      [NEW]     +16 dns_ares_on_resolved_locked(grpc_exec_ctx*, void*, grpc_error*)::args_to_remove            0  [ = ]
      [NEW]      +8 grpc_subchannel_create(grpc_exec_ctx*, grpc_connector*, grpc_subchannel_args const*)      +8  [NEW]
      [NEW]      +8 grpc_lb_policy_grpclb_create_lb_channel(grpc_exec_ctx*, char const*, grpc_client_cha      +8  [NEW]
      [NEW]      +8 glb_create(grpc_exec_ctx*, grpc_lb_policy_factory*, grpc_lb_policy_args*)::args_to_r      +8  [NEW]
      [NEW]      +8 parse_max_tbl_size_x(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const*      +8  [NEW]
      [NEW]      +8 lb_policy_args_create(grpc_exec_ctx*, glb_lb_policy*)::keys_to_remove                     +8  [NEW]
      [NEW]      +8 parse_indexed_field_x(grpc_exec_ctx*, grpc_chttp2_hpack_parser*, unsigned char const      +8  [NEW]
      [DEL]    -192 init_transport(grpc_chttp2_transport*, grpc_channel_args const*, grpc_endpoint*, boo    -192  [DEL]
      [DEL]     -60 CSWTCH.3                                                                                 -60  [DEL]
     -41.2%     -56 [Other]                                                                                  -56 -41.2%
      [DEL]     -40 vtable for ExecCtxNext                                                                   -40  [DEL]
      [DEL]     -40 vtable for ExecCtxPluck                                                                  -40  [DEL]
      [DEL]     -40 vtable for grpc_core::ExecCtx                                                            -40  [DEL]
      -2.6%     -32 [None]                                                                                     0  [ = ]
      [DEL]     -32 grpc_lb_policy_grpclb_build_lb_channel_args(grpc_slice_hash_table*, grpc_fake_resolv     -32  [DEL]
      [DEL]     -32 parse_lithdr_incidx_v(grpc_chttp2_hpack_parser*, unsigned char const*, unsigned char     -32  [DEL]
      [DEL]     -32 parse_lithdr_notidx_v(grpc_chttp2_hpack_parser*, unsigned char const*, unsigned char     -32  [DEL]
      [DEL]     -32 parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser*, unsigned char const*, unsigned char     -32  [DEL]
      [DEL]     -24 parse_lithdr_incidx_x(grpc_chttp2_hpack_parser*, unsigned char const*, unsigned char     -24  [DEL]
      [DEL]     -24 parse_lithdr_notidx_x(grpc_chttp2_hpack_parser*, unsigned char const*, unsigned char     -24  [DEL]
      [DEL]     -24 parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser*, unsigned char const*, unsigned char     -24  [DEL]
      [DEL]     -16 grpc_lb_subchannel_list_create(grpc_lb_policy*, grpc_core::TraceFlag*, grpc_lb_addre     -16  [DEL]
      [DEL]     -16 parse_lithdr_incidx(grpc_chttp2_hpack_parser*, unsigned char const*, unsigned char c     -16  [DEL]
      [DEL]     -16 parse_lithdr_notidx(grpc_chttp2_hpack_parser*, unsigned char const*, unsigned char c     -16  [DEL]
      [DEL]     -16 parse_lithdr_nvridx(grpc_chttp2_hpack_parser*, unsigned char const*, unsigned char c     -16  [DEL]
      [DEL]     -16 dns_ares_on_resolved_locked(void*, grpc_error*)::args_to_remove                            0  [ = ]
      -9.1%      -8 glb_lb_policy_vtable                                                                      -8  -9.1%
      -9.1%      -8 pick_first_lb_policy_vtable                                                               -8  -9.1%

  +0.7% +8.38Ki TOTAL                                                                                -55.8Ki  -0.9%


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

libgrpc++.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
   +11% +1.37Ki src/cpp/client/generic_stub.cc                                                       +1.37Ki   +11%
      +305% +1.60Ki grpc::internal::CallOpSet<grpc::internal::CallOpRecvInitialMetadata, grpc::internal: +1.60Ki  +305%
      +174% +1.58Ki grpc::internal::CallOpSet<grpc::internal::CallOpRecvInitialMetadata, grpc::internal: +1.58Ki  +174%
      [NEW]    +194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    +194  [NEW]
  +2.6%     +16 src/cpp/common/channel_filter.cc                                                         +16  +2.6%
      [NEW]    +270 grpc::MetadataBatch::AddMetadata                                                        +270  [NEW]
      [NEW]     +97 grpc::internal::(anonymous namespace)::MaybeAddFilter                                    +97  [NEW]
      [NEW]     +14 grpc::ChannelData::StartTransportOp                                                      +14  [NEW]
      [NEW]     +14 grpc::ChannelData::GetInfo                                                               +14  [NEW]
      [NEW]     +14 grpc::CallData::SetPollsetOrPollsetSet                                                   +14  [NEW]
      [NEW]     +14 grpc::CallData::StartTransportStreamOpBatch                                              +14  [NEW]
      [NEW]      +3 grpc::ChannelData::Init                                                                   +3  [NEW]
      [NEW]      +3 grpc::CallData::Init                                                                      +3  [NEW]
      [NEW]      +2 grpc::ChannelData::Destroy                                                                +2  [NEW]
      [NEW]      +2 grpc::CallData::Destroy                                                                   +2  [NEW]

 -------------- SHRINKING                                                                            --------------
  -6.0%    -336 src/cpp/common/channel_arguments.cc                                                     -336  -6.0%
      [DEL]    -194 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >    -194  [DEL]
     -14.6%    -118 grpc::ChannelArguments::SetSocketMutator                                                -118 -14.6%
     -31.5%    -112 grpc::ChannelArguments::~ChannelArguments                                               -112 -31.5%
      [DEL]     -56 grpc_core::ExecCtx::~ExecCtx                                                             -56  [DEL]
      [DEL]     -53 grpc_core::ExecCtx::~ExecCtx                                                             -53  [DEL]
      [DEL]      -3 grpc_core::ExecCtx::CheckReadyToFinish                                                    -3  [DEL]
      [DEL]      -2 grpc::ChannelArguments::PointerVtableMembers::Destroy                                     -2  [DEL]
  -1.7%     -64 src/cpp/client/client_context.cc                                                         -64  -1.7%
      -6.4%     -32 grpc::ClientContext::ClientContext                                                       -32  -6.4%
      -3.9%     -32 grpc::ClientContext::~ClientContext                                                      -32  -3.9%

 -+-+-+-+-+-+-+ MIXED                                                                                +-+-+-+-+-+-+-
  -0.5%   -1022 [None]                                                                               +7.49Ki  +0.2%
      [DEL]     -40 vtable for grpc_core::ExecCtx                                                            -40  [DEL]
      [DEL]     -21 typeinfo name for grpc_core::ExecCtx                                                     -21  [DEL]
     -13.1%     -16 [None]                                                                                     0  [ = ]
      [DEL]     -16 typeinfo for grpc_core::ExecCtx                                                          -16  [DEL]

  [ = ]       0 TOTAL                                                                                +8.49Ki  +0.2%



@AspirinSJL
Copy link
Member Author

I've spent 2 days on this timer bug but I haven't understood why it happens. To reproduce it, run GRPC_VERBOSITY=DEBUG GRPC_TRACE=timer,glb,round_robin tools/run_tests/run_tests.py -l c++ -r "grpclb_end.*Reresolve" -c asan -S -n inf and wait for about 15s. A full sample log is here. The error message says I'm adding a dulicate timer. While debugging it, one thing I can't understand is that the timer will sometimes fire immediately rather than after the timeout. I am thinking that maybe I'm using the timer wrongly or something behind the timer may be wrong. @sreecha any idea?

11 17:06:02.579113253  243527 grpclb.cc:1766]             [grpclb 0x61a00000f680] Status from LB server received. Status = 0, Details = '', (call: 0x62a000030220), error '"No Error"'
I1211 17:06:02.579131002  243527 grpclb.cc:870]              before init re-re timer
D1211 17:06:02.579142890  243527 timer_generic.cc:341]       TIMER 0x61a00000fa88: SET 1134 now 134 call 0x61a00000f930[0x9815b0]
D1211 17:06:02.579156296  243527 timer_generic.cc:377]         timer (0x61a00000fa88) .. add to shard 0 with queue_deadline_cap=1004 => is_first_timer=false
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Timer 0x61a00000fa88 should fire after 1000 ms.

I1211 17:06:02.579166838  243527 grpclb.cc:873]              after init re-re timer
D1211 17:06:02.579180604  243527 grpclb.cc:1325]             [grpclb 0x61a00000f680] Connection to LB server lost...
D1211 17:06:02.579192986  243527 grpclb.cc:1329]             [grpclb 0x61a00000f680] ... retry_timer_active in 1444ms.
D1211 17:06:02.579203913  243527 timer_generic.cc:341]       TIMER 0x61a00000fa28: SET 1578 now 134 call 0x61a00000f890[0x98d390]
D1211 17:06:02.579219826  243527 timer_generic.cc:377]         timer (0x61a00000fa28) .. add to shard 0 with queue_deadline_cap=1004 => is_first_timer=false
I1211 17:06:02.579233495  243527 grpclb.cc:1857]             beginning of re-re cb
I1211 17:06:02.579243354  243527 grpclb.cc:1869]             end of re-re cb
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx But the associated closure is invoked within 0.1 ms.

D1211 17:06:02.579257860  243527 round_robin.cc:412]         [RR 0x60c00000ac00] connectivity changed for subchannel 0x616000005a80, subchannel_list 0x60800000e1a0: prev_state=IDLE new_state=CONNECTING p->base.shutting_down=0 sd->subchannel_list->shutting_down=0 error="No Error"
D1211 17:06:02.579274608  243527 subchannel_list.cc:62]      [round_robin 0x60c00000ac00] subchannel list 0x60800000e1a0 index 0 of 1 (subchannel 0x616000005a80): requesting connectivity change notification
I1211 17:06:02.579292312  243527 grpclb.cc:643]              [grpclb 0x61a00000f680] Setting grpclb's state to CONNECTING from new RR policy 0x60c00000ac00 state.
D1211 17:06:02.579340820  243527 timer_generic.cc:429]       TIMER 0x612000042c70: CANCEL pending=true
E1211 17:06:02.579351332  243527 timer_generic.cc:168]       ** Removed timer (0x612000042c70)

@sreecha
Copy link
Contributor

sreecha commented Dec 12, 2017

@AspirinSJL - yes, will take a look once you resolve the merge conflicts and update the PR.

@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] Performance differences noted:
Benchmark                    allocs_per_iteration    atm_cas_per_iteration    cpu_time    real_time
---------------------------  ----------------------  -----------------------  ----------  -----------
BM_ClosureSched2OnExecCtx                                                     -6%         -6%
BM_ErrorCreateAndSetStatus                                                    +17%        +17%
BM_ErrorCreateAndSetStrLoop                                                   +76%        +76%
BM_ErrorCreateFromStatic                                                      +14%        +14%
BM_ErrorUnrefNone                                                             -5%         -5%
BM_LameChannelCallCreateCpp  -60%                    -5%                      -20%        -20%
BM_NoOpExecCtx                                                                +9%         +9%

@AspirinSJL
Copy link
Member Author

Review status: 5 of 9 files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


src/core/ext/filters/client_channel/lb_policy.h, line 209 at r2 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

This should still have the _locked suffix, because it still runs in the combiner.

Done.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1052 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Let's do this opportunistically. When you're working on a function anyway, if it has them, go ahead and remove them -- especially if you might be tempted to add more with your new code.

Done.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1933 at r1 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

I'd prefer not to move shutting_down to the base class, for two reasons.

First, the shutdown code is too deeply embedded in the logic of each implementation. I think it's generally a bad idea to have too much interaction between superclasses and subclasses, because it splits up the logic between them and makes it hard to follow. In fact, the C++ style guide discourages implementation inheritance for exactly this reason.

Second, although all of our implementations currently use a simple bool to indicate shutting down, I could imagine other implementations that do something different. I don't think it makes sense to tie ourselves to this one particular implementation.

So, here are the alternatives I see, in decreasing order of preference:

  • Leave this method in the base class, but drop the assertion about shutting_down, so that that field does not need to be moved to the base class.

  • Leave the method in the subclasses, even though they all basically have the same implementation.

  • Move the method to the base class but add a new vtable method that returns whether the LB policy is shutting down, and use that method to access the subclass's shutting_down value from the base class.

Done. I choose solution 2. I think we should keep the assertion, even though we have some duplicate code.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 883 at r2 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

if (glb_policy->rr_state == GRPC_CHANNEL_TRANSIENT_FAILURE ||
glb_policy->rr_state == GRPC_CHANNEL_IDLE) {

Could just call maybe_start_reresolution_timer() unconditionally here, since the code in that function already checks this condition.

Done.


Comments from Reviewable

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                      FILE SIZE
 ++++++++++++++ GROWING                                                        ++++++++++++++
  +0.1%    +403 [None]                                                         +5.03Ki  +0.1%
  +4.5%    +672 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc    +672  +4.5%
      [NEW]    +303 update_lb_connectivity_status_locked                              +303  [NEW]
      [NEW]    +193 maybe_start_reresolution_timer                                    +193  [NEW]
      [NEW]    +147 on_reresolution_requested_locked                                  +147  [NEW]
       +14%    +136 glb_create                                                        +136   +14%
       +16%     +95 glb_shutdown_locked                                                +95   +16%
       +75%     +89 glb_rr_connectivity_changed_locked                                 +89   +75%
      +5.9%     +77 lb_on_response_received_locked                                     +77  +5.9%
      +4.6%     +19 [Unmapped]                                                         +19  +4.6%
      +3.9%     +16 lb_on_server_status_received_locked                                +16  +3.9%

 -------------- SHRINKING                                                      --------------
  -0.5%      -3 src/core/ext/filters/client_channel/lb_policy.cc                    -3  -0.5%
      -1.7%      -3 grpc_lb_policy_try_reresolve                                        -3  -1.7%

  +0.1% +1.05Ki TOTAL                                                          +5.68Ki  +0.1%


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

libgrpc++.so

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

  [ = ]       0        0  [ = ]



@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@markdroth
Copy link
Member

Reviewed 6 of 9 files at r5.
Review status: all files reviewed at latest revision, 7 unresolved discussions, some commit checks failed.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 899 at r5 (raw file):

  }
  GPR_ASSERT(glb_policy->rr_state != GRPC_CHANNEL_SHUTDOWN);
  maybe_start_reresolution_timer(glb_policy);

Suggest moving this down to an else clause after the if block on the next line.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 904 at r5 (raw file):

    gpr_log(GPR_INFO, "before cancelling re-re timer");
    grpc_timer_cancel(&glb_policy->reresolution_timer);
    glb_policy->reresolution_timer_active = false;

I suspect this is the cause of the timer bug you're trying to track down: We should not be setting reresolution_timer_active to false outside of the timer callback itself, because even once we call grpc_timer_cancel(), the callback could still be pending, and we can't reuse the grpc_closure object until the callback has actually been executed.

I think this line should be removed.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1046 at r5 (raw file):

    gpr_log(GPR_INFO, "before cancelling re-re timer");
    grpc_timer_cancel(&glb_policy->reresolution_timer);
    glb_policy->reresolution_timer_active = false;

Same here.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1679 at r5 (raw file):

              gpr_log(GPR_INFO, "before cancelling re-re timer");
              grpc_timer_cancel(&glb_policy->reresolution_timer);
              glb_policy->reresolution_timer_active = false;

Same here.


src/core/lib/iomgr/timer_generic.cc, line 168 at r5 (raw file):

    abort();
  } else {
    gpr_log(GPR_ERROR, "** Removed timer (%p)", t);

I assume this was added just for debugging purposes. Please make sure to revert the changes to this file before this PR gets merged.


test/cpp/end2end/grpclb_end2end_test.cc, line 1141 at r5 (raw file):

  addresses.emplace_back(AddressData{balancer_servers_[1].port_, true, ""});
  gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 ==========");
  SetNextResolution(addresses);

The goal of this test is to check the new functionality being added in this PR, which is that the grpclb policy will request reresolution. However, if we're explicitly telling the fake resolver to return new data here, then this test doesn't actually cover that new functionality, because it would return the new data even if the grpclb policy did not request reresolution.

I think that in order to test this, we need a way to set the fake resolver's results_upon_error member without setting its next_results member. This will probably require adding a new method to grpc_fake_resolver_response_generator.


test/cpp/end2end/grpclb_end2end_test.cc, line 1171 at r5 (raw file):

// Check LB policy name for the channel.
EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName());

This isn't necessary; it's already covered in various tests above.


Comments from Reviewable

@AspirinSJL
Copy link
Member Author

Review status: all files reviewed at latest revision, 7 unresolved discussions, some commit checks failed.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 899 at r5 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Suggest moving this down to an else clause after the if block on the next line.

Done.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 904 at r5 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

I suspect this is the cause of the timer bug you're trying to track down: We should not be setting reresolution_timer_active to false outside of the timer callback itself, because even once we call grpc_timer_cancel(), the callback could still be pending, and we can't reuse the grpc_closure object until the callback has actually been executed.

I think this line should be removed.

Right, this is the cause. Thanks! I will also delete the unnecessary glb_policy->retry_timer_active = false; and glb_policy->fallback_timer_active = false;.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1046 at r5 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Same here.

Done.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 1679 at r5 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Same here.

Done.


src/core/lib/iomgr/timer_generic.cc, line 168 at r5 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

I assume this was added just for debugging purposes. Please make sure to revert the changes to this file before this PR gets merged.

Yes, it's in the temp-logging commit. I will revert it before merging.


test/cpp/end2end/grpclb_end2end_test.cc, line 1141 at r5 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

The goal of this test is to check the new functionality being added in this PR, which is that the grpclb policy will request reresolution. However, if we're explicitly telling the fake resolver to return new data here, then this test doesn't actually cover that new functionality, because it would return the new data even if the grpclb policy did not request reresolution.

I think that in order to test this, we need a way to set the fake resolver's results_upon_error member without setting its next_results member. This will probably require adding a new method to grpc_fake_resolver_response_generator.

Done.

Also, I changed grpc_fake_resolver_response_generator_set_response() to synchronously set the normal response, because I don't see any reason to do it in an async way.


test/cpp/end2end/grpclb_end2end_test.cc, line 1171 at r5 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

// Check LB policy name for the channel.
EXPECT_EQ("grpclb", channel_->GetLoadBalancingPolicyName());

This isn't necessary; it's already covered in various tests above.

Done. So only keeping one (Vanilla) is enough? I guess so because we will use grpclb as long as there is any balancer address, which is true for every test here. I am removing all of those except the Vanilla one.


Comments from Reviewable

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                          FILE SIZE
 ++++++++++++++ GROWING                                                            ++++++++++++++
  +2.4%    +352 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc        +352  +2.4%
      [NEW]    +303 update_lb_connectivity_status_locked                                  +303  [NEW]
       +14%    +136 glb_create                                                            +136   +14%
      [NEW]    +131 maybe_start_reresolution_timer                                        +131  [NEW]
      [NEW]     +72 on_reresolution_requested_locked                                       +72  [NEW]
       +48%     +57 glb_rr_connectivity_changed_locked                                     +57   +48%
      +1.7%     +22 lb_on_response_received_locked                                         +22  +1.7%
      +3.9%     +16 lb_on_server_status_received_locked                                    +16  +3.9%
      +3.1%     +13 [Unmapped]                                                             +13  +3.1%
      +2.0%     +12 glb_shutdown_locked                                                    +12  +2.0%

 -------------- SHRINKING                                                          --------------
  -1.3%     -16 src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc     -16  -1.3%
      [DEL]    -138 grpc_fake_resolver_response_generator_set_response                    -138  [DEL]
      [DEL]     -90 set_response_closure_fn                                                -90  [DEL]
      -3.7%      -8 [Unmapped]                                                              -8  -3.7%
  -0.5%      -3 src/core/ext/filters/client_channel/lb_policy.cc                        -3  -0.5%
      -1.7%      -3 grpc_lb_policy_try_reresolve                                            -3  -1.7%

 -+-+-+-+-+-+-+ MIXED                                                              +-+-+-+-+-+-+-
  +0.0%    +187 [None]                                                                -117  -0.0%

  +0.0%    +520 TOTAL                                                                 +216  +0.0%


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

libgrpc++.so

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

  [ = ]       0        0  [ = ]



@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +0.1%    +347 [None]                                                                                  +659  +0.0%
   +27%    +320 src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc                      +320   +27%
      [NEW]    +150 grpc_fake_resolver_response_generator_set_response_upon_error                           +150  [NEW]
      [NEW]    +117 set_response_closure_locked                                                             +117  [NEW]
       +41%     +56 grpc_fake_resolver_response_generator_set_response                                       +56   +41%
       +90%     +46 fake_resolver_channel_saw_error_locked                                                   +46   +90%
       +15%     +32 [Unmapped]                                                                               +32   +15%
       +22%      +9 fake_resolver_destroy                                                                     +9   +22%
  +0.3%     +48 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc                           +48  +0.3%
      [NEW] +1.46Ki rr_handover_locked(glb_lb_policy*) [clone .part.18]                                  +1.46Ki  [NEW]
      [NEW] +1.22Ki query_for_backends_locked(glb_lb_policy*) [clone .part.12]                           +1.22Ki  [NEW]
      [NEW]    +801 build_lb_channel_args(grpc_lb_addresses const*, grpc_fake_resolver_response_generato    +801  [NEW]
      [NEW]    +303 update_lb_connectivity_status_locked                                                    +303  [NEW]
      [NEW]    +223 rr_on_connectivity_changed_locked                                                       +223  [NEW]
      [NEW]    +210 extract_backend_addresses_locked(grpc_lb_addresses const*) [clone .isra.1]              +210  [NEW]
      [NEW]    +145 lb_call_data_shutdown(glb_lb_policy*) [clone .isra.3]                                   +145  [NEW]
      [NEW]    +125 rr_on_reresolution_requested_locked                                                     +125  [NEW]
      +6.2%     +64 glb_create                                                                               +64  +6.2%
      +2.5%     +16 lb_on_server_status_received_locked                                                      +16  +2.5%
  +9.1%     +45 src/core/ext/filters/client_channel/lb_policy.cc                                         +45  +9.1%
      +883%     +53 grpc_lb_policy_set_reresolve_closure_locked                                              +53  +883%

 -------------- SHRINKING                                                                            --------------
  -2.1%    -112 src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc                  -112  -2.1%
      [DEL]    -138 start_picking_locked(pick_first_lb_policy*) [clone .isra.1]                             -138  [DEL]
      [DEL]    -112 pf_set_reresolve_closure_locked                                                         -112  [DEL]
      [DEL]     -89 destroy_unselected_subchannels_locked(pick_first_lb_policy*) [clone .isra.2]             -89  [DEL]
  -1.8%    -112 src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc                -112  -1.8%
      [DEL]    -112 rr_set_reresolve_closure_locked                                                         -112  [DEL]
      [DEL]    -105 start_picking_locked(round_robin_lb_policy*) [clone .isra.1]                            -105  [DEL]

  +0.0%    +536 TOTAL                                                                                   +848  +0.0%


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

libgrpc++.so

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

  [ = ]       0        0  [ = ]



@grpc-testing
Copy link

[trickle] No significant performance differences

@markdroth
Copy link
Member

Reviewed 2 of 9 files at r27, 7 of 7 files at r28.
Review status: all files reviewed at latest revision, 4 unresolved discussions.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 854 at r28 (raw file):

  GPR_ASSERT(glb_policy->rr_connectivity_state != GRPC_CHANNEL_SHUTDOWN);
  GPR_ASSERT(glb_policy->rr_connectivity_state != GRPC_CHANNEL_IDLE);
  if ((glb_policy->lb_calld == nullptr ||

It just occurred to me that now that we're going to re-resolve whenever our connection to a single backend fails (which will be handled by rr_on_reresolution_requested_locked() above), we probably don't need to do it here. I think this code can just go away.


Comments from Reviewable

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@AspirinSJL
Copy link
Member Author

Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 854 at r28 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

It just occurred to me that now that we're going to re-resolve whenever our connection to a single backend fails (which will be handled by rr_on_reresolution_requested_locked() above), we probably don't need to do it here. I think this code can just go away.

Done.

Good catch!

I moved the checking of a good balancer connection to rr_on_reresolution_requested_locked().


Comments from Reviewable

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +9.1%     +45 src/core/ext/filters/client_channel/lb_policy.cc                                         +45  +9.1%
      +883%     +53 grpc_lb_policy_set_reresolve_closure_locked                                              +53  +883%
  +0.1%     +16 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc                           +16  +0.1%
      [NEW]    +801 build_lb_channel_args(grpc_lb_addresses const*, grpc_fake_resolver_response_generato    +801  [NEW]
      [NEW]    +303 update_lb_connectivity_status_locked                                                    +303  [NEW]
      [NEW]    +210 extract_backend_addresses_locked(grpc_lb_addresses const*) [clone .isra.1]              +210  [NEW]
      [NEW]    +162 rr_on_connectivity_changed_locked                                                       +162  [NEW]
      [NEW]    +145 lb_call_data_shutdown(glb_lb_policy*) [clone .isra.3]                                   +145  [NEW]
      [NEW]    +141 rr_on_reresolution_requested_locked                                                     +141  [NEW]
      +6.2%     +64 glb_create                                                                               +64  +6.2%
      +2.5%     +16 lb_on_server_status_received_locked                                                      +16  +2.5%

 -------------- SHRINKING                                                                            --------------
  -2.1%    -112 src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc                  -112  -2.1%
      [DEL]    -138 start_picking_locked(pick_first_lb_policy*) [clone .isra.1]                             -138  [DEL]
      [DEL]    -112 pf_set_reresolve_closure_locked                                                         -112  [DEL]
      [DEL]     -89 destroy_unselected_subchannels_locked(pick_first_lb_policy*) [clone .isra.2]             -89  [DEL]
  -1.8%    -112 src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc                -112  -1.8%
      [DEL]    -112 rr_set_reresolve_closure_locked                                                         -112  [DEL]
      [DEL]    -105 start_picking_locked(round_robin_lb_policy*) [clone .isra.1]                            -105  [DEL]

 -+-+-+-+-+-+-+ MIXED                                                                                +-+-+-+-+-+-+-
  +0.0%      +3 [None]                                                                               -1.18Ki  -0.0%
      -9.1%      -8 glb_lb_policy_vtable                                                                      -8  -9.1%
      -9.1%      -8 pick_first_lb_policy_vtable                                                               -8  -9.1%
      -9.1%      -8 round_robin_lb_policy_vtable                                                              -8  -9.1%

  -0.0%    -160 TOTAL                                                                                -1.34Ki  -0.0%


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

libgrpc++.so

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

  [ = ]       0        0  [ = ]



@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

Corrupt JSON data (indicates timeout or crash): 
    bm_fullstack_streaming_pump.BM_PumpStreamServerToClient_SockPair__8.opt.old: 1
    bm_fullstack_streaming_pump.BM_PumpStreamServerToClient_SockPair__8.counters.new: 1


[microbenchmarks] No significant performance differences

@markdroth
Copy link
Member

Reviewed 1 of 1 files at r29.
Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks failed.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 757 at r29 (raw file):

  // Handle the re-resolution request using glb's original re-resolution
  // closure.
  if (glb_policy->lb_calld == nullptr ||

Please add a comment here explaining that we only want to do a re-resolution if we're not talking to a balancer, because otherwise we expect to get updated addresses from the balancer.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 855 at r29 (raw file):

    return;
  }
  GPR_ASSERT(glb_policy->rr_connectivity_state != GRPC_CHANNEL_SHUTDOWN);

These assertions don't really buy us anything, because none of the code below requires these constraints, so let's just remove them.


Comments from Reviewable

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +9.1%     +45 src/core/ext/filters/client_channel/lb_policy.cc                                         +45  +9.1%
      +883%     +53 grpc_lb_policy_set_reresolve_closure_locked                                              +53  +883%

 -------------- SHRINKING                                                                            --------------
  -0.0%    -117 [None]                                                                               -1.27Ki  -0.0%
      -0.0%     -93 [Unmapped]                                                                           -1.25Ki  -0.0%
      -9.1%      -8 glb_lb_policy_vtable                                                                      -8  -9.1%
      -9.1%      -8 pick_first_lb_policy_vtable                                                               -8  -9.1%
      -9.1%      -8 round_robin_lb_policy_vtable                                                              -8  -9.1%
  -2.1%    -112 src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc                  -112  -2.1%
      [DEL]    -138 start_picking_locked(pick_first_lb_policy*) [clone .isra.1]                             -138  [DEL]
      [DEL]    -112 pf_set_reresolve_closure_locked                                                         -112  [DEL]
      [DEL]     -89 destroy_unselected_subchannels_locked(pick_first_lb_policy*) [clone .isra.2]             -89  [DEL]
  -1.8%    -112 src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc                -112  -1.8%
      [DEL]    -112 rr_set_reresolve_closure_locked                                                         -112  [DEL]
      [DEL]    -105 start_picking_locked(round_robin_lb_policy*) [clone .isra.1]                            -105  [DEL]
  -0.7%     -96 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc                           -96  -0.7%
      [DEL]    -801 build_lb_channel_args(grpc_lb_addresses const*, grpc_fake_resolver_response_generato    -801  [DEL]
      [DEL]    -303 update_lb_connectivity_status_locked                                                    -303  [DEL]
      [DEL]    -210 extract_backend_addresses_locked(grpc_lb_addresses const*) [clone .isra.2]              -210  [DEL]
      [DEL]    -145 lb_call_data_shutdown(glb_lb_policy*) [clone .isra.4]                                   -145  [DEL]
      [DEL]    -143 glb_set_reresolve_closure_locked                                                        -143  [DEL]
      [DEL]     -98 on_rr_connectivity_changed_locked                                                        -98  [DEL]
      -2.6%     -40 rr_handover_locked(glb_lb_policy*) [clone .part.19]                                      -40  -2.6%
      -3.9%     -32 glb_shutdown_locked                                                                      -32  -3.9%
      -2.2%     -16 glb_update_locked                                                                        -16  -2.2%
      -3.0%     -13 [Unmapped]                                                                               -13  -3.0%
      -2.0%      -8 glb_pick_locked                                                                           -8  -2.0%
      -7.4%      -8 glb_ping_one_locked                                                                       -8  -7.4%
      -2.9%      -8 glb_lb_channel_on_connectivity_changed_cb                                                 -8  -2.9%
      -3.5%      -7 glb_destroy                                                                               -7  -3.5%
     -25.0%      -3 glb_check_connectivity_locked                                                             -3 -25.0%
     -25.0%      -3 glb_notify_on_state_change_locked                                                         -3 -25.0%

  -0.0%    -392 TOTAL                                                                                -1.54Ki  -0.0%


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

libgrpc++.so

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

  [ = ]       0        0  [ = ]



@AspirinSJL
Copy link
Member Author

Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks failed.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 757 at r29 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Please add a comment here explaining that we only want to do a re-resolution if we're not talking to a balancer, because otherwise we expect to get updated addresses from the balancer.

Done.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 855 at r29 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

These assertions don't really buy us anything, because none of the code below requires these constraints, so let's just remove them.

Done.

Do we add assertions only when the code below require them? I think it's also helpful (e.g., for debugging) to assert some expectations at some points even when the code below don't rely on them.


Comments from Reviewable

@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@markdroth
Copy link
Member

Reviewed 1 of 1 files at r30.
Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 855 at r29 (raw file):

Previously, AspirinSJL (Juanli Shen) wrote…

Done.

Do we add assertions only when the code below require them? I think it's also helpful (e.g., for debugging) to assert some expectations at some points even when the code below don't rely on them.

Whenever you add an assertion, you are essentially adding a dependency on some external input whose value you are constraining. This dependency comes with a cost, because it means that if we ever change the external input such that it can be set to a value that the assertion is preventing, we need to remember to change the assertion -- and we might not even know where the assertion is when we change the external code. As a result, you should only add assertions if the benefit you get from the assertion outweighs the overhead of adding that dependency.

If you are writing code that is actually using an input but you are not expecting to ever receive certain values and it would unnecessarily complicate things to handle those values, then it makes sense to add an assertion, so that you blow up with a useful message before you get to code that was not written to handle the value (thus resulting in undefined behavior). In that situation, the assertion adds value (avoiding undefined behavior) and doesn't really add any cost, because if the calling code ever changed such that the assertion would fail, the code protected by the assertion would have needed to change anyway. In other words, in this case, the code already depends on the external code that provides the value, so the fact that the assertion is there doesn't add a new dependency.

In contrast, if you are writing code that does not actually care about the value that you are asserting on, the assertion does add a dependency without actually providing any significant value, so it's best to avoid it.


Comments from Reviewable

Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

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

Nice work!

@AspirinSJL
Copy link
Member Author

Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc, line 855 at r29 (raw file):

Previously, markdroth (Mark D. Roth) wrote…

Whenever you add an assertion, you are essentially adding a dependency on some external input whose value you are constraining. This dependency comes with a cost, because it means that if we ever change the external input such that it can be set to a value that the assertion is preventing, we need to remember to change the assertion -- and we might not even know where the assertion is when we change the external code. As a result, you should only add assertions if the benefit you get from the assertion outweighs the overhead of adding that dependency.

If you are writing code that is actually using an input but you are not expecting to ever receive certain values and it would unnecessarily complicate things to handle those values, then it makes sense to add an assertion, so that you blow up with a useful message before you get to code that was not written to handle the value (thus resulting in undefined behavior). In that situation, the assertion adds value (avoiding undefined behavior) and doesn't really add any cost, because if the calling code ever changed such that the assertion would fail, the code protected by the assertion would have needed to change anyway. In other words, in this case, the code already depends on the external code that provides the value, so the fact that the assertion is there doesn't add a new dependency.

In contrast, if you are writing code that does not actually care about the value that you are asserting on, the assertion does add a dependency without actually providing any significant value, so it's best to avoid it.

Thanks for explaining!

If we don't have the assertions here, is there any other way to check that the RR never changes to IDLE state? Or do we want to check that?


Comments from Reviewable

@grpc-testing
Copy link

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

libgrpc.so

     VM SIZE                                                                                            FILE SIZE
 ++++++++++++++ GROWING                                                                              ++++++++++++++
  +9.1%     +45 src/core/ext/filters/client_channel/lb_policy.cc                                         +45  +9.1%
      +883%     +53 grpc_lb_policy_set_reresolve_closure_locked                                              +53  +883%

 -------------- SHRINKING                                                                            --------------
  -0.0%    -117 [None]                                                                               -1.26Ki  -0.0%
      -0.0%     -93 [Unmapped]                                                                           -1.24Ki  -0.0%
      -9.1%      -8 glb_lb_policy_vtable                                                                      -8  -9.1%
      -9.1%      -8 pick_first_lb_policy_vtable                                                               -8  -9.1%
      -9.1%      -8 round_robin_lb_policy_vtable                                                              -8  -9.1%
  -2.1%    -112 src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc                  -112  -2.1%
      [DEL]    -138 start_picking_locked(pick_first_lb_policy*) [clone .isra.1]                             -138  [DEL]
      [DEL]    -112 pf_set_reresolve_closure_locked                                                         -112  [DEL]
      [DEL]     -89 destroy_unselected_subchannels_locked(pick_first_lb_policy*) [clone .isra.2]             -89  [DEL]
  -1.8%    -112 src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc                -112  -1.8%
      [DEL]    -112 rr_set_reresolve_closure_locked                                                         -112  [DEL]
      [DEL]    -105 start_picking_locked(round_robin_lb_policy*) [clone .isra.1]                            -105  [DEL]
  -0.7%     -96 src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc                           -96  -0.7%
      [DEL]    -801 build_lb_channel_args(grpc_lb_addresses const*, grpc_fake_resolver_response_generato    -801  [DEL]
      [DEL]    -303 update_lb_connectivity_status_locked                                                    -303  [DEL]
      [DEL]    -210 extract_backend_addresses_locked(grpc_lb_addresses const*) [clone .isra.2]              -210  [DEL]
      [DEL]    -145 lb_call_data_shutdown(glb_lb_policy*) [clone .isra.4]                                   -145  [DEL]
      [DEL]    -143 glb_set_reresolve_closure_locked                                                        -143  [DEL]
      [DEL]     -98 on_rr_connectivity_changed_locked                                                        -98  [DEL]
      -2.6%     -40 rr_handover_locked(glb_lb_policy*) [clone .part.17]                                      -40  -2.6%
      -3.9%     -32 glb_shutdown_locked                                                                      -32  -3.9%
      -2.2%     -16 glb_update_locked                                                                        -16  -2.2%
      -3.0%     -13 [Unmapped]                                                                               -13  -3.0%
      -2.0%      -8 glb_pick_locked                                                                           -8  -2.0%
      -7.4%      -8 glb_ping_one_locked                                                                       -8  -7.4%
      -2.9%      -8 glb_lb_channel_on_connectivity_changed_cb                                                 -8  -2.9%
      -3.5%      -7 glb_destroy                                                                               -7  -3.5%
     -25.0%      -3 glb_check_connectivity_locked                                                             -3 -25.0%
     -25.0%      -3 glb_notify_on_state_change_locked                                                         -3 -25.0%

  -0.0%    -392 TOTAL                                                                                -1.53Ki  -0.0%


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

libgrpc++.so

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

  [ = ]       0        0  [ = ]



@grpc-testing
Copy link

[trickle] No significant performance differences

@grpc-testing
Copy link

[microbenchmarks] No significant performance differences

@AspirinSJL
Copy link
Member Author

Anyway, it's so green, let's ship it!

@AspirinSJL AspirinSJL merged commit 836fa8b into grpc:master Feb 7, 2018
@AspirinSJL AspirinSJL deleted the grpclb_reresolution branch February 7, 2018 02:55
@markdroth
Copy link
Member

If we don't have the assertions here, is there any other way to check that the RR never changes to IDLE state? Or do we want to check that?

I don't think this is something we need to check for. In general, we should have tests that cover the behavior of RR, but it's hard to write tests for the absence of a behavior, unless there are specific conditions under which the code is likely to exhibit that behavior (and I don't think there are in this case).

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.

None yet

9 participants