Skip to content

Commit

Permalink
ovelord/state: minor tweaks to state lock tracing
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Borzecki <[email protected]>
  • Loading branch information
bboozzoo committed Jan 17, 2025
1 parent 5d30345 commit c5a0532
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 4 additions & 4 deletions overlord/state/locktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//go:build statelocktrace

/*
* Copyright (C) 2021 Canonical Ltd
* Copyright (C) 2025 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
Expand Down Expand Up @@ -70,7 +70,7 @@ func traceCallers(ts, heldMs, waitMs int64) error {
}

pc := make([]uintptr, 10)
// avoid 3 first callers on the stack: runtime.Callers(), this function and the parent
// ignore the first 3 callers on the stack: runtime.Callers(), this function and the parent
n := runtime.Callers(3, pc)
frames := runtime.CallersFrames(pc[:n])

Expand Down Expand Up @@ -104,8 +104,8 @@ func lockTimestamp() int64 {
return time.Now().UnixMilli()
}

// maybeSaveLockTime allows to save lock times when this overpass the threshold
// defined by through the SNAPD_STATE_LOCK_THRESHOLD_MS environment settings.
// maybeSaveLockTime logs the lock hold and wait times when either exceeds the
// threshold defined in the SNAPD_STATE_LOCK_THRESHOLD_MS environment variable.
func maybeSaveLockTime(lockWaitStart, lockHoldStart, now int64) {
if !traceStateLock {
return
Expand Down
9 changes: 3 additions & 6 deletions overlord/state/locktrace_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//go:build !statelocktrace

/*
* Copyright (C) 2021 Canonical Ltd
* Copyright (C) 2025 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
Expand All @@ -20,9 +20,6 @@

package state

func lockTimestamp() int64 {
return int64(0)
}
func lockTimestamp() int64 { return 0 }

func maybeSaveLockTime(lockWaitStart, lockHoldStart, now int64) {
}
func maybeSaveLockTime(lockWaitStart, lockHoldStart, now int64) {}

0 comments on commit c5a0532

Please sign in to comment.