[google-perftools/f14/master] add fix for jemalloc
Tom Callaway
spot at fedoraproject.org
Thu Dec 2 15:05:32 UTC 2010
commit b53dfda797336598a986d8975db1f612589e4915
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date: Thu Dec 2 10:05:40 2010 -0500
add fix for jemalloc
google-perftools-pprof-jemalloc-fix.patch | 68 +++++++++++++++++++++++++++++
google-perftools.spec | 8 +++-
2 files changed, 75 insertions(+), 1 deletions(-)
---
diff --git a/google-perftools-pprof-jemalloc-fix.patch b/google-perftools-pprof-jemalloc-fix.patch
new file mode 100644
index 0000000..6d822a1
--- /dev/null
+++ b/google-perftools-pprof-jemalloc-fix.patch
@@ -0,0 +1,68 @@
+--- src/pprof.orig 2010-01-19 23:45:49.000000000 +0100
++++ src/pprof 2010-11-25 00:26:29.000000000 +0100
+@@ -3039,16 +3039,18 @@
+ # The sampling frequency is the rate of a Poisson process.
+ # This means that the probability of sampling an allocation of
+ # size X with sampling rate Y is 1 - exp(-X/Y)
+- my $ratio;
+- $ratio = (($s1*1.0)/$n1)/($sample_adjustment);
+- my $scale_factor;
+- $scale_factor = 1/(1 - exp(-$ratio));
++ if ($n1 != 0) {
++ my $ratio = (($s1*1.0)/$n1)/($sample_adjustment);
++ my $scale_factor = 1/(1 - exp(-$ratio));
+ $n1 *= $scale_factor;
+ $s1 *= $scale_factor;
+- $ratio = (($s2*1.0)/$n2)/($sample_adjustment);
+- $scale_factor = 1/(1 - exp(-$ratio));
++ }
++ if ($n2 != 0) {
++ my $ratio = (($s2*1.0)/$n2)/($sample_adjustment);
++ my $scale_factor = 1/(1 - exp(-$ratio));
+ $n2 *= $scale_factor;
+ $s2 *= $scale_factor;
++ }
+ } else {
+ # Remote-heap version 1
+ my $ratio;
+@@ -3599,9 +3601,14 @@
+
+ my $symbols = {};
+
+- # Map each PC value to the containing library
+- my %seen = ();
+- foreach my $lib (@{$libs}) {
++ # Map each PC value to the containing library. To make this faster,
++ # we sort libraries by their starting pc value (highest first), and
++ # advance through the libraries as we advance the pc. Sometimes the
++ # addresses of libraries may overlap with the addresses of the main
++ # binary, so to make sure the libraries 'win', we iterate over the
++ # libraries in reverse order (binary will have the lowest start addr).
++ my @pcs = (sort { $a cmp $b } keys(%{$pcset}));
++ foreach my $lib (sort {$b->[1] cmp $a->[1]} @{$libs}) {
+ my $libname = $lib->[0];
+ my $start = $lib->[1];
+ my $finish = $lib->[2];
+@@ -3609,12 +3616,17 @@
+
+ # Get list of pcs that belong in this library.
+ my $contained = [];
+- foreach my $pc (keys(%{$pcset})) {
+- if (!$seen{$pc} && ($pc ge $start) && ($pc le $finish)) {
+- $seen{$pc} = 1;
+- push(@{$contained}, $pc);
+- }
++ my ($start_pc_index, $finish_pc_index);
++ for ($finish_pc_index = $#pcs + 1; $finish_pc_index > 0;
++ $finish_pc_index--) {
++ last if $pcs[$finish_pc_index - 1] le $finish;
++ }
++ for ($start_pc_index = $finish_pc_index; $start_pc_index > 0;
++ $start_pc_index--) {
++ last if $pcs[$start_pc_index - 1] lt $start;
+ }
++ @{$contained} = splice(@pcs, $start_pc_index,
++ $finish_pc_index - $start_pc_index);
+ # Map to symbols
+ MapToSymbols($libname, AddressSub($start, $offset), $contained, $symbols);
+ }
diff --git a/google-perftools.spec b/google-perftools.spec
index 45f6702..bdae0f9 100644
--- a/google-perftools.spec
+++ b/google-perftools.spec
@@ -1,11 +1,13 @@
Name: google-perftools
Version: 1.6
-Release: 1%{?dist}
+Release: 2%{?dist}
License: BSD
Group: Development/Tools
Summary: Very fast malloc and performance analysis tools
URL: http://code.google.com/p/google-perftools/
Source0: http://google-perftools.googlecode.com/files/google-perftools-%{version}.tar.gz
+# See https://bugzilla.redhat.com/show_bug.cgi?id=657118
+Patch0: google-perftools-pprof-jemalloc-fix.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# Still broken, bz 238390
ExcludeArch: ppc64
@@ -29,6 +31,7 @@ Libraries and headers for developing applications that use google-perftools.
%prep
%setup -q
+%patch0 -p0 -b .jemalloc
%build
CXXFLAGS=`echo $RPM_OPT_FLAGS -DTCMALLOC_LARGE_PAGES| sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//g'`
@@ -75,6 +78,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/*.so
%changelog
+* Thu Dec 2 2010 Tom "spot" Callaway <tcallawa at redhat.com> - 1.6-2
+- fix pprof to work properly with jemalloc (bz 657118)
+
* Fri Aug 6 2010 Tom "spot" Callaway <tcallawa at redhat.com> - 1.6-1
- update to 1.6
More information about the scm-commits
mailing list