summaryrefslogtreecommitdiff
path: root/internal/flamegraph/worker.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-06 21:27:31 +0300
committerPaul Buetow <paul@buetow.org>2025-04-06 21:27:31 +0300
commit6ca3491f421e8506fa3ff832a51b3a7d8a5c7ef6 (patch)
tree701d955b507929c8cb4b21c2fd40fe1ca12f3b0c /internal/flamegraph/worker.go
parent70d0c28c24dd7b69b3d711574574f8b2a1d8ad0c (diff)
initial dumping in new ior data format
Diffstat (limited to 'internal/flamegraph/worker.go')
-rw-r--r--internal/flamegraph/worker.go60
1 files changed, 6 insertions, 54 deletions
diff --git a/internal/flamegraph/worker.go b/internal/flamegraph/worker.go
index e47329e..a24be6d 100644
--- a/internal/flamegraph/worker.go
+++ b/internal/flamegraph/worker.go
@@ -2,23 +2,19 @@ package flamegraph
import (
"context"
+ "fmt"
"ior/internal/event"
- "ior/internal/types"
"sync"
"time"
)
type worker struct {
- collapsed collapsed
- iod iorData
- done chan struct{}
+ iod iorData
+ done chan struct{}
}
func newWorker() worker {
- return worker{
- collapsed: make(collapsed), // COLLAPSED: Retire ocne newIorData implemented
- iod: newIorData(), // TODO: make flags global, so i don't have to pass them through the whole code base
- }
+ return worker{iod: newIorData()}
}
func (w worker) run(ctx context.Context, wg *sync.WaitGroup, ch <-chan *event.Pair) {
@@ -27,12 +23,8 @@ func (w worker) run(ctx context.Context, wg *sync.WaitGroup, ch <-chan *event.Pa
for {
select {
case ev := <-ch:
- // var filePath string
- // if ev.File == nil {
- // filePath = "N:file"
- // } else {
- // filePath = ev.File.Name()
- // }
+ fmt.Println("worker got event", ev)
+ w.iod.add(ev)
ev.Recycle()
default:
@@ -45,43 +37,3 @@ func (w worker) run(ctx context.Context, wg *sync.WaitGroup, ch <-chan *event.Pa
}
}
}
-
-// TODO: Retire collapsed
-func (w worker) runCollapsed(ctx context.Context, wg *sync.WaitGroup, ch <-chan *event.Pair) {
- {
- defer wg.Done()
-
- for {
- select {
- case ev := <-ch:
- var filePath string
- if ev.File == nil {
- filePath = "N:file"
- } else {
- filePath = ev.File.Name()
- }
- pathMap, ok := w.collapsed[filePath]
- if !ok {
- pathMap = make(map[types.TraceId]collapsedCounter)
- }
-
- traceId := ev.EnterEv.GetTraceId()
- cnt := pathMap[traceId]
- cnt.count++
- cnt.duration += ev.Duration
- pathMap[traceId] = cnt
-
- w.collapsed[filePath] = pathMap
- ev.Recycle()
-
- default:
- select {
- case <-ctx.Done():
- return
- default:
- time.Sleep(time.Millisecond * 10)
- }
- }
- }
- }
-}