Operational Remediation Reports
Mutex Budget Remediation Report
Spend a contention budget against a fixed limit and turn the acquired and rejected counts into a spend, drain, or throttle remediation action.
budget limit
The contention limit and budget are scalars, so the acquired and rejected counts that drive the remediation action stay deterministic and free of lock identity.
Mutex Budget Remediation Report
mutex_budget_remediation_report.go
Replay: real traced execution (multi-file project)
package main
import "fmt"
func main() {
var budget = 1
limit := 2
acquired := 0
rejected := 0
for i := 0; i < budget; i++ {
if acquired < limit {
acquired++
} else {
rejected++
}
}
remaining := limit - acquired
var action string
if rejected > 0 {
action = "throttle"
} else if remaining == 0 {
action = "drain"
} else {
action = "spend"
}
fmt.Printf("budget=%d acquired=%d rejected=%d %s\n", budget, acquired, rejected, action)
}
package main
import "fmt"
func main() {
var budget = 2
limit := 2
acquired := 0
rejected := 0
for i := 0; i < budget; i++ {
if acquired < limit {
acquired++
} else {
rejected++
}
}
remaining := limit - acquired
var action string
if rejected > 0 {
action = "throttle"
} else if remaining == 0 {
action = "drain"
} else {
action = "spend"
}
fmt.Printf("budget=%d acquired=%d rejected=%d %s\n", budget, acquired, rejected, action)
}
package main
import "fmt"
func main() {
var budget = 4
limit := 2
acquired := 0
rejected := 0
for i := 0; i < budget; i++ {
if acquired < limit {
acquired++
} else {
rejected++
}
}
remaining := limit - acquired
var action string
if rejected > 0 {
action = "throttle"
} else if remaining == 0 {
action = "drain"
} else {
action = "spend"
}
fmt.Printf("budget=%d acquired=%d rejected=%d %s\n", budget, acquired, rejected, action)
}
budget ← 1, limit ← 2, acquired ← 0, rejected ← 0
5func main() {6 var budget→ 1 = 1 //@budget=2, 47 limit→ 2 := 28 acquired→ 0 := 09 rejected→ 0 := 010 for i := 0; i < budget; i++ {for i := 0; i < budget; i++
9rejected := 010for i0 := 0; i < budget1; i++ {11 if acquired < limit {acquired ← 1
10for i := 0; i < budget; i++ {11 if acquired0 < limit2 {12 acquired→ 1++13 } else {remaining ← 1, action ← ""
16}17remaining→ 1 := limit2 - acquired118var action→ "" string19if rejected > 0 {action ← "spend"
22 action = "drain"23} else {24 action→ "spend" = "spend"25}fmt.Printf("budget=%d acquired=%d rejected=%d %s ", budget, acquired, …
25 }26 fmt.Printf("budget=%d acquired=%d rejected=%d %s\n", budget1, acquired1, rejected0, action"spend")27}outputbudget=1 acquired=1 rejected=0 spend
budget ← 2, limit ← 2, acquired ← 0, rejected ← 0
5func main() {6 var budget→ 2 = 27 limit→ 2 := 28 acquired→ 0 := 09 rejected→ 0 := 010 for i := 0; i < budget; i++ {for i := 0; i < budget; i++
pass 1 of 29rejected := 010for i0 := 0; i < budget2; i++ {11 if acquired < limit {acquired ← 1
pass 1 of 210for i := 0; i < budget; i++ {11 if acquired0 < limit2 {12 acquired→ 1++13 } else {for i := 0; i < budget; i++
pass 2 of 29rejected := 010for i1 := 0; i < budget2; i++ {11 if acquired < limit {acquired ← 2
pass 2 of 210for i := 0; i < budget; i++ {11 if acquired1 < limit2 {12 acquired→ 2++13 } else {remaining ← 0, action ← ""
16}17remaining→ 0 := limit2 - acquired218var action→ "" string19if rejected > 0 {action ← "drain"
20 action = "throttle"21} else if remaining0 == 0 {22 action→ "drain" = "drain"23} else {fmt.Printf("budget=%d acquired=%d rejected=%d %s ", budget, acquired, …
25 }26 fmt.Printf("budget=%d acquired=%d rejected=%d %s\n", budget2, acquired2, rejected0, action"drain")27}outputbudget=2 acquired=2 rejected=0 drain
budget ← 4, limit ← 2, acquired ← 0, rejected ← 0
5func main() {6 var budget→ 4 = 47 limit→ 2 := 28 acquired→ 0 := 09 rejected→ 0 := 010 for i := 0; i < budget; i++ {for i := 0; i < budget; i++
pass 1 of 49rejected := 010for i0 := 0; i < budget4; i++ {11 if acquired < limit {All 4 passes — pass 1 is the card above pass ilimitacquiredrejected1 0 2 0 → 1 — 2 1 2 1 → 2 — 3 2 — — 0 → 1 4 3 — — 1 → 2 acquired ← 1
pass 1 of 210for i := 0; i < budget; i++ {11 if acquired0 < limit2 {12 acquired→ 1++13 } else {acquired ← 2
pass 2 of 210for i := 0; i < budget; i++ {11 if acquired1 < limit2 {12 acquired→ 2++13 } else {rejected ← 1
pass 1 of 212 acquired++13} else {14 rejected→ 1++15}rejected ← 2
pass 2 of 212 acquired++13} else {14 rejected→ 2++15}remaining ← 0, action ← ""
16}17remaining→ 0 := limit2 - acquired218var action→ "" string19if rejected > 0 {action ← "throttle"
18var action string19if rejected2 > 0 {20 action→ "throttle" = "throttle"21} else if remaining == 0 {fmt.Printf("budget=%d acquired=%d rejected=%d %s ", budget, acquired, …
25 }26 fmt.Printf("budget=%d acquired=%d rejected=%d %s\n", budget4, acquired2, rejected2, action"throttle")27}outputbudget=4 acquired=2 rejected=2 throttle