perftools.rb 0.5.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # perftools.rb
2
2
 
3
- google-perftools for ruby code
4
- (c) 2010 Aman Gupta (tmm1)
3
+ gperftools for ruby code
4
+ (c) 2012 Aman Gupta (tmm1)
5
5
  http://www.ruby-lang.org/en/LICENSE.txt
6
6
 
7
+ gperftools (formerly known as google-perftools): http://gperftools.googlecode.com
8
+
7
9
  ## Usage (in a webapp)
8
10
 
9
11
  Use [rack-perftools_profiler](https://github.com/bhb/rack-perftools_profiler):
@@ -81,7 +83,7 @@ The sampling interval of the profiler can be adjusted to collect more
81
83
  pprof.rb --text --ignore=Gem /tmp/my_app_profile
82
84
 
83
85
 
84
- For more options, see [pprof documentation](http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html#pprof)
86
+ For more options, see [pprof documentation](http://gperftools.googlecode.com/svn/trunk/doc/cpuprofile.html#pprof)
85
87
 
86
88
 
87
89
  ### Examples
@@ -108,7 +110,7 @@ The sampling interval of the profiler can be adjusted to collect more
108
110
 
109
111
  ## Installation
110
112
 
111
- Just install the gem, which will download, patch and compile google-perftools for you:
113
+ Just install the gem, which will download, patch and compile gperftools for you:
112
114
 
113
115
  sudo gem install perftools.rb
114
116
 
@@ -119,12 +121,17 @@ The sampling interval of the profiler can be adjusted to collect more
119
121
  gem build perftools.rb.gemspec
120
122
  gem install perftools.rb
121
123
 
124
+ Use via a Gemfile:
125
+
126
+ gem 'perftools.rb', :git => 'git://github.com/tmm1/perftools.rb.git'
122
127
 
123
128
  You'll also need graphviz to generate call graphs using dot:
124
129
 
125
130
  sudo brew install graphviz ghostscript # osx
126
131
  sudo apt-get install graphviz ps2pdf # debian/ubuntu
127
132
 
133
+ 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)
134
+
128
135
  ## Advantages over ruby-prof
129
136
 
130
137
  * Sampling profiler
@@ -138,9 +145,9 @@ The sampling interval of the profiler can be adjusted to collect more
138
145
 
139
146
  Download:
140
147
 
141
- wget http://google-perftools.googlecode.com/files/google-perftools-1.6.tar.gz
142
- tar zxvf google-perftools-1.6.tar.gz
143
- cd google-perftools-1.6
148
+ wget http://gperftools.googlecode.com/files/gperftools-2.0.tar.gz
149
+ tar zxvf gperftools-2.0.tar.gz
150
+ cd gperftools-2.0
144
151
 
145
152
  Compile:
146
153
 
@@ -172,6 +179,6 @@ The sampling interval of the profiler can be adjusted to collect more
172
179
 
173
180
  * [Ilya Grigorik's introduction to perftools.rb](http://www.igvita.com/2009/06/13/profiling-ruby-with-googles-perftools/)
174
181
 
175
- * [Google Perftools](http://code.google.com/p/google-perftools/)
182
+ * [Google Perftools](http://code.google.com/p/gperftools/)
176
183
 
177
- * [Analyzing profiles and interpreting different output formats](http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html#pprof)
184
+ * [Analyzing profiles and interpreting different output formats](http://gperftools.googlecode.com/svn/trunk/doc/cpuprofile.html#pprof)
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rbconfig'
3
- cmd = "#{File.dirname(__FILE__)}/pprof #{Config::CONFIG['bindir']}/#{Config::CONFIG['ruby_install_name']} #{ARGV.join(" ")}"
4
- exec(cmd)
3
+ exec(File.join(File.dirname(__FILE__), 'pprof'), File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']), *ARGV)
@@ -3,7 +3,7 @@ CWD = File.expand_path(File.dirname(__FILE__))
3
3
  def sys(cmd)
4
4
  puts " -- #{cmd}"
5
5
  unless ret = xsystem(cmd)
6
- 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"
6
+ raise "#{cmd} failed, please report to https://github.com/tmm1/perfools.rb/issues/new with #{CWD}/src/mkmf.log and #{CWD}/src/gperftools-2.0/config.log"
7
7
  end
8
8
  ret
9
9
  end
@@ -27,7 +27,7 @@ if RUBY_VERSION >= "1.9"
27
27
  end
28
28
  end
29
29
 
30
- perftools = File.basename('google-perftools-1.6.tar.gz')
30
+ perftools = File.basename('gperftools-2.0.tar.gz')
31
31
  dir = File.basename(perftools, '.tar.gz')
32
32
 
33
33
  puts "(I'm about to compile google-perftools.. this will definitely take a while)"
@@ -36,7 +36,7 @@ ENV["PATCH_GET"] = '0'
36
36
  Dir.chdir('src') do
37
37
  FileUtils.rm_rf(dir) if File.exists?(dir)
38
38
 
39
- sys("tar zxvf #{perftools}")
39
+ sys("tar zpxvf #{perftools}")
40
40
  Dir.chdir(dir) do
41
41
  if ENV['DEV']
42
42
  sys("git init")
@@ -48,10 +48,11 @@ Dir.chdir('src') do
48
48
  ['perftools-notests', true],
49
49
  ['perftools-pprof', true],
50
50
  ['perftools-gc', true],
51
- ['perftools-osx', RUBY_PLATFORM =~ /darwin/],
51
+ ['perftools-osx', false], # fixed in 2.0
52
52
  ['perftools-debug', true],
53
53
  ['perftools-objects', true],
54
- ['perftools-frames', true]
54
+ ['perftools-frames', true],
55
+ ['perftools-realtime', true]
55
56
  ].each do |patch, apply|
56
57
  if apply
57
58
  sys("patch -p1 < ../../../patches/#{patch}.patch")
@@ -123,6 +123,11 @@ static VALUE Isend;
123
123
  #include <vm_core.h>
124
124
  #include <iseq.h>
125
125
 
126
+ // Fix compile error in ruby 1.9.3
127
+ #ifdef RTYPEDDATA_DATA
128
+ #define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))
129
+ #endif
130
+
126
131
  int
127
132
  rb_stack_trace(void** result, int max_depth)
128
133
  {
@@ -1,15 +1,33 @@
1
1
  diff --git a/Makefile.in b/Makefile.in
2
- index b301f4d..969db5e 100644
2
+ index be6bce7..423baba 100644
3
3
  --- a/Makefile.in
4
4
  +++ b/Makefile.in
5
- @@ -65,9 +65,7 @@ host_triplet = @host@
6
- @ENABLE_FRAME_POINTERS_TRUE@@X86_64_AND_NO_FP_BY_DEFAULT_TRUE@am__append_3 = -fno-omit-frame-pointer
7
- @ENABLE_FRAME_POINTERS_FALSE@@X86_64_AND_NO_FP_BY_DEFAULT_TRUE@am__append_4 = -DNO_FRAME_POINTER
8
- @MINGW_TRUE@am__append_5 = -Wl,-u__tcmalloc
5
+ @@ -66,26 +66,8 @@ host_triplet = @host@
6
+ @ENABLE_FRAME_POINTERS_TRUE@@X86_64_AND_NO_FP_BY_DEFAULT_TRUE@am__append_5 = -fno-omit-frame-pointer
7
+ @ENABLE_FRAME_POINTERS_FALSE@@X86_64_AND_NO_FP_BY_DEFAULT_TRUE@am__append_6 = -DNO_FRAME_POINTER
8
+ @MINGW_TRUE@am__append_7 = -Wl,-u__tcmalloc
9
+ -TESTS = low_level_alloc_unittest$(EXEEXT) atomicops_unittest$(EXEEXT) \
10
+ - $(am__EXEEXT_9) tcmalloc_minimal_unittest$(EXEEXT) \
11
+ - tcmalloc_minimal_large_unittest$(EXEEXT) $(am__append_17) \
12
+ - addressmap_unittest$(EXEEXT) $(am__EXEEXT_10) \
13
+ - packed_cache_test$(EXEEXT) frag_unittest$(EXEEXT) \
14
+ - markidle_unittest$(EXEEXT) \
15
+ - current_allocated_bytes_test$(EXEEXT) \
16
+ - malloc_hook_test$(EXEEXT) malloc_extension_test$(EXEEXT) \
17
+ - $(am__EXEEXT_11) $(am__EXEEXT_12) page_heap_test$(EXEEXT) \
18
+ - pagemap_unittest$(EXEEXT) realloc_unittest$(EXEEXT) \
19
+ - stack_trace_table_test$(EXEEXT) \
20
+ - thread_dealloc_unittest$(EXEEXT) $(am__EXEEXT_13) \
21
+ - $(am__EXEEXT_14) $(am__EXEEXT_15) $(am__append_29) \
22
+ - $(am__EXEEXT_16) $(am__EXEEXT_17) $(am__EXEEXT_18) \
23
+ - $(am__EXEEXT_19) $(am__append_49) $(am__EXEEXT_20) \
24
+ - $(am__append_58) $(am__append_60) $(am__EXEEXT_21) \
25
+ - $(am__EXEEXT_22)
9
26
  -noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
10
27
  - $(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \
11
28
  - $(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_23)
29
+ +TESTS =
12
30
  +noinst_PROGRAMS =
13
31
  bin_PROGRAMS =
14
- @MINGW_TRUE@am__append_6 = libwindows.la libspinlock.la
32
+ @MINGW_TRUE@am__append_8 = libwindows.la libspinlock.la
15
33
 
@@ -1,53 +1,60 @@
1
+ commit 7a33a39f5b31e41f87a47bcadff818208fcc6c05
2
+ Author: Aman Gupta <aman@tmm1.net>
3
+ Date: Wed Mar 7 22:55:33 2012 -0800
4
+
5
+ perftools-objects
6
+
1
7
  diff --git a/src/profile-handler.cc b/src/profile-handler.cc
2
- index 5df5054..2335617 100644
8
+ index f9d8d8b..91f6f72 100644
3
9
  --- a/src/profile-handler.cc
4
10
  +++ b/src/profile-handler.cc
5
- @@ -395,6 +395,8 @@ void ProfileHandler::GetState(ProfileHandlerState* state) {
6
- }
7
-
8
- void ProfileHandler::StartTimer() {
11
+ @@ -426,6 +426,8 @@ void ProfileHandler::StartTimer() {
12
+ if (!allowed_) {
13
+ return;
14
+ }
9
15
  + if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return;
10
16
  +
11
17
  struct itimerval timer;
12
18
  timer.it_interval.tv_sec = 0;
13
19
  timer.it_interval.tv_usec = 1000000 / frequency_;
14
- @@ -403,12 +405,16 @@ void ProfileHandler::StartTimer() {
15
- }
16
-
17
- void ProfileHandler::StopTimer() {
20
+ @@ -437,6 +439,8 @@ void ProfileHandler::StopTimer() {
21
+ if (!allowed_) {
22
+ return;
23
+ }
18
24
  + if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return;
19
25
  +
20
26
  struct itimerval timer;
21
27
  memset(&timer, 0, sizeof timer);
22
28
  setitimer(timer_type_, &timer, 0);
23
- }
24
-
25
- bool ProfileHandler::IsTimerRunning() {
29
+ @@ -446,6 +450,8 @@ bool ProfileHandler::IsTimerRunning() {
30
+ if (!allowed_) {
31
+ return false;
32
+ }
26
33
  + if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return false;
27
34
  +
28
35
  struct itimerval current_timer;
29
36
  RAW_CHECK(0 == getitimer(timer_type_, &current_timer), "getitimer");
30
37
  return (current_timer.it_value.tv_sec != 0 ||
31
- @@ -416,6 +422,8 @@ bool ProfileHandler::IsTimerRunning() {
32
- }
33
-
34
- void ProfileHandler::EnableHandler() {
38
+ @@ -456,6 +462,8 @@ void ProfileHandler::EnableHandler() {
39
+ if (!allowed_) {
40
+ return;
41
+ }
35
42
  + if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return;
36
43
  +
37
44
  struct sigaction sa;
38
45
  sa.sa_sigaction = SignalHandler;
39
46
  sa.sa_flags = SA_RESTART | SA_SIGINFO;
40
- @@ -425,6 +433,8 @@ void ProfileHandler::EnableHandler() {
41
- }
42
-
43
- void ProfileHandler::DisableHandler() {
47
+ @@ -468,6 +476,8 @@ void ProfileHandler::DisableHandler() {
48
+ if (!allowed_) {
49
+ return;
50
+ }
44
51
  + if (getenv("CPUPROFILE_OBJECTS") || getenv("CPUPROFILE_METHODS")) return;
45
52
  +
46
53
  struct sigaction sa;
47
54
  sa.sa_handler = SIG_IGN;
48
55
  sa.sa_flags = SA_RESTART;
49
56
  diff --git a/src/profiler.cc b/src/profiler.cc
50
- index f408cf8..7645c45 100644
57
+ index 6538299..8e92b91 100644
51
58
  --- a/src/profiler.cc
52
59
  +++ b/src/profiler.cc
53
60
  @@ -102,6 +102,10 @@ class CpuProfiler {
@@ -0,0 +1,22 @@
1
+ commit 2c428e120733fdbf4ae2399046d9d63e6845b18d
2
+ Author: Aman Gupta <aman@tmm1.net>
3
+ Date: Thu Mar 8 22:39:12 2012 -0800
4
+
5
+ perftools-realtime
6
+
7
+ diff --git a/src/profile-handler.cc b/src/profile-handler.cc
8
+ index dfc8cf4..567ca45 100644
9
+ --- a/src/profile-handler.cc
10
+ +++ b/src/profile-handler.cc
11
+ @@ -491,6 +491,11 @@ bool ProfileHandler::IsSignalHandlerAvailable() {
12
+ const int signal_number = (timer_type_ == ITIMER_PROF ? SIGPROF : SIGALRM);
13
+ RAW_CHECK(sigaction(signal_number, NULL, &sa) == 0, "is-signal-handler avail");
14
+
15
+ +#ifdef BUILD_FOR_RUBY
16
+ + // Inside ruby, there's a default signal handler set for SIGALRM.
17
+ + return true;
18
+ +#endif
19
+ +
20
+ // We only take over the handler if the current one is unset.
21
+ // It must be SIG_IGN or SIG_DFL, not some other function.
22
+ // SIG_IGN must be allowed because when profiling is allowed but
@@ -1,7 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'perftools.rb'
3
- s.version = '0.5.6'
4
- s.date = '2011-01-23'
3
+ s.version = '2.0.0'
5
4
  s.rubyforge_project = 'perftools-rb'
6
5
  s.summary = 'google-perftools for ruby code'
7
6
  s.description = 'A sampling profiler for ruby code based on patches to google-perftools'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perftools.rb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
+ - 2
7
8
  - 0
8
- - 5
9
- - 6
10
- version: 0.5.6
9
+ - 0
10
+ version: 2.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aman Gupta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-23 00:00:00 -08:00
18
+ date: 2012-03-17 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -32,7 +32,7 @@ files:
32
32
  - bin/pprof.rb
33
33
  - ext/extconf.rb
34
34
  - ext/perftools.c
35
- - ext/src/google-perftools-1.6.tar.gz
35
+ - ext/src/gperftools-2.0.tar.gz
36
36
  - patches/perftools-debug.patch
37
37
  - patches/perftools-frames.patch
38
38
  - patches/perftools-gc.patch
@@ -40,6 +40,7 @@ files:
40
40
  - patches/perftools-objects.patch
41
41
  - patches/perftools-osx.patch
42
42
  - patches/perftools-pprof.patch
43
+ - patches/perftools-realtime.patch
43
44
  - patches/perftools.patch
44
45
  - perftools.rb.gemspec
45
46
  has_rdoc: false
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
73
  requirements: []
73
74
 
74
75
  rubyforge_project: perftools-rb
75
- rubygems_version: 1.4.2
76
+ rubygems_version: 1.6.2
76
77
  signing_key:
77
78
  specification_version: 3
78
79
  summary: google-perftools for ruby code