Skip to content

Commit

Permalink
kvserver: touch up raft ready handling log
Browse files Browse the repository at this point in the history
The bytes printed after "wrote" where the append bytes only, this was
confusing. Consolidate. Also, no need to print whether it's sync or
non-blocking-sync again because we already printed that in the timing section.

Found in cockroachdb#100096.

Epic: none
Release note: None
  • Loading branch information
tbg committed Apr 14, 2023
1 parent 582880a commit 4180659
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
24 changes: 9 additions & 15 deletions pkg/kv/kvserver/replica_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,33 +635,27 @@ func (s handleRaftReadyStats) SafeFormat(p redact.SafePrinter, _ rune) {
dUnaccounted := dTotal - dSnap - dAppend - dApply - dPebble

{
var sync redact.SafeString
p.Printf("raft ready handling: %.2fs [append=%.2fs, apply=%.2fs, ",
dTotal.Seconds(), dAppend.Seconds(), dApply.Seconds())
if s.append.Sync {
var sync redact.SafeString
if s.append.NonBlocking {
sync = "-non-blocking-sync"
sync = "non-blocking-sync" // actual sync time not reflected in this case
} else {
sync = "-sync"
sync = "sync"
}
p.Printf("%s=%.2fs", sync, dPebble.Seconds())
}
p.Printf("raft ready handling: %.2fs [append=%.2fs, apply=%.2fs, commit-batch%s=%.2fs",
dTotal.Seconds(), dAppend.Seconds(), dApply.Seconds(), sync, dPebble.Seconds())
}
if dSnap > 0 {
p.Printf(", snap=%.2fs", dSnap.Seconds())
}
p.Printf(", other=%.2fs]", dUnaccounted.Seconds())

p.Printf(", wrote %s",
humanizeutil.IBytes(s.append.PebbleBytes),
)
if s.append.Sync {
p.SafeString(" sync")
if s.append.NonBlocking {
p.SafeString("(non-blocking)")
}
p.Printf(", wrote [")
if b := s.append.PebbleBytes; b > 0 {
p.Printf("append-batch=%s, ", humanizeutil.IBytes(b))
}
p.SafeString(" [")

if b, n := s.append.RegularBytes, s.append.RegularEntries; n > 0 || b > 0 {
p.Printf("append-ent=%s (%d), ", humanizeutil.IBytes(b), n)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/testdata/handle_raft_ready_stats.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
echo
----
raft ready handling: 5.00s [append=1.00s, apply=1.00s, commit-batch-sync=1.00s, snap=1.00s, other=1.00s], wrote 5.0 KiB sync [append-ent=1.0 KiB (7), append-sst=5.0 MiB (3), apply=3 B (2 in 9 batches)], state_assertions=4, snapshot applied
raft ready handling: 5.00s [append=1.00s, apply=1.00s, sync=1.00s, snap=1.00s, other=1.00s], wrote [append-batch=5.0 KiB, append-ent=1.0 KiB (7), append-sst=5.0 MiB (3), apply=3 B (2 in 9 batches)], state_assertions=4, snapshot applied

0 comments on commit 4180659

Please sign in to comment.