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(flamegraph): Dispatch candidates using goroutine #513

Closed
wants to merge 3 commits into from
Closed
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: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
- Remove module frame in python ([#496](https://github.com/getsentry/vroom/pull/496))
- Handle js profile normalization for react+android profiles ([#499](https://github.com/getsentry/vroom/pull/499))
- Fix metrics example list ([#505](https://github.com/getsentry/vroom/pull/505))
- Increase readjob channel size ([#512](https://github.com/getsentry/vroom/pull/512))
- Increase readjob channel size ([#512](https://github.com/getsentry/vroom/pull/512))

**Internal**:

Expand Down Expand Up @@ -102,6 +102,7 @@
- Lift Intervals struct to utils ([#498](https://github.com/getsentry/vroom/pull/498))
- Fix flakey test for profile examples ([#504](https://github.com/getsentry/vroom/pull/504))
- Instrument flamegraph generation with spans ([#510](https://github.com/getsentry/vroom/pull/510)), ([#511](https://github.com/getsentry/vroom/pull/511))
- Dispatch candidates using goroutine ([#513](https://github.com/getsentry/vroom/pull/513))

## 23.12.0

Expand Down
60 changes: 32 additions & 28 deletions internal/flamegraph/flamegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,37 +483,41 @@ func GetFlamegraphFromCandidates(
results := make(chan storageutil.ReadJobResult, numCandidates)
defer close(results)

dispatchSpan := span.StartChild("dispatch candidates")
dispatchSpan.SetData("transaction_candidates", len(transactionProfileCandidates))
dispatchSpan.SetData("continuous_candidates", len(continuousProfileCandidates))

for _, candidate := range transactionProfileCandidates {
jobs <- profile.ReadJob{
Ctx: ctx,
OrganizationID: organizationID,
ProjectID: candidate.ProjectID,
ProfileID: candidate.ProfileID,
Storage: storage,
Result: results,
// We dispatch the read jobs within a goroutine so we can start reading the results
// immediately and NOT block until all the candidates have been dispatched.
go func() {
dispatchSpan := span.StartChild("dispatch candidates")
dispatchSpan.SetData("transaction_candidates", len(transactionProfileCandidates))
dispatchSpan.SetData("continuous_candidates", len(continuousProfileCandidates))

for _, candidate := range transactionProfileCandidates {
jobs <- profile.ReadJob{
Ctx: ctx,
OrganizationID: organizationID,
ProjectID: candidate.ProjectID,
ProfileID: candidate.ProfileID,
Storage: storage,
Result: results,
}
}
}

for _, candidate := range continuousProfileCandidates {
jobs <- chunk.ReadJob{
Ctx: ctx,
OrganizationID: organizationID,
ProjectID: candidate.ProjectID,
ProfilerID: candidate.ProfilerID,
ChunkID: candidate.ChunkID,
TransactionID: candidate.TransactionID,
ThreadID: candidate.ThreadID,
Start: candidate.Start,
End: candidate.End,
Storage: storage,
Result: results,
for _, candidate := range continuousProfileCandidates {
jobs <- chunk.ReadJob{
Ctx: ctx,
OrganizationID: organizationID,
ProjectID: candidate.ProjectID,
ProfilerID: candidate.ProfilerID,
ChunkID: candidate.ChunkID,
TransactionID: candidate.TransactionID,
ThreadID: candidate.ThreadID,
Start: candidate.Start,
End: candidate.End,
Storage: storage,
Result: results,
}
}
}
dispatchSpan.Finish()
dispatchSpan.Finish()
}()

var flamegraphTree []*nodetree.Node

Expand Down
Loading