Skip to content

Commit

Permalink
Merge pull request #7 from rauls5382/master
Browse files Browse the repository at this point in the history
Apply leaf cleanup to threadz samples
  • Loading branch information
hk-cho committed Mar 11, 2016
2 parents 00709b5 + 4d8e0fa commit df108c6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions profile/legacy_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,15 @@ func cpuProfile(b []byte, period int64, parse func(b []byte) (uint64, []byte)) (
}
}

if err := p.ParseMemoryMap(bytes.NewBuffer(b)); err != nil {
return nil, err
}

cleanupDuplicateLocations(p)
return p, nil
}

func cleanupDuplicateLocations(p *Profile) {
// The profile handler may duplicate the leaf frame, because it gets
// its address both from stack unwinding and from the signal
// context. Detect this and delete the duplicate, which has been
Expand All @@ -383,11 +392,6 @@ func cpuProfile(b []byte, period int64, parse func(b []byte) (uint64, []byte)) (
s.Location = append(s.Location[:1], s.Location[2:]...)
}
}

if err := p.ParseMemoryMap(bytes.NewBuffer(b)); err != nil {
return nil, err
}
return p, nil
}

// parseCPUSamples parses a collection of profilez samples from a
Expand Down Expand Up @@ -936,6 +940,7 @@ func parseThread(b []byte) (*Profile, error) {
return nil, err
}

cleanupDuplicateLocations(p)
return p, nil
}

Expand Down

0 comments on commit df108c6

Please sign in to comment.