Skip to content

Commit

Permalink
debug(proctree): split evictions from procs and threads
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeldtinoco committed Sep 13, 2023
1 parent 9482357 commit 16cd971
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/proctree/proctree.go
Expand Up @@ -56,12 +56,13 @@ type ProcessTree struct {

// NewProcessTree creates a new process tree.
func NewProcessTree(ctx context.Context, config ProcTreeConfig) (*ProcessTree, error) {
evicted := 0
procEvited := 0
thrEvicted := 0

// Create caches for processes.
processes, err := lru.NewWithEvict[uint32, *Process](
config.ProcessCacheSize,
func(uint32, *Process) { evicted++ },
func(uint32, *Process) { procEvited++ },
)
if err != nil {
return nil, errfmt.WrapError(err)
Expand All @@ -70,7 +71,7 @@ func NewProcessTree(ctx context.Context, config ProcTreeConfig) (*ProcessTree, e
// Create caches for threads.
threads, err := lru.NewWithEvict[uint32, *Thread](
config.ThreadCacheSize,
func(uint32, *Thread) { evicted++ },
func(uint32, *Thread) { thrEvicted++ },
)
if err != nil {
return nil, errfmt.WrapError(err)
Expand All @@ -88,13 +89,15 @@ func NewProcessTree(ctx context.Context, config ProcTreeConfig) (*ProcessTree, e
case <-ctx.Done():
return
case <-ticker15s.C:
if evicted != 0 {
if procEvited != 0 || thrEvicted != 0 {
logger.Debugw("proctree cache stats",
"recently evicted", evicted,
"processes evicted", procEvited,
"total processes", processes.Len(),
"threads evicted", thrEvicted,
"total threads", threads.Len(),
)
evicted = 0
procEvited = 0
thrEvicted = 0
}
case <-ticker1m.C:
logger.Debugw("proctree cache stats",
Expand Down

0 comments on commit 16cd971

Please sign in to comment.