Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug of incomplete records when threads arrive at the cpu anal… #364

Merged
merged 3 commits into from
Nov 23, 2022
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### New features
- Add a new tool: A debug tool for Trace Profiling is provided for developers to troubleshoot problems.([#363](https://github.com/CloudDectective-Harmonycloud/kindling/pull/363))

### Bug fixes
- Fix the bug of incomplete records when threads arrive at the cpu analyzer for the first time. ([#364](https://github.com/CloudDectective-Harmonycloud/kindling/pull/364))

## v0.5.0 - 2022-11-02
### New features
- Add a new feature: Trace Profiling. See more details about it on our [website](http://kindling.harmonycloud.cn). ([#335](https://github.com/CloudDectective-Harmonycloud/kindling/pull/335))
Expand Down
18 changes: 13 additions & 5 deletions collector/pkg/component/analyzer/cpuanalyzer/cpu_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package cpuanalyzer

import (
"fmt"
"strconv"
"sync"

"github.com/Kindling-project/kindling/collector/pkg/component"
"github.com/Kindling-project/kindling/collector/pkg/component/analyzer"
"github.com/Kindling-project/kindling/collector/pkg/component/consumer"
"github.com/Kindling-project/kindling/collector/pkg/model"
"github.com/Kindling-project/kindling/collector/pkg/model/constnames"
"go.uber.org/zap/zapcore"
"strconv"
"sync"
)

const (
Expand Down Expand Up @@ -221,9 +222,16 @@ func (ca *CpuAnalyzer) PutEventToSegments(pid uint32, tid uint32, threadName str
(newTimeSegments.BaseTime+uint64(i+1))*nanoToSeconds)
newTimeSegments.Segments.UpdateByIndex(i, segment)
}
val := newTimeSegments.Segments.GetByIndex(0)
segment := val.(*Segment)
segment.putTimedEvent(event)

endOffset := int(event.EndTimestamp()/nanoToSeconds - newTimeSegments.BaseTime)

for i := 0; i <= endOffset && i < maxSegmentSize; i++ {
val := newTimeSegments.Segments.GetByIndex(i)
segment := val.(*Segment)
segment.putTimedEvent(event)
segment.IsSend = 0
}

tidCpuEvents[tid] = newTimeSegments
}
}
Expand Down