bleak_house 3.2 → 3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +2 -0
- data/Manifest +32 -30
- data/README +2 -5
- data/TODO +1 -1
- data/bin/bleak +2 -5
- data/ext/bleak_house/logger/build_logger.rb +3 -0
- data/ext/bleak_house/logger/build_ruby.rb +61 -0
- data/ext/bleak_house/logger/extconf.rb +2 -3
- data/lib/bleak_house/analyzer/analyzer.rb +23 -12
- data/{patches → ruby}/gc.c.patch +0 -0
- data/{patches → ruby}/parse.y.patch +0 -0
- data/ruby/ruby-1.8.6.tar.bz2 +0 -0
- data.tar.gz.sig +0 -0
- metadata +34 -32
- metadata.gz.sig +0 -0
- data/lib/bleak_house/support/build.rb +0 -53
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
TODO
|
|
2
|
-
test/unit/test_bleak_house.rb
|
|
3
|
-
test/misc/direct.rb
|
|
4
|
-
README
|
|
5
|
-
Rakefile
|
|
6
|
-
patches/parse.y.patch
|
|
7
|
-
patches/gc.c.patch
|
|
8
|
-
Manifest
|
|
9
|
-
LICENSE_RUBY
|
|
10
|
-
LICENSE_BSD
|
|
11
|
-
LICENSE
|
|
12
|
-
lib/vendor/lightcsv.rb
|
|
13
|
-
lib/bleak_house.rb
|
|
14
|
-
lib/bleak_house/support/rake.rb
|
|
15
|
-
lib/bleak_house/support/core_extensions.rb
|
|
16
|
-
lib/bleak_house/support/build.rb
|
|
17
|
-
lib/bleak_house/rails.rb
|
|
18
|
-
lib/bleak_house/rails/dispatcher.rb
|
|
19
|
-
lib/bleak_house/rails/bleak_house.rb
|
|
20
|
-
lib/bleak_house/rails/action_controller.rb
|
|
21
|
-
lib/bleak_house/logger.rb
|
|
22
|
-
lib/bleak_house/logger/mem_usage.rb
|
|
23
|
-
lib/bleak_house/analyzer.rb
|
|
24
|
-
lib/bleak_house/analyzer/analyzer.rb
|
|
25
|
-
install.rb
|
|
26
|
-
init.rb
|
|
27
|
-
ext/bleak_house/logger/snapshot.h
|
|
28
|
-
ext/bleak_house/logger/snapshot.c
|
|
29
|
-
ext/bleak_house/logger/extconf.rb
|
|
30
|
-
CHANGELOG
|
|
31
1
|
bin/bleak
|
|
2
|
+
CHANGELOG
|
|
3
|
+
ext/bleak_house/logger/build_logger.rb
|
|
4
|
+
ext/bleak_house/logger/build_ruby.rb
|
|
5
|
+
ext/bleak_house/logger/extconf.rb
|
|
6
|
+
ext/bleak_house/logger/snapshot.c
|
|
7
|
+
ext/bleak_house/logger/snapshot.h
|
|
8
|
+
init.rb
|
|
9
|
+
install.rb
|
|
10
|
+
lib/bleak_house/analyzer/analyzer.rb
|
|
11
|
+
lib/bleak_house/analyzer.rb
|
|
12
|
+
lib/bleak_house/logger/mem_usage.rb
|
|
13
|
+
lib/bleak_house/logger.rb
|
|
14
|
+
lib/bleak_house/rails/action_controller.rb
|
|
15
|
+
lib/bleak_house/rails/bleak_house.rb
|
|
16
|
+
lib/bleak_house/rails/dispatcher.rb
|
|
17
|
+
lib/bleak_house/rails.rb
|
|
18
|
+
lib/bleak_house/support/core_extensions.rb
|
|
19
|
+
lib/bleak_house/support/rake.rb
|
|
20
|
+
lib/bleak_house.rb
|
|
21
|
+
lib/vendor/lightcsv.rb
|
|
22
|
+
LICENSE
|
|
23
|
+
LICENSE_BSD
|
|
24
|
+
LICENSE_RUBY
|
|
25
|
+
Manifest
|
|
26
|
+
Rakefile
|
|
27
|
+
README
|
|
28
|
+
ruby/gc.c.patch
|
|
29
|
+
ruby/parse.y.patch
|
|
30
|
+
ruby/ruby-1.8.6.tar.bz2
|
|
31
|
+
test/misc/direct.rb
|
|
32
|
+
test/unit/test_bleak_house.rb
|
|
33
|
+
TODO
|
data/README
CHANGED
|
@@ -26,12 +26,9 @@ The public certificate for this gem is at http://rubyforge.org/frs/download.php/
|
|
|
26
26
|
== Installation
|
|
27
27
|
|
|
28
28
|
Install the gem:
|
|
29
|
-
sudo gem install bleak_house
|
|
29
|
+
sudo gem install bleak_house
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
bleak --build
|
|
33
|
-
|
|
34
|
-
This gives you a Ruby binary named <tt>ruby-bleak-house</tt> alongside your regular binary.
|
|
31
|
+
The installation takes a long time because it compiles a patched Ruby binary for you. It is installed as <tt>ruby-bleak-house</tt> alongside your regular <tt>ruby</tt>binary.
|
|
35
32
|
|
|
36
33
|
== Profiling a Rails app
|
|
37
34
|
|
data/TODO
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
*
|
|
2
|
+
* Some bug in the immortal detector; no results returned on the CHOW 2gb dump.
|
data/bin/bleak
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
|
|
3
5
|
if !ARGV[0]
|
|
4
6
|
puts "Please specify a BleakHouse logfile"
|
|
5
7
|
exit
|
|
6
|
-
elsif ARGV[0] == "--build"
|
|
7
|
-
require 'bleak_house/support/build'
|
|
8
8
|
else
|
|
9
9
|
$LOAD_PATH << "#{File.dirname(__FILE__)}/../lib/"
|
|
10
|
-
unless self.respond_to? 'gem'
|
|
11
|
-
$LOAD_PATH << "/opt/local/lib/ruby/gems/1.8/gems/ccsv-0.0.1/lib/"
|
|
12
|
-
end
|
|
13
10
|
require 'bleak_house/analyzer'
|
|
14
11
|
BleakHouse::Analyzer.run(ARGV[0])
|
|
15
12
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
if RUBY_PLATFORM =~ /win32|windows/
|
|
3
|
+
raise "Windows is not supported."
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
source_dir = File.expand_path(File.dirname(__FILE__)) + "/../../../ruby"
|
|
7
|
+
tmp = "/tmp/"
|
|
8
|
+
|
|
9
|
+
require 'fileutils'
|
|
10
|
+
|
|
11
|
+
if `which ruby-bleak-house` =~ /no ruby-bleak-house in/
|
|
12
|
+
|
|
13
|
+
Dir.chdir(tmp) do
|
|
14
|
+
build_dir = "bleak_house"
|
|
15
|
+
binary_dir = File.dirname(`which ruby`)
|
|
16
|
+
FileUtils.rm_rf(build_dir) rescue nil
|
|
17
|
+
Dir.mkdir(build_dir)
|
|
18
|
+
|
|
19
|
+
begin
|
|
20
|
+
Dir.chdir(build_dir) do
|
|
21
|
+
|
|
22
|
+
# Copy Ruby source
|
|
23
|
+
bz2 = "ruby-1.8.6.tar.bz2"
|
|
24
|
+
FileUtils.copy "#{source_dir}/#{bz2}", bz2
|
|
25
|
+
|
|
26
|
+
# Extract
|
|
27
|
+
system("tar xjf #{bz2} > tar.log 2>&1")
|
|
28
|
+
File.delete bz2
|
|
29
|
+
|
|
30
|
+
Dir.chdir("ruby-1.8.6") do
|
|
31
|
+
|
|
32
|
+
# Patch
|
|
33
|
+
system("patch -p0 < \'#{source_dir}/gc.c.patch\' > ../gc.c.patch.log 2>&1")
|
|
34
|
+
system("patch -p0 < \'#{source_dir}/parse.y.patch\' > ../parse.y.patch.log 2>&1")
|
|
35
|
+
|
|
36
|
+
# Configure
|
|
37
|
+
system("./configure --prefix=#{binary_dir[0..-5]} > ../configure.log 2>&1") # --with-static-linked-ext
|
|
38
|
+
|
|
39
|
+
# Make
|
|
40
|
+
system("make > ../make.log 2>&1")
|
|
41
|
+
|
|
42
|
+
binary = "#{binary_dir}/ruby-bleak-house"
|
|
43
|
+
|
|
44
|
+
# Install binary
|
|
45
|
+
if File.exist? "ruby"
|
|
46
|
+
# Avoid "Text file busy" error
|
|
47
|
+
exec("rm #{binary}; cp ./ruby #{binary}; chmod 755 #{binary}")
|
|
48
|
+
else
|
|
49
|
+
raise "Binary did not build"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
rescue Object => e
|
|
55
|
+
raise "Please see the last modified log file in #{tmp}#{build_dir}, perhaps\nit will contain a clue.\n#{e.to_s}"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Success
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
@@ -16,7 +16,7 @@ module BleakHouse
|
|
|
16
16
|
-5 => 'heap/filled',
|
|
17
17
|
-6 => 'heap/free'
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
INITIAL_SKIP = 10
|
|
21
21
|
|
|
22
22
|
CLASS_KEYS = eval('[nil, ' + # skip 0
|
|
@@ -31,7 +31,9 @@ module BleakHouse
|
|
|
31
31
|
# Avoid divide by zero errors
|
|
32
32
|
frame['meta']['ratio'] = ratio = (bsize - dsize) / (bsize + dsize + 1).to_f
|
|
33
33
|
frame['meta']['impact'] = begin
|
|
34
|
-
Math.log10((bsize - dsize).abs.to_i / 10.0)
|
|
34
|
+
result = Math.log10((bsize - dsize).abs.to_i / 10.0)
|
|
35
|
+
raise Errno::ERANGE if result.nan? or result.infinite?
|
|
36
|
+
result
|
|
35
37
|
rescue Errno::ERANGE
|
|
36
38
|
0
|
|
37
39
|
end
|
|
@@ -41,20 +43,22 @@ module BleakHouse
|
|
|
41
43
|
|
|
42
44
|
# Parses and correlates a BleakHouse::Logger output file.
|
|
43
45
|
def self.run(logfile)
|
|
44
|
-
|
|
46
|
+
logfile.chomp!(".cache")
|
|
47
|
+
cachefile = logfile + ".cache"
|
|
48
|
+
|
|
49
|
+
unless File.exists? logfile or File.exists? cachefile
|
|
45
50
|
puts "No data file found: #{logfile}"
|
|
46
51
|
exit
|
|
47
52
|
end
|
|
48
53
|
|
|
49
54
|
puts "Working..."
|
|
50
55
|
|
|
51
|
-
cachefile = logfile + ".cache"
|
|
52
56
|
frames = []
|
|
53
57
|
last_population = []
|
|
54
58
|
frame = nil
|
|
55
59
|
ix = nil
|
|
56
60
|
|
|
57
|
-
if File.exist?(cachefile) and File.stat(cachefile).mtime > File.stat(logfile).mtime
|
|
61
|
+
if File.exist?(cachefile) and (!File.exists? logfile or File.stat(cachefile).mtime > File.stat(logfile).mtime)
|
|
58
62
|
# Cache is fresh
|
|
59
63
|
puts "Using cache"
|
|
60
64
|
frames = Marshal.load(File.open(cachefile).read)
|
|
@@ -125,7 +129,7 @@ module BleakHouse
|
|
|
125
129
|
end
|
|
126
130
|
|
|
127
131
|
# See what objects are still laying around
|
|
128
|
-
population = frames
|
|
132
|
+
population = frames[-2]['objects'].reject do |key, value|
|
|
129
133
|
frames.first['births'][key] == value
|
|
130
134
|
end
|
|
131
135
|
|
|
@@ -154,7 +158,7 @@ module BleakHouse
|
|
|
154
158
|
leakers[tag] ||= Hash.new(0)
|
|
155
159
|
leakers[tag][klass] += 1
|
|
156
160
|
end
|
|
157
|
-
end
|
|
161
|
+
end
|
|
158
162
|
|
|
159
163
|
# Sort
|
|
160
164
|
leakers = leakers.map do |tag, value|
|
|
@@ -170,10 +174,17 @@ module BleakHouse
|
|
|
170
174
|
requests = frames.select do |frame|
|
|
171
175
|
frame['meta']['tag'] == tag
|
|
172
176
|
end.size
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
values = value.map do |klass, count|
|
|
178
|
+
count = count/requests
|
|
179
|
+
[klass, count]
|
|
180
|
+
end.select do |klass, count|
|
|
181
|
+
count > 0
|
|
182
|
+
end
|
|
183
|
+
if values.any?
|
|
184
|
+
puts " #{tag} leaks, averaged over #{requests} requests:"
|
|
185
|
+
values.each do |klass, count|
|
|
186
|
+
puts " #{count} #{klass}"
|
|
187
|
+
end
|
|
177
188
|
end
|
|
178
189
|
end
|
|
179
190
|
|
|
@@ -186,7 +197,7 @@ module BleakHouse
|
|
|
186
197
|
impacts = impacts.map do |tag, values|
|
|
187
198
|
[tag, values.inject(0) {|acc, i| acc + i} / values.size.to_f]
|
|
188
199
|
end.sort_by do |tag, impact|
|
|
189
|
-
-impact
|
|
200
|
+
impact.nan? ? 0 : -impact
|
|
190
201
|
end
|
|
191
202
|
|
|
192
203
|
puts "\nTags sorted by impact * ratio:"
|
data/{patches → ruby}/gc.c.patch
RENAMED
|
File without changes
|
|
File without changes
|
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: bleak_house
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: "3.
|
|
7
|
-
date: 2007-
|
|
6
|
+
version: "3.3"
|
|
7
|
+
date: 2007-10-11 00:00:00 -04:00
|
|
8
8
|
summary: A library for finding memory leaks.
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
@@ -52,37 +52,39 @@ post_install_message:
|
|
|
52
52
|
authors:
|
|
53
53
|
- Evan Weaver
|
|
54
54
|
files:
|
|
55
|
-
- TODO
|
|
56
|
-
- test/unit/test_bleak_house.rb
|
|
57
|
-
- test/misc/direct.rb
|
|
58
|
-
- README
|
|
59
|
-
- Rakefile
|
|
60
|
-
- patches/parse.y.patch
|
|
61
|
-
- patches/gc.c.patch
|
|
62
|
-
- Manifest
|
|
63
|
-
- LICENSE_RUBY
|
|
64
|
-
- LICENSE_BSD
|
|
65
|
-
- LICENSE
|
|
66
|
-
- lib/vendor/lightcsv.rb
|
|
67
|
-
- lib/bleak_house.rb
|
|
68
|
-
- lib/bleak_house/support/rake.rb
|
|
69
|
-
- lib/bleak_house/support/core_extensions.rb
|
|
70
|
-
- lib/bleak_house/support/build.rb
|
|
71
|
-
- lib/bleak_house/rails.rb
|
|
72
|
-
- lib/bleak_house/rails/dispatcher.rb
|
|
73
|
-
- lib/bleak_house/rails/bleak_house.rb
|
|
74
|
-
- lib/bleak_house/rails/action_controller.rb
|
|
75
|
-
- lib/bleak_house/logger.rb
|
|
76
|
-
- lib/bleak_house/logger/mem_usage.rb
|
|
77
|
-
- lib/bleak_house/analyzer.rb
|
|
78
|
-
- lib/bleak_house/analyzer/analyzer.rb
|
|
79
|
-
- install.rb
|
|
80
|
-
- init.rb
|
|
81
|
-
- ext/bleak_house/logger/snapshot.h
|
|
82
|
-
- ext/bleak_house/logger/snapshot.c
|
|
83
|
-
- ext/bleak_house/logger/extconf.rb
|
|
84
|
-
- CHANGELOG
|
|
85
55
|
- bin/bleak
|
|
56
|
+
- CHANGELOG
|
|
57
|
+
- ext/bleak_house/logger/build_logger.rb
|
|
58
|
+
- ext/bleak_house/logger/build_ruby.rb
|
|
59
|
+
- ext/bleak_house/logger/extconf.rb
|
|
60
|
+
- ext/bleak_house/logger/snapshot.c
|
|
61
|
+
- ext/bleak_house/logger/snapshot.h
|
|
62
|
+
- init.rb
|
|
63
|
+
- install.rb
|
|
64
|
+
- lib/bleak_house/analyzer/analyzer.rb
|
|
65
|
+
- lib/bleak_house/analyzer.rb
|
|
66
|
+
- lib/bleak_house/logger/mem_usage.rb
|
|
67
|
+
- lib/bleak_house/logger.rb
|
|
68
|
+
- lib/bleak_house/rails/action_controller.rb
|
|
69
|
+
- lib/bleak_house/rails/bleak_house.rb
|
|
70
|
+
- lib/bleak_house/rails/dispatcher.rb
|
|
71
|
+
- lib/bleak_house/rails.rb
|
|
72
|
+
- lib/bleak_house/support/core_extensions.rb
|
|
73
|
+
- lib/bleak_house/support/rake.rb
|
|
74
|
+
- lib/bleak_house.rb
|
|
75
|
+
- lib/vendor/lightcsv.rb
|
|
76
|
+
- LICENSE
|
|
77
|
+
- LICENSE_BSD
|
|
78
|
+
- LICENSE_RUBY
|
|
79
|
+
- Manifest
|
|
80
|
+
- Rakefile
|
|
81
|
+
- README
|
|
82
|
+
- ruby/gc.c.patch
|
|
83
|
+
- ruby/parse.y.patch
|
|
84
|
+
- ruby/ruby-1.8.6.tar.bz2
|
|
85
|
+
- test/misc/direct.rb
|
|
86
|
+
- test/unit/test_bleak_house.rb
|
|
87
|
+
- TODO
|
|
86
88
|
test_files:
|
|
87
89
|
- test/unit/test_bleak_house.rb
|
|
88
90
|
rdoc_options: []
|
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
if RUBY_PLATFORM =~ /win32|windows/
|
|
3
|
-
puts "ERROR: windows not supported."
|
|
4
|
-
exit
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
require 'fileutils'
|
|
8
|
-
puts "Building patched Ruby binary"
|
|
9
|
-
|
|
10
|
-
tmp = "/tmp/"
|
|
11
|
-
Dir.chdir(tmp) do
|
|
12
|
-
|
|
13
|
-
build_dir = "bleak_house"
|
|
14
|
-
binary_dir = File.dirname(`which ruby`)
|
|
15
|
-
FileUtils.rm_rf(build_dir) rescue nil
|
|
16
|
-
Dir.mkdir(build_dir)
|
|
17
|
-
|
|
18
|
-
begin
|
|
19
|
-
Dir.chdir(build_dir) do
|
|
20
|
-
puts " Downloading Ruby source"
|
|
21
|
-
bz2 = "ruby-1.8.6.tar.bz2"
|
|
22
|
-
system("wget 'http://rubyforge.org/frs/download.php/18434/ruby-1.8.6.tar.bz2' &> wget.log")
|
|
23
|
-
puts " Extracting"
|
|
24
|
-
system("tar xjf #{bz2} &> tar.log")
|
|
25
|
-
File.delete bz2
|
|
26
|
-
|
|
27
|
-
Dir.chdir("ruby-1.8.6") do
|
|
28
|
-
puts " Patching"
|
|
29
|
-
system("patch -p0 < \'#{File.dirname(__FILE__)}/../../../patches/gc.c.patch\' &> ../gc.c.patch.log")
|
|
30
|
-
system("patch -p0 < \'#{File.dirname(__FILE__)}/../../../patches/parse.y.patch\' &> ../parse.y.patch.log")
|
|
31
|
-
puts " Configuring"
|
|
32
|
-
system("./configure --prefix=#{binary_dir[0..-5]} &> ../configure.log") # --with-static-linked-ext
|
|
33
|
-
puts " Making"
|
|
34
|
-
system("make &> ../make.log")
|
|
35
|
-
|
|
36
|
-
binary = "#{binary_dir}/ruby-bleak-house"
|
|
37
|
-
puts " Installing as #{binary}"
|
|
38
|
-
|
|
39
|
-
if File.exist? "ruby"
|
|
40
|
-
# Avoid a "Text file busy" error
|
|
41
|
-
exec("rm #{binary}; cp ./ruby #{binary}; chmod -755 #{binary}; echoe \" Done\"")
|
|
42
|
-
else
|
|
43
|
-
raise "Binary did not build"
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
rescue Object => e
|
|
49
|
-
puts "ERROR: please see the last modified log file in #{tmp}#{build_dir}, perhaps\nit will contain a clue.\n#{e.to_s}"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
|