输出日志更加合理
This commit is contained in:
parent
af8568c8cb
commit
6dd44fff53
16
sm.go
16
sm.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/474420502/execute/triggered"
|
"github.com/474420502/execute/triggered"
|
||||||
sm "github.com/lni/dragonboat/v4/statemachine"
|
sm "github.com/lni/dragonboat/v4/statemachine"
|
||||||
|
@ -37,14 +38,13 @@ func NewSMQueue(shardID uint64, replicaID uint64) sm.IStateMachine {
|
||||||
queues: make(map[string]*PriorityQueue[QueueItem]),
|
queues: make(map[string]*PriorityQueue[QueueItem]),
|
||||||
|
|
||||||
counter: triggered.RegisterExecute[int64](func(params *triggered.Params[int64]) {
|
counter: triggered.RegisterExecute[int64](func(params *triggered.Params[int64]) {
|
||||||
if params.Value != 0 {
|
var m runtime.MemStats
|
||||||
var m runtime.MemStats
|
runtime.ReadMemStats(&m)
|
||||||
runtime.ReadMemStats(&m)
|
allocMB := float64(m.Alloc) / 1024 / 1024
|
||||||
allocMB := float64(m.Alloc) / 1024 / 1024
|
// totalAllocMB := float64(m.TotalAlloc) / 1024 / 1024
|
||||||
// totalAllocMB := float64(m.TotalAlloc) / 1024 / 1024
|
sysMB := float64(m.Sys) / 1024 / 1024
|
||||||
sysMB := float64(m.Sys) / 1024 / 1024
|
log.Printf("队列堆积数据: %d, Alloc = %.2f MB, Sys = %.2fMB\n", params.Value, allocMB, sysMB)
|
||||||
log.Printf("队列堆积数据: %d, Alloc = %.2f MB, Sys = %.2fMB\n", params.Value, allocMB, sysMB)
|
time.Sleep(time.Second * 10) // 每超过10秒 统计一次
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,9 +51,9 @@ var countPutPop *CountPutPop = &CountPutPop{
|
||||||
|
|
||||||
var logIntervalTimeHandler = triggered.RegisterExecute[*CountPutPop](func(params *triggered.Params[*CountPutPop]) {
|
var logIntervalTimeHandler = triggered.RegisterExecute[*CountPutPop](func(params *triggered.Params[*CountPutPop]) {
|
||||||
params.Value.Use(func(item *CountPutPop) {
|
params.Value.Use(func(item *CountPutPop) {
|
||||||
log.Printf("all pop: %d all put: %d\n", item.PutCount, item.PopCount)
|
log.Printf("all pop count: %d all put count: %d\n", item.PutCount, item.PopCount)
|
||||||
for k, v := range item.SelfCount {
|
for k, v := range item.SelfCount {
|
||||||
log.Printf("%s pop: %d\n", k, v)
|
log.Printf("uinty3d[%s] pop count: %d\n", k, v)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
time.Sleep(time.Second * 15)
|
time.Sleep(time.Second * 15)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user