bleak_house 5.2 → 5.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  BleakHouse Changelog
3
3
 
4
+ 5.3. subtract rails core counts from action counts and convolve
4
5
  5.2. change smoothing algorithm to be more intuitive and so mem usage is correct
5
6
  5.1. close file properly
6
7
  5. totally awesome C instrumentation
data/README CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  BleakHouse
3
3
 
4
- REQUIREMENTS:
4
+ REQUIREMENTS
5
5
 
6
6
  A *nix operating system. Windows is not supported.
7
7
 
@@ -11,7 +11,7 @@ It is highly recommended that you compile the bleak_house patched
11
11
  Ruby build. In the plugin directory:
12
12
  rake ruby:build
13
13
 
14
- USAGE:
14
+ USAGE
15
15
 
16
16
  To profile your application:
17
17
  RAILS_ENV=production BLEAK_HOUSE=true ruby-bleak-house ./script/server
@@ -20,20 +20,20 @@ Browse around manually, thrash your entire app with a script,
20
20
  target troublesome controllers/actions, etc.
21
21
 
22
22
  Then, to analyze:
23
- RAILS_ENV=production SMOOTHNESS=2 rake bleak_house:analyze
23
+ RAILS_ENV=production SMOOTHNESS=1 rake bleak_house:analyze
24
24
 
25
25
  And then look in log/bleak_house/.
26
26
 
27
27
  TROUBLESHOOTING
28
28
 
29
29
  If you see the error "Symbol not found: _rb_gc_heaps_used",
30
- it means you installed the patched binary, but tried to run the
30
+ it means you installed the patched binary, but tried to profile the
31
31
  server with the regular binary.
32
32
 
33
33
  You may get library require errors if you install ruby-bleak-house (1.8.6)
34
34
  alongside a different verson of Ruby. You could try to patch your local
35
35
  version of Ruby instead, or you could just upgrade to 1.8.6, which has
36
- a good trackrecord or stability anyway.
36
+ a good trackrecord of stability anyway.
37
37
 
38
38
  COPYRIGHT AND LICENSING
39
39
 
@@ -18,7 +18,7 @@ Gruff::Base::MAX_LEGENDS = 28
18
18
  class BleakHouse
19
19
  class Analyze
20
20
 
21
- SMOOTHNESS = ((i = ENV['SMOOTHNESS'].to_i) < 2 ? 2 : i)/2 * 2
21
+ SMOOTHNESS = ENV['SMOOTHNESS'].to_i.zero? ? 1 : ENV['SMOOTHNESS'].to_i
22
22
  MEM_KEY = "memory usage"
23
23
  DIR = "#{RAILS_ROOT}/log/bleak_house/"
24
24
 
@@ -28,6 +28,10 @@ class BleakHouse
28
28
  @name = name
29
29
  end
30
30
 
31
+ def d
32
+ self.class.d
33
+ end
34
+
31
35
  def draw
32
36
  g = Gruff::Line.new("1024x768")
33
37
  g.title = @name
@@ -49,6 +53,7 @@ class BleakHouse
49
53
  @increments.each_with_index do |increment, index|
50
54
  labels[index] = increment if (index % mod).zero?
51
55
  end
56
+
52
57
  g.labels = labels
53
58
 
54
59
  g.minimum_value = 0
@@ -63,12 +68,17 @@ class BleakHouse
63
68
  data.each_with_index do |frameset, index|
64
69
  increments << frameset.time
65
70
  frameset.data.keys.select do |key|
66
- key =~ selector #or key =~ Regexp.new(specials.keys.join('|'))
71
+ # aggregate common keys based on the selection regexs
72
+ key =~ selector
67
73
  end.each do |key|
68
74
  aggregate_data[key.to_s[namer, 1]] ||= []
69
75
  aggregate_data[key.to_s[namer, 1]][index] += frameset.data[key].to_i
70
76
  end
71
- end
77
+ end
78
+ aggregate_data.each do |key, value|
79
+ # extend the length of every value set to the end of the run
80
+ aggregate_data[key][increments.size - 1] ||= nil
81
+ end
72
82
  [aggregate_data, increments]
73
83
  end
74
84
 
@@ -83,20 +93,32 @@ class BleakHouse
83
93
  Dir.chdir(DIR) do
84
94
 
85
95
  puts "parsing data"
86
- data = YAML.load_file(filename)
96
+ data = YAML.load_file(filename)
97
+
98
+ # subtract core counts from action
99
+ data = data[0..(-1 - data.size % 2)]
100
+ data = data.in_groups_of(2).map do |frames|
101
+ core, action = frames.first, frames.last
102
+ action.data.each do |key, value|
103
+ action.data[key] = value - core.data[key[/::::(.*)/,1]].to_i
104
+ end
105
+ [action.time, core.data.merge(action.data)]
106
+ end
107
+
108
+ # smooth
87
109
  data = data[0..(-1 - data.size % SMOOTHNESS)]
88
110
  data = data.in_groups_of(SMOOTHNESS).map do |frames|
89
111
  timestamp = frames.map(&:time).sum / SMOOTHNESS
90
112
  values = frames.map(&:data).inject(Hash.new(0)) do |total, this_frame|
91
113
  this_frame.each do |key, value|
92
- # hackz are because we want to average the memory usage, but conflate the core/action frames
93
- total[key] += (value / SMOOTHNESS.to_f * (key =~ /^#{MEM_KEY}/ ? 1.0 : 2.0))
114
+ total[key] += value / SMOOTHNESS.to_f
94
115
  end
95
116
  end
96
117
  [Time.at(timestamp).strftime("%H:%M:%S"), values]
97
118
  end
98
119
  puts "#{data.size} frames after smoothing"
99
-
120
+
121
+ # generate initial controller graph
100
122
  puts "entire app"
101
123
  controller_data, increments = aggregate(data, //, /^(.*?)($|\/|::::)/)
102
124
  if controller_data.has_key? MEM_KEY
@@ -110,7 +132,6 @@ class BleakHouse
110
132
  # in each controller, by action
111
133
  controller_data.keys.each do |controller|
112
134
  @mem = (controller == MEM_KEY)
113
- next unless @mem
114
135
  puts(@mem ? " #{controller}" : " action for #{controller} controller")
115
136
  Dir.descend(controller) do
116
137
  action_data, increments = aggregate(data, /^#{controller}($|\/|::::)/, /\/(.*?)($|\/|::::)/)
@@ -132,5 +153,9 @@ class BleakHouse
132
153
  end
133
154
  end
134
155
 
156
+ def self.d
157
+ require 'ruby-debug'; Debugger.start; debugger
158
+ end
159
+
135
160
  end
136
161
  end
@@ -20,13 +20,14 @@ class BleakHouse
20
20
  end
21
21
  end
22
22
 
23
- LOGFILE = "#{RAILS_ROOT}/log/bleak_house_#{RAILS_ENV}.dump"
23
+ LOGFILE = "#{RAILS_ROOT}/log/bleak_house_#{RAILS_ENV}.yaml.log"
24
24
  if File.exists?(LOGFILE)
25
25
  File.rename(LOGFILE, "#{LOGFILE}.old")
26
26
  warn "renamed old logfile"
27
27
  end
28
28
 
29
29
  WITH_SPECIALS = false
30
+ GC = true
30
31
 
31
32
  MEMLOGGER = if ENV['MEMLOGGER'] !~ /ruby/i and (ENV['MEMLOGGER'] =~ /c/i or
32
33
  `which ruby-bleak-house` !~ /no ruby_bleak_house/)
@@ -6,13 +6,13 @@ class Dispatcher
6
6
  def prepare_application_with_bleak_house
7
7
  prepare_application_without_bleak_house
8
8
  BleakHouse::MEMLOGGER.snapshot(BleakHouse::LOGFILE, 'core rails', BleakHouse::WITH_SPECIALS)
9
- GC.start
9
+ GC.start if BleakHouse::GC
10
10
  end
11
11
  alias_method_chain :prepare_application, :bleak_house
12
12
 
13
13
  def reset_after_dispatch_with_bleak_house
14
14
  BleakHouse::MEMLOGGER.snapshot(BleakHouse::LOGFILE, BleakHouse.last_request_name || 'unknown', BleakHouse::WITH_SPECIALS)
15
- GC.start
15
+ GC.start if BleakHouse::GC
16
16
  reset_after_dispatch_without_bleak_house
17
17
  end
18
18
  alias_method_chain :reset_after_dispatch, :bleak_house
@@ -44,4 +44,7 @@ class Symbol
44
44
  def =~ regex
45
45
  self.to_s =~ regex
46
46
  end
47
+ def [](*args)
48
+ self.to_s[*args]
49
+ end
47
50
  end
@@ -8,7 +8,7 @@ namespace :bleak_house do
8
8
  rescue LoadError
9
9
  require 'bleak_house/analyze'
10
10
  end
11
- BleakHouse::Analyze.build_all("#{RAILS_ROOT}/log/bleak_house_#{RAILS_ENV}.dump")
11
+ BleakHouse::Analyze.build_all("#{RAILS_ROOT}/log/bleak_house_#{RAILS_ENV}.yaml.log")
12
12
  end
13
13
  end
14
14
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: bleak_house
5
5
  version: !ruby/object:Gem::Version
6
- version: "5.2"
7
- date: 2007-05-07 00:00:00 -04:00
6
+ version: "5.3"
7
+ date: 2007-05-08 00:00:00 -04:00
8
8
  summary: BleakHouse is a Rails plugin for finding memory leaks. It tracks ObjectSpace for your entire app, and produces charts of references by controller, by action, and by object class.
9
9
  require_paths:
10
10
  - lib
@@ -27,7 +27,7 @@ signing_key:
27
27
  cert_chain:
28
28
  post_install_message: |+
29
29
 
30
- Thanks for installing Bleak House 5.2.
30
+ Thanks for installing Bleak House 5.3.
31
31
 
32
32
  For each Rails app you want to profile, you will need to add the following
33
33
  rake task in RAILS_ROOT/lib/tasks/bleak_house_tasks.rake to be able to run
@@ -38,7 +38,7 @@ post_install_message: |+
38
38
  task :analyze do
39
39
  rescue LoadError
40
40
  end
41
- BleakHouse::Analyze.build_all("#{RAILS_ROOT}/log/bleak_house_#{RAILS_ENV}.dump")
41
+ BleakHouse::Analyze.build_all("#{RAILS_ROOT}/log/bleak_house_#{RAILS_ENV}.yaml.log")
42
42
  end
43
43
  end
44
44