perftools.rb 0.3.2 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/ext/extconf.rb CHANGED
@@ -33,13 +33,25 @@ Dir.chdir('src') do
33
33
 
34
34
  sys("tar zxvf #{perftools}")
35
35
  Dir.chdir(dir) do
36
- sys("patch -p1 < ../../../patches/perftools.patch")
37
- sys("patch -p1 < ../../../patches/perftools-notests.patch")
38
- sys("patch -p1 < ../../../patches/perftools-pprof.patch")
39
- sys("patch -p1 < ../../../patches/perftools-gc.patch")
40
- sys("patch -p1 < ../../../patches/perftools-osx.patch") if RUBY_PLATFORM =~ /darwin/
41
- sys("patch -p1 < ../../../patches/perftools-osx-106.patch") if RUBY_PLATFORM =~ /darwin10/
42
- sys("patch -p1 < ../../../patches/perftools-debug.patch")
36
+ if ENV['DEV']
37
+ sys("git init")
38
+ sys("git add .")
39
+ sys("git commit -m 'initial source'")
40
+ end
41
+
42
+ [ ['perftools', true],
43
+ ['perftools-notests', true],
44
+ ['perftools-pprof', true],
45
+ ['perftools-gc', true],
46
+ ['perftools-osx', RUBY_PLATFORM =~ /darwin/],
47
+ ['perftools-osx-106', RUBY_PLATFORM =~ /darwin10/],
48
+ ['perftools-debug', true]
49
+ ].each do |patch, apply|
50
+ if apply
51
+ sys("patch -p1 < ../../../patches/#{patch}.patch")
52
+ sys("git commit -am '#{patch}'") if ENV['DEV']
53
+ end
54
+ end
43
55
  end
44
56
 
45
57
  Dir.chdir(dir) do
@@ -77,7 +89,6 @@ if RUBY_VERSION >= "1.9"
77
89
  have_header("insns.inc") and
78
90
  have_header("insns_info.inc")
79
91
  }
80
- have_func('rb_during_gc', 'ruby.h')
81
92
 
82
93
  unless Ruby_core_source::create_makefile_with_core(hdrs, "perftools")
83
94
  STDERR.puts "\n\n"
data/ext/perftools.c CHANGED
@@ -1,10 +1,11 @@
1
+ #include <assert.h>
1
2
  #include <ruby.h>
2
3
  static VALUE Iallocate;
3
4
  static VALUE I__send__;
4
5
 
5
6
  #define SAVE_FRAME() \
6
- if (method != I__send__) { \
7
- if (FL_TEST(klass, FL_SINGLETON) && (BUILTIN_TYPE(self) == T_CLASS || BUILTIN_TYPE(self) == T_MODULE)) \
7
+ if (method && method != I__send__) { \
8
+ if (self && FL_TEST(klass, FL_SINGLETON) && (BUILTIN_TYPE(self) == T_CLASS || BUILTIN_TYPE(self) == T_MODULE)) \
8
9
  result[depth++] = (void*) self; \
9
10
  else \
10
11
  result[depth++] = 0; \
@@ -68,6 +69,7 @@ static VALUE I__send__;
68
69
  }
69
70
  }
70
71
 
72
+ assert(depth <= max_depth);
71
73
  return depth;
72
74
  }
73
75
  #endif
@@ -90,24 +92,25 @@ static VALUE I__send__;
90
92
  if (max_depth == 0)
91
93
  return 0;
92
94
 
93
- #ifdef HAVE_RB_DURING_GC
94
95
  if (rb_during_gc()) {
95
96
  result[0] = rb_gc;
96
97
  return 1;
97
98
  }
98
- #endif
99
99
 
100
- while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp) && depth+3 < max_depth) {
100
+ while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp) && depth+3 <= max_depth) {
101
101
  rb_iseq_t *iseq = cfp->iseq;
102
102
 
103
103
  if (iseq && iseq->type == ISEQ_TYPE_METHOD) {
104
- self = iseq->self;
104
+ self = 0; // maybe use cfp->self here, but iseq->self is a ISeq ruby obj
105
105
  klass = iseq->klass;
106
106
  method = iseq->defined_method_id;
107
107
  SAVE_FRAME();
108
108
  }
109
109
 
110
- switch(VM_FRAME_TYPE(cfp)) {
110
+ if (depth+3 > max_depth)
111
+ break;
112
+
113
+ switch (VM_FRAME_TYPE(cfp)) {
111
114
  case VM_FRAME_MAGIC_METHOD:
112
115
  case VM_FRAME_MAGIC_CFUNC:
113
116
  self = cfp->self;
@@ -120,6 +123,7 @@ static VALUE I__send__;
120
123
  cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
121
124
  }
122
125
 
126
+ assert(depth <= max_depth);
123
127
  return depth;
124
128
  }
125
129
 
@@ -122,7 +122,7 @@ index 5f2531b..e6240d9 100644
122
122
  start_time_ = time(NULL);
123
123
  fname_ = strdup(fname);
124
124
 
125
- @@ -166,16 +203,47 @@ void ProfileData::Stop() {
125
+ @@ -166,16 +203,52 @@ void ProfileData::Stop() {
126
126
  return;
127
127
  }
128
128
 
@@ -143,22 +143,27 @@ index 5f2531b..e6240d9 100644
143
143
  + Entry e = bucket->entry[a];
144
144
  + Evict(e);
145
145
  +#ifdef BUILD_FOR_RUBY
146
- + if (e.depth > 1)
146
+ + if (e.depth > 1) {
147
147
  + for (int n=0; n<e.depth; n+=3) {
148
- + ID sym = e.stack[n] + e.stack[n+1] + e.stack[n+2];
148
+ + VALUE self = e.stack[n];
149
+ + VALUE klass = e.stack[n+1];
150
+ + ID method = e.stack[n+2];
151
+ +
152
+ + ID sym = self + klass + method; // unique identifer
149
153
  +
150
154
  + if (known_symbols.find(sym) == known_symbols.end()) {
151
155
  + fprintf(symbols, "%0*lx: ", sizeof(unsigned long)*2, sym);
152
156
  +
153
- + if (e.stack[n])
154
- + fprintf(symbols, "%s.", rb_class2name(e.stack[n]));
155
- + else
156
- + fprintf(symbols, "%s#", rb_class2name(e.stack[n+1]));
157
+ + if (self) { // class method
158
+ + fprintf(symbols, "%s.%s\n", rb_class2name(self), rb_id2name(method));
159
+ + } else { // instance method
160
+ + fprintf(symbols, "%s#%s\n", rb_class2name(klass), rb_id2name(method));
161
+ + }
157
162
  +
158
- + fprintf(symbols, "%s\n", rb_id2name(e.stack[n+2]));
159
163
  + known_symbols.insert(sym);
160
164
  + }
161
165
  + }
166
+ + }
162
167
  +#endif
163
168
  }
164
169
  }
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.2'
4
- s.date = '2009-10-10'
3
+ s.version = '0.3.5'
4
+ s.date = '2009-10-13'
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.2
4
+ version: 0.3.5
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-10-10 00:00:00 -07:00
12
+ date: 2009-10-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  requirements: []
60
60
 
61
61
  rubyforge_project: perftools-rb
62
- rubygems_version: 1.3.4
62
+ rubygems_version: 1.3.5
63
63
  signing_key:
64
64
  specification_version: 3
65
65
  summary: google-perftools for ruby code