Skip to content

Commit

Permalink
Merge #28423
Browse files Browse the repository at this point in the history
28423: sql: stop unconditional sprintfs of debug information r=jordanlewis a=jordanlewis

Commit eb22d4a added some unconditional sprintfs that seemed to be
guarded behind log.V(2) - they were in fact not guarded and were
unconditionally executed. This reduces allocations by about 5% and has a
corresponding throughput improvement on kv --read-percent=100.

Release note: None

Co-authored-by: Jordan Lewis <[email protected]>
  • Loading branch information
craig[bot] and jordanlewis committed Aug 10, 2018
2 parents 27cecbd + cdbf2df commit 06e1b4e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/sql/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ func (s *tableVersionState) incRefcount() {

func (s *tableVersionState) incRefcountLocked() {
s.mu.refcount++
log.VEventf(context.TODO(), 2, "tableVersionState.incRef: %s", s.stringLocked())
if log.V(2) {
log.VEventf(context.TODO(), 2, "tableVersionState.incRef: %s", s.stringLocked())
}
}

// The lease expiration stored in the database is of a different type.
Expand Down Expand Up @@ -866,7 +868,9 @@ func (t *tableState) upsertLocked(
table.mu.refcount += s.mu.refcount
s.mu.refcount = 0
s.mu.leased = false
log.VEventf(ctx, 2, "replaced lease: %s with %s", s.stringLocked(), table.stringLocked())
if log.V(2) {
log.VEventf(ctx, 2, "replaced lease: %s with %s", s.stringLocked(), table.stringLocked())
}
table.mu.Unlock()
s.mu.Unlock()
t.mu.active.remove(s)
Expand Down Expand Up @@ -960,7 +964,9 @@ func (t *tableState) release(
s.mu.Lock()
defer s.mu.Unlock()
s.mu.refcount--
log.VEventf(context.TODO(), 2, "release: %s", s.stringLocked())
if log.V(2) {
log.VEventf(context.TODO(), 2, "release: %s", s.stringLocked())
}
if s.mu.refcount < 0 {
panic(fmt.Sprintf("negative ref count: %s", s))
}
Expand Down

0 comments on commit 06e1b4e

Please sign in to comment.