perftools.rb 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/ext/extconf.rb CHANGED
@@ -53,6 +53,9 @@ Dir.chdir('src') do
53
53
  sys("git commit -am '#{patch}'") if ENV['DEV']
54
54
  end
55
55
  end
56
+
57
+ sys("sed -i -e 's,SpinLock,ISpinLock,g' src/*.{cc,h} src/base/*.{cc,h}")
58
+ sys("git commit -am 'rename spinlock'") if ENV['DEV']
56
59
  end
57
60
 
58
61
  Dir.chdir(dir) do
data/ext/perftools.c CHANGED
@@ -1,10 +1,17 @@
1
1
  #include <assert.h>
2
2
  #include <ruby.h>
3
+
4
+ void ProfilerGcMark(void (*cb)(VALUE));
5
+ int ProfilerStart(const char*);
6
+ void ProfilerStop();
7
+ void ProfilerFlush();
8
+
3
9
  static VALUE Iallocate;
4
10
  static VALUE I__send__;
11
+ static VALUE Isend;
5
12
 
6
13
  #define SAVE_FRAME() \
7
- if (method && method != I__send__) { \
14
+ if (method && method != I__send__ && !(method == Isend && klass == rb_cObject)) { \
8
15
  if (self && FL_TEST(klass, FL_SINGLETON) && (BUILTIN_TYPE(self) == T_CLASS || BUILTIN_TYPE(self) == T_MODULE)) \
9
16
  result[depth++] = (void*) self; \
10
17
  else \
@@ -15,8 +22,20 @@ static VALUE I__send__;
15
22
  }
16
23
 
17
24
  #ifdef RUBY18
18
- #include <node.h>
19
25
  #include <env.h>
26
+ #include <node.h>
27
+ #include <setjmp.h>
28
+ #include <signal.h>
29
+
30
+ static jmp_buf saved_location;
31
+ static sig_t saved_handler = NULL;
32
+
33
+ void
34
+ segv_handler(int sig)
35
+ {
36
+ assert(saved_handler);
37
+ _longjmp(saved_location, 1);
38
+ }
20
39
 
21
40
  int
22
41
  rb_stack_trace(void** result, int max_depth)
@@ -38,6 +57,17 @@ static VALUE I__send__;
38
57
  }
39
58
  #endif
40
59
 
60
+ // should not be possible to get here and already have a saved signal handler
61
+ assert(!saved_handler);
62
+
63
+ // ruby_frame is occasionally inconsistent, so temporarily catch segfaults
64
+ saved_handler = signal(SIGSEGV, segv_handler);
65
+ if (_setjmp(saved_location)) {
66
+ signal(SIGSEGV, saved_handler);
67
+ saved_handler = NULL;
68
+ return 0;
69
+ }
70
+
41
71
  /*
42
72
  // XXX does it make sense to track allocations or not?
43
73
  if (frame->last_func == ID_ALLOCATOR) {
@@ -54,7 +84,7 @@ static VALUE I__send__;
54
84
  */
55
85
 
56
86
  for (; frame && (n = frame->node); frame = frame->prev) {
57
- if (frame->prev > 0xff && frame->prev->last_func) {
87
+ if (frame->prev && frame->prev->last_func) {
58
88
  if (frame->prev->node == n) {
59
89
  if (frame->prev->last_func == frame->last_func) continue;
60
90
  }
@@ -69,14 +99,17 @@ static VALUE I__send__;
69
99
  }
70
100
  }
71
101
 
102
+ signal(SIGSEGV, saved_handler);
103
+ saved_handler = NULL;
104
+
72
105
  assert(depth <= max_depth);
73
106
  return depth;
74
107
  }
75
108
  #endif
76
109
 
77
110
  #ifdef RUBY19
78
- #include <vm_core.h>
79
111
  #include <iseq.h>
112
+ #include <vm_core.h>
80
113
 
81
114
  int
82
115
  rb_stack_trace(void** result, int max_depth)
@@ -216,6 +249,7 @@ Init_perftools()
216
249
  bProfilerRunning = Qfalse;
217
250
  Iallocate = rb_intern("allocate");
218
251
  I__send__ = rb_intern("__send__");
252
+ Isend = rb_intern("send");
219
253
 
220
254
  rb_define_singleton_method(cCpuProfiler, "running?", cpuprofiler_running_p, 0);
221
255
  rb_define_singleton_method(cCpuProfiler, "start", cpuprofiler_start, 1);
data/perftools.rb.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'perftools.rb'
3
- s.version = '0.3.7'
4
- s.date = '2009-11-03'
3
+ s.version = '0.3.8'
4
+ s.date = '2009-11-11'
5
5
  s.rubyforge_project = 'perftools-rb'
6
6
  s.summary = 'google-perftools for ruby code'
7
7
  s.description = 'A sampling profiler for ruby code based on patches to google-perftools'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perftools.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-03 00:00:00 -08:00
12
+ date: 2009-11-11 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15