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

*: Limit calls to pretty.ToJSON to more verbose debugging, warnings, and errors to improve performance #7169

Closed
wants to merge 1 commit into from

Conversation

townba
Copy link
Contributor

@townba townba commented Apr 25, 2024

RELEASE NOTES: None

@aranjans aranjans added fixit Type: Behavior Change Behavior changes not categorized as bugs and removed fixit labels Apr 30, 2024
@aranjans aranjans added this to the 1.64 Release milestone Apr 30, 2024
@aranjans
Copy link
Collaborator

LGTM! @zasweq can you also please have a pass through this PR?

@aranjans aranjans requested a review from zasweq April 30, 2024 16:04
@zasweq zasweq assigned zasweq and townba and unassigned zasweq Apr 30, 2024
@ginayeh ginayeh assigned zasweq and unassigned townba Apr 30, 2024
Copy link
Contributor

@zasweq zasweq left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -194,5 +194,7 @@ func (ccr *ccResolverWrapper) addChannelzTraceEvent(s resolver.State) {
} else if len(ccr.curState.Addresses) == 0 && len(s.Addresses) > 0 {
updates = append(updates, "resolver returned new addresses")
}
channelz.Infof(logger, ccr.cc.channelz, "Resolver state updated: %s (%v)", pretty.ToJSON(s), strings.Join(updates, "; "))
if channelz.IsOn() || logger.V(2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for the additional channelz.IsOn() bool conditional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's similar to the reason for the logger.V(2) check. We only want to call pretty.ToJSON when we know we're going to use the result. channelz.Infof can add a trace event, log, or both, so we want to call it when channelz data collection is on, we're logging at depth 2, or both.

Copy link
Collaborator

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

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

lgtm

@townba
Copy link
Contributor Author

townba commented May 2, 2024

Please don't merge this yet. Doug Fawley and I are still discussing this approach.

@arvindbr8 arvindbr8 removed this from the 1.64 Release milestone May 2, 2024
@dfawley
Copy link
Member

dfawley commented May 6, 2024

I'm going to close this since I think we got the same win just from the Debugf calls. We can reopen or recreate in the future if needed.

@dfawley dfawley closed this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants