Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions internal/etw/processors/fs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ package processors

import (
"expvar"
"sync"
"time"

"github.com/rabbitstack/fibratus/pkg/config"
"github.com/rabbitstack/fibratus/pkg/event"
"github.com/rabbitstack/fibratus/pkg/event/params"
Expand All @@ -31,8 +34,6 @@ import (
"github.com/rabbitstack/fibratus/pkg/util/va"
"golang.org/x/sys/windows"
"golang.org/x/time/rate"
"sync"
"time"
)

var (
Expand Down Expand Up @@ -371,11 +372,13 @@ func (f *fsProcessor) purge() {

// evict unmatched stack traces
for id, q := range f.buckets {
for i, evt := range q {
if time.Since(evt.Timestamp) > time.Second*30 {
f.buckets[id] = append(q[:i], q[i+1:]...)
s := q[:0]
for _, evt := range q {
if time.Since(evt.Timestamp) <= time.Second*30 {
s = append(s, evt)
}
}
f.buckets[id] = s
}

f.mu.Unlock()
Expand Down
10 changes: 7 additions & 3 deletions pkg/event/stackwalk.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ func (s *StackwalkDecorator) Pop(e *Event) *Event {
if !proc.IsCreateProcess() && proc.Params.MustGetPid() != pid {
continue
}
s.buckets[ev.StackID()] = append(qu[:i], qu[i+1:]...)
qu = append(qu[:i], qu[i+1:]...)
}
s.buckets[ev.StackID()] = qu
}
}

Expand Down Expand Up @@ -209,16 +210,18 @@ func (s *StackwalkDecorator) flush() []error {
errs := make([]error, 0)

for id, q := range s.buckets {
for i, evt := range q {
n := q[:0]
for _, evt := range q {
if time.Since(evt.Timestamp) < maxQueueTTLPeriod {
n = append(n, evt)
continue
}

stackwalkFlushes.Add(1)
err := s.q.push(evt)
if err != nil {
errs = append(errs, err)
}
s.buckets[id] = append(q[:i], q[i+1:]...)
if stackwalkEnqueued.Value() > 0 {
stackwalkEnqueued.Add(-1)
}
Expand All @@ -227,6 +230,7 @@ func (s *StackwalkDecorator) flush() []error {
}
stackwalkFlushesEvents.Add(evt.Name, 1)
}
s.buckets[id] = n
}

return errs
Expand Down
Loading