|
@@ -676,9 +676,10 @@ func scaleHeapSample(count, size, rate int64) (int64, int64) {
|
676
|
676
|
return int64(float64(count) * scale), int64(float64(size) * scale)
|
677
|
677
|
}
|
678
|
678
|
|
679
|
|
-// parseContention parses a contentionz profile and returns a newly
|
680
|
|
-// populated Profile.
|
681
|
|
-func parseContention(b []byte) (p *Profile, err error) {
|
|
679
|
+// parseContention parses a mutex or contention profile. There are 2 cases:
|
|
680
|
+// "--- contentionz " for legacy C++ profiles (and backwards compatibility)
|
|
681
|
+// "--- mutex:" or "--- contention:" for profiles generated by the Go runtime.
|
|
682
|
+func parseContention(b []byte) (*Profile, error) {
|
682
|
683
|
s := bufio.NewScanner(bytes.NewBuffer(b))
|
683
|
684
|
if !s.Scan() {
|
684
|
685
|
if err := s.Err(); err != nil {
|
|
@@ -686,13 +687,16 @@ func parseContention(b []byte) (p *Profile, err error) {
|
686
|
687
|
}
|
687
|
688
|
return nil, errUnrecognized
|
688
|
689
|
}
|
689
|
|
- line := s.Text()
|
690
|
690
|
|
691
|
|
- if !strings.HasPrefix(line, "--- contention") {
|
|
691
|
+ switch l := s.Text(); {
|
|
692
|
+ case strings.HasPrefix(l, "--- contentionz "):
|
|
693
|
+ case strings.HasPrefix(l, "--- mutex:"):
|
|
694
|
+ case strings.HasPrefix(l, "--- contention:"):
|
|
695
|
+ default:
|
692
|
696
|
return nil, errUnrecognized
|
693
|
697
|
}
|
694
|
698
|
|
695
|
|
- p = &Profile{
|
|
699
|
+ p := &Profile{
|
696
|
700
|
PeriodType: &ValueType{Type: "contentions", Unit: "count"},
|
697
|
701
|
Period: 1,
|
698
|
702
|
SampleType: []*ValueType{
|
|
@@ -789,7 +793,7 @@ func parseContention(b []byte) (p *Profile, err error) {
|
789
|
793
|
return nil, err
|
790
|
794
|
}
|
791
|
795
|
|
792
|
|
- if err = parseAdditionalSections(s, p); err != nil {
|
|
796
|
+ if err := parseAdditionalSections(s, p); err != nil {
|
793
|
797
|
return nil, err
|
794
|
798
|
}
|
795
|
799
|
|