Quellcode durchsuchen

Apply leaf cleanup to threadz samples

The legacy profilez parser handles duplicate leaf samples that are a
common artifact of satck unwinding. Apply the same technique to threadz
profiles where duplicate samples also occur.
Raul Silvera vor 9 Jahren
Ursprung
Commit
4d8e0fa166
1 geänderte Dateien mit 10 neuen und 5 gelöschten Zeilen
  1. 10
    5
      profile/legacy_profile.go

+ 10
- 5
profile/legacy_profile.go Datei anzeigen

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
 	// The profile handler may duplicate the leaf frame, because it gets
385
 	// The profile handler may duplicate the leaf frame, because it gets
377
 	// its address both from stack unwinding and from the signal
386
 	// its address both from stack unwinding and from the signal
378
 	// context. Detect this and delete the duplicate, which has been
387
 	// context. Detect this and delete the duplicate, which has been
383
 			s.Location = append(s.Location[:1], s.Location[2:]...)
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
 // parseCPUSamples parses a collection of profilez samples from a
397
 // parseCPUSamples parses a collection of profilez samples from a
936
 		return nil, err
940
 		return nil, err
937
 	}
941
 	}
938
 
942
 
943
+	cleanupDuplicateLocations(p)
939
 	return p, nil
944
 	return p, nil
940
 }
945
 }
941
 
946