Skip to content

Commit

Permalink
kv: hoist log.ExpensiveLogEnabled outside loop in appendRefreshSpans
Browse files Browse the repository at this point in the history
This commit hoists the call to `log.ExpensiveLogEnabled` outside of the
per-span loop in `txnSpanRefresher.appendRefreshSpans`. The function is
too expensive to call once per span.

Release justification: low risk change that may close perf gap.

Release note: None.
  • Loading branch information
nvanbenschoten committed Sep 20, 2022
1 parent 0efe4f5 commit 69fc8d3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/kv/kvclient/kvcoord/txn_interceptor_span_refresher.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,9 @@ func (sr *txnSpanRefresher) tryRefreshTxnSpans(
func (sr *txnSpanRefresher) appendRefreshSpans(
ctx context.Context, ba roachpb.BatchRequest, br *roachpb.BatchResponse,
) error {
expLogEnabled := log.ExpensiveLogEnabled(ctx, 3)
return ba.RefreshSpanIterate(br, func(span roachpb.Span) {
if log.ExpensiveLogEnabled(ctx, 3) {
if expLogEnabled {
log.VEventf(ctx, 3, "recording span to refresh: %s", span.String())
}
sr.refreshFootprint.insert(span)
Expand Down

0 comments on commit 69fc8d3

Please sign in to comment.