Skip to content

Commit

Permalink
pkg/cover: parallelize symbolizeModule to speed up the symbolize
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangenj committed May 13, 2024
1 parent 748b2e8 commit dce836e
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions pkg/cover/backend/dwarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,30 @@ func symbolizeModule(target *targets.Target, interner *symbolizer.Interner, objD
func symbolize(target *targets.Target, interner *symbolizer.Interner, objDir, srcDir, buildDir string,
splitBuildDelimiters []string, pcs map[*Module][]uint64) ([]Frame, error) {
var frames []Frame
type frameResult struct {
frames []Frame
err error
}
frameC := make(chan frameResult, len(pcs))
for mod, pcs1 := range pcs {
frames1, err := symbolizeModule(target, interner, objDir, srcDir, buildDir, splitBuildDelimiters, mod, pcs1)
if err != nil {
return nil, err
go func(mod *Module, pcs []uint64) {
res := frameResult{}
frames, err := symbolizeModule(target, interner, objDir, srcDir, buildDir, splitBuildDelimiters, mod, pcs)
if err != nil {
res.err = err
frameC <- res
return
}
res.frames = frames
frameC <- res
}(mod, pcs1)
}
for range pcs {
res := <-frameC
if res.err != nil {
return nil, res.err
}
frames = append(frames, frames1...)
frames = append(frames, res.frames...)
}
return frames, nil
}
Expand Down

0 comments on commit dce836e

Please sign in to comment.