瀏覽代碼

Merge pull request #7 from rauls5382/master

Apply leaf cleanup to threadz samples
Hyoun Kyu Cho 9 年之前
父節點
當前提交
df108c626c
共有 1 個文件被更改,包括 10 次插入5 次删除
  1. 10
    5
      profile/legacy_profile.go

+ 10
- 5
profile/legacy_profile.go 查看文件

@@ -373,6 +373,15 @@ func cpuProfile(b []byte, period int64, parse func(b []byte) (uint64, []byte)) (
373 373
 		}
374 374
 	}
375 375
 
376
+	if err := p.ParseMemoryMap(bytes.NewBuffer(b)); err != nil {
377
+		return nil, err
378
+	}
379
+
380
+	cleanupDuplicateLocations(p)
381
+	return p, nil
382
+}
383
+
384
+func cleanupDuplicateLocations(p *Profile) {
376 385
 	// The profile handler may duplicate the leaf frame, because it gets
377 386
 	// its address both from stack unwinding and from the signal
378 387
 	// context. Detect this and delete the duplicate, which has been
@@ -383,11 +392,6 @@ func cpuProfile(b []byte, period int64, parse func(b []byte) (uint64, []byte)) (
383 392
 			s.Location = append(s.Location[:1], s.Location[2:]...)
384 393
 		}
385 394
 	}
386
-
387
-	if err := p.ParseMemoryMap(bytes.NewBuffer(b)); err != nil {
388
-		return nil, err
389
-	}
390
-	return p, nil
391 395
 }
392 396
 
393 397
 // parseCPUSamples parses a collection of profilez samples from a
@@ -936,6 +940,7 @@ func parseThread(b []byte) (*Profile, error) {
936 940
 		return nil, err
937 941
 	}
938 942
 
943
+	cleanupDuplicateLocations(p)
939 944
 	return p, nil
940 945
 }
941 946