Permalink
Browse files

Migrate to perftools 1.8.3

* use RbConfig::CONFIG instead of Config::CONFIG
* Fixed error 'Symbol not found: _ruby_current_thread (LoadError)' for ruby-1.9.3
* Added examples of reporting add_numbers_profile in ruby '1.8.6', '1.8.7', '1.9.1', '1.9.2', '1.9.3'
  • Loading branch information...
bearded
bearded committed Oct 6, 2011
1 parent f4139fc commit df73f93e4dda8953e77ba3be2945f4bf806b07cf
View
@@ -123,7 +123,7 @@ The sampling interval of the profiler can be adjusted to collect more
You'll also need graphviz to generate call graphs using dot:
sudo brew install graphviz ghostscript # osx
- sudo apt-get install graphviz ps2pdf # debian/ubuntu
+ sudo apt-get install graphviz ghostscript # debian/ubuntu
If graphviz fails to build on OSX Lion, you may need to recompile libgd, [see here](https://github.com/mxcl/homebrew/issues/6645#issuecomment-1806807)
@@ -140,9 +140,9 @@ The sampling interval of the profiler can be adjusted to collect more
Download:
- wget http://google-perftools.googlecode.com/files/google-perftools-1.6.tar.gz
- tar zxvf google-perftools-1.6.tar.gz
- cd google-perftools-1.6
+ wget http://google-perftools.googlecode.com/files/google-perftools-1.8.3.tar.gz
+ tar zxvf google-perftools-1.8.3.tar.gz
+ cd google-perftools-1.8.3
Compile:
View
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
require 'rbconfig'
-exec(File.join(File.dirname(__FILE__), 'pprof'), File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']), *ARGV)
+exec(File.join(File.dirname(__FILE__), 'pprof'), File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']), *ARGV)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
@@ -3,7 +3,7 @@
def sys(cmd)
puts " -- #{cmd}"
unless ret = xsystem(cmd)
- raise "#{cmd} failed, please report to perftools@tmm1.net with pastie.org link to #{CWD}/mkmf.log and #{CWD}/src/google-perftools-1.6/config.log"
+ raise "#{cmd} failed, please report to perftools@tmm1.net with pastie.org link to #{CWD}/mkmf.log and #{CWD}/src/google-perftools-1.8.3/config.log"
end
ret
end
@@ -27,7 +27,7 @@ def sys(cmd)
end
end
-perftools = File.basename('google-perftools-1.6.tar.gz')
+perftools = File.basename('google-perftools-1.8.3.tar.gz')
dir = File.basename(perftools, '.tar.gz')
puts "(I'm about to compile google-perftools.. this will definitely take a while)"
View
@@ -123,6 +123,11 @@ static VALUE Isend;
#include <vm_core.h>
#include <iseq.h>
+// Fix compile error in ruby 1.9.3
+#ifdef RTYPEDDATA_DATA
+#define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))
+#endif
+
int
rb_stack_trace(void** result, int max_depth)
{
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,8 @@
diff --git a/Makefile.in b/Makefile.in
-index c3bf409..c613939 100644
+index 153483e..d38bee1 100644
--- a/Makefile.in
+++ b/Makefile.in
-@@ -1367,13 +1367,13 @@ AUTOMAKE = @AUTOMAKE@
+@@ -1509,13 +1509,13 @@ AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
@@ -1,5 +1,5 @@
diff --git a/src/profiledata.h b/src/profiledata.h
-index ccdf96f..0517614 100644
+index 1b3eb2e..0d81603 100644
--- a/src/profiledata.h
+++ b/src/profiledata.h
@@ -106,7 +106,7 @@ class ProfileData {
View
@@ -1,5 +1,5 @@
diff --git a/src/profiledata.cc b/src/profiledata.cc
-index e6240d9..b901ee8 100644
+index ea95493..582ec9a 100644
--- a/src/profiledata.cc
+++ b/src/profiledata.cc
@@ -198,6 +198,29 @@ static void DumpProcSelfMaps(int fd) {
@@ -33,7 +33,7 @@ index e6240d9..b901ee8 100644
if (!enabled()) {
return;
diff --git a/src/profiledata.h b/src/profiledata.h
-index 67c463d..a68e12f 100644
+index 2f013e6..1b3eb2e 100644
--- a/src/profiledata.h
+++ b/src/profiledata.h
@@ -40,6 +40,12 @@
@@ -61,10 +61,10 @@ index 67c463d..a68e12f 100644
static const int kAssociativity = 4; // For hashtable
static const int kBuckets = 1 << 10; // For hashtable
diff --git a/src/profiler.cc b/src/profiler.cc
-index d89a53a..37234b2 100644
+index b38602a..3363428 100644
--- a/src/profiler.cc
+++ b/src/profiler.cc
-@@ -87,6 +87,10 @@ class CpuProfiler {
+@@ -92,6 +92,10 @@ class CpuProfiler {
// Write the data to disk (and continue profiling).
void FlushTable();
@@ -75,7 +75,7 @@ index d89a53a..37234b2 100644
bool Enabled();
void GetCurrentState(ProfilerState* state);
-@@ -221,6 +225,16 @@ void CpuProfiler::FlushTable() {
+@@ -226,6 +230,16 @@ void CpuProfiler::FlushTable() {
EnableHandler();
}
@@ -92,7 +92,7 @@ index d89a53a..37234b2 100644
bool CpuProfiler::Enabled() {
SpinLockHolder cl(&lock_);
return collector_.enabled();
-@@ -300,6 +314,12 @@ extern "C" PERFTOOLS_DLL_DECL void ProfilerFlush() {
+@@ -306,6 +320,12 @@ extern "C" PERFTOOLS_DLL_DECL void ProfilerFlush() {
CpuProfiler::instance_.FlushTable();
}
@@ -2,14 +2,14 @@ diff --git a/Makefile.in b/Makefile.in
index b301f4d..969db5e 100644
--- a/Makefile.in
+++ b/Makefile.in
-@@ -65,9 +65,7 @@ host_triplet = @host@
- @ENABLE_FRAME_POINTERS_TRUE@@X86_64_AND_NO_FP_BY_DEFAULT_TRUE@am__append_3 = -fno-omit-frame-pointer
- @ENABLE_FRAME_POINTERS_FALSE@@X86_64_AND_NO_FP_BY_DEFAULT_TRUE@am__append_4 = -DNO_FRAME_POINTER
- @MINGW_TRUE@am__append_5 = -Wl,-u__tcmalloc
+@@ -67,9 +67,7 @@
+ @ENABLE_FRAME_POINTERS_TRUE@@X86_64_AND_NO_FP_BY_DEFAULT_TRUE@am__append_4 = -fno-omit-frame-pointer
+ @ENABLE_FRAME_POINTERS_FALSE@@X86_64_AND_NO_FP_BY_DEFAULT_TRUE@am__append_5 = -DNO_FRAME_POINTER
+ @MINGW_TRUE@am__append_6 = -Wl,-u__tcmalloc
-noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
- $(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \
-- $(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_23)
-+noinst_PROGRAMS =
+- $(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_28)
++noinst_PROGRAMS =
bin_PROGRAMS =
- @MINGW_TRUE@am__append_6 = libwindows.la libspinlock.la
+ @MINGW_TRUE@am__append_7 = libwindows.la libspinlock.la
@@ -1,5 +1,5 @@
diff --git a/src/profile-handler.cc b/src/profile-handler.cc
-index 5df5054..2335617 100644
+index dfc2e38..d3bfb42 100644
--- a/src/profile-handler.cc
+++ b/src/profile-handler.cc
@@ -395,6 +395,8 @@ void ProfileHandler::GetState(ProfileHandlerState* state) {
@@ -47,7 +47,7 @@ index 5df5054..2335617 100644
sa.sa_handler = SIG_IGN;
sa.sa_flags = SA_RESTART;
diff --git a/src/profiler.cc b/src/profiler.cc
-index f408cf8..7645c45 100644
+index 3363428..0043513 100644
--- a/src/profiler.cc
+++ b/src/profiler.cc
@@ -102,6 +102,10 @@ class CpuProfiler {
@@ -72,7 +72,7 @@ index f408cf8..7645c45 100644
};
// Profile data structure singleton: Constructor will check to see if
-@@ -323,6 +323,10 @@ extern "C" PERFTOOLS_DLL_DECL void ProfilerFlush() {
+@@ -324,6 +324,10 @@ extern "C" PERFTOOLS_DLL_DECL void ProfilerFlush() {
extern "C" PERFTOOLS_DLL_DECL void ProfilerGcMark(void (*cb)(VALUE)) {
CpuProfiler::instance_.GcMark(cb);
}
@@ -1,11 +1,11 @@
diff --git a/Makefile.in b/Makefile.in
-index 566d77c..c3bf409 100644
+index 153483e..fe68999 100644
--- a/Makefile.in
+++ b/Makefile.in
-@@ -1397,7 +1397,7 @@ INSTALL_DATA = @INSTALL_DATA@
- INSTALL_PROGRAM = @INSTALL_PROGRAM@
+@@ -1543,7 +1543,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+ LD = @LD@
-LDFLAGS = @LDFLAGS@
+LDFLAGS = @LDFLAGS@ -Wl,-flat_namespace,-undefined,dynamic_lookup
LIBOBJS = @LIBOBJS@
@@ -1,14 +1,8 @@
-commit 1828f461a3ea523b7018d03ab83850621cf66ba9
-Author: Aman Gupta <aman@tmm1.net>
-Date: Fri Nov 12 16:33:15 2010 -0600
-
- perftools-pprof
-
diff --git a/src/pprof b/src/pprof
-index e67e42e..b04d988 100755
+index dbe71a4..e300f22 100755
--- a/src/pprof
+++ b/src/pprof
-@@ -560,7 +560,8 @@ sub Main() {
+@@ -575,7 +575,8 @@ sub Main() {
my $symbol_map = {};
# Read one profile, pick the last item on the list
@@ -18,7 +12,7 @@ index e67e42e..b04d988 100755
my $profile = $data->{profile};
my $pcs = $data->{pcs};
my $libs = $data->{libs}; # Info about main program and shared libraries
-@@ -589,7 +590,18 @@ sub Main() {
+@@ -604,7 +605,18 @@ sub Main() {
# Collect symbols
my $symbols;
@@ -38,7 +32,7 @@ index e67e42e..b04d988 100755
$symbols = FetchSymbols($pcs, $symbol_map);
} elsif ($main::use_symbol_page) {
$symbols = FetchSymbols($pcs);
-@@ -2425,6 +2437,10 @@ sub RemoveUninterestingFrames {
+@@ -2790,6 +2802,10 @@ sub RemoveUninterestingFrames {
foreach my $name ('ProfileData::Add', # historical
'ProfileData::prof_handler', # historical
'CpuProfiler::prof_handler',
@@ -49,23 +43,23 @@ index e67e42e..b04d988 100755
'__FRAME_END__',
'__pthread_sighandler',
'__restore') {
-@@ -2434,6 +2450,7 @@ sub RemoveUninterestingFrames {
+@@ -2799,6 +2815,7 @@ sub RemoveUninterestingFrames {
# Nothing skipped for unknown types
}
+=pod
if ($main::profile_type eq 'cpu') {
# If all the second-youngest program counters are the same,
# this STRONGLY suggests that it is an artifact of measurement,
-@@ -2458,6 +2475,7 @@ sub RemoveUninterestingFrames {
+@@ -2823,6 +2840,7 @@ sub RemoveUninterestingFrames {
$profile = $result;
}
}
+=cut
my $result = {};
foreach my $k (keys(%{$profile})) {
-@@ -3360,7 +3378,7 @@ sub ReadCPUProfile {
+@@ -3749,7 +3767,7 @@ sub ReadCPUProfile {
# file, in which case the subtract-one was done when the file
# was written.
if ($j > 0 && !$main::use_symbolized_profile) {
View
@@ -1,8 +1,8 @@
diff --git a/Makefile.in b/Makefile.in
-index 232d2ec..566d77c 100644
+index f3aa67e..5b73c77 100644
--- a/Makefile.in
+++ b/Makefile.in
-@@ -1367,13 +1367,13 @@ AUTOMAKE = @AUTOMAKE@
+@@ -1511,13 +1511,13 @@ AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
@@ -19,10 +19,10 @@ index 232d2ec..566d77c 100644
DEFS = @DEFS@
DEPDIR = @DEPDIR@
diff --git a/src/profile-handler.cc b/src/profile-handler.cc
-index e658d30..370d012 100644
+index 700b5c0..dfc2e38 100644
--- a/src/profile-handler.cc
+++ b/src/profile-handler.cc
-@@ -264,6 +264,11 @@ ProfileHandler::~ProfileHandler() {
+@@ -267,6 +267,11 @@ ProfileHandler::~ProfileHandler() {
void ProfileHandler::RegisterThread() {
SpinLockHolder cl(&control_lock_);
@@ -34,7 +34,7 @@ index e658d30..370d012 100644
// We try to detect whether timers are being shared by setting a
// timer in the first call to this function, then checking whether
// it's set in the second call.
-@@ -305,6 +310,7 @@ void ProfileHandler::RegisterThread() {
+@@ -308,6 +313,7 @@ void ProfileHandler::RegisterThread() {
StartTimer();
break;
}
@@ -197,7 +197,7 @@ index 5f2531b..ea95493 100644
out_ = -1;
diff --git a/src/profiledata.h b/src/profiledata.h
-index da7ea9e..67c463d 100644
+index 3521bac..2f013e6 100644
--- a/src/profiledata.h
+++ b/src/profiledata.h
@@ -169,6 +169,7 @@ class ProfileData {
@@ -209,10 +209,10 @@ index da7ea9e..67c463d 100644
// Move 'entry' to the eviction buffer.
diff --git a/src/profiler.cc b/src/profiler.cc
-index 183a7c7..d89a53a 100644
+index a57953e..b38602a 100644
--- a/src/profiler.cc
+++ b/src/profiler.cc
-@@ -63,6 +63,12 @@ typedef int ucontext_t; // just to quiet the compiler, mostly
+@@ -68,6 +68,12 @@ typedef int ucontext_t; // just to quiet the compiler, mostly
#include "conflict-signal.h" /* used on msvc machines */
#endif
@@ -225,17 +225,18 @@ index 183a7c7..d89a53a 100644
using std::string;
// Collects up all profile data. This is a singleton, which is
-@@ -261,6 +267,9 @@ void CpuProfiler::prof_handler(int sig, siginfo_t*, void* signal_ucontext,
+@@ -266,6 +272,10 @@ void CpuProfiler::prof_handler(int sig, siginfo_t*, void* signal_ucontext,
(*instance->filter_)(instance->filter_arg_)) {
void* stack[ProfileData::kMaxStackDepth];
+#ifdef BUILD_FOR_RUBY
+ int depth = rb_stack_trace(stack, arraysize(stack));
+#else
++
// The top-most active routine doesn't show up as a normal
// frame, but as the "pc" value in the signal handler context.
stack[0] = GetPC(*reinterpret_cast<ucontext_t*>(signal_ucontext));
-@@ -274,8 +283,10 @@ void CpuProfiler::prof_handler(int sig, siginfo_t*, void* signal_ucontext,
+@@ -279,8 +289,10 @@ void CpuProfiler::prof_handler(int sig, siginfo_t*, void* signal_ucontext,
int depth = GetStackTraceWithContext(stack + 1, arraysize(stack) - 1,
2, signal_ucontext);
depth++; // To account for pc value in stack[0];
@@ -248,7 +249,7 @@ index 183a7c7..d89a53a 100644
}
diff --git a/src/stacktrace.cc b/src/stacktrace.cc
-index d158eea..e8509fe 100644
+index 175cdf5..18b4a79 100644
--- a/src/stacktrace.cc
+++ b/src/stacktrace.cc
@@ -52,6 +52,7 @@
@@ -259,7 +260,7 @@ index d158eea..e8509fe 100644
#include <config.h>
#include <google/stacktrace.h>
#include "stacktrace_config.h"
-@@ -69,3 +70,4 @@
+@@ -108,3 +109,4 @@
#else
# error Cannot calculate stack trace: will need to write for your environment
#endif

0 comments on commit df73f93

Please sign in to comment.