scrap 0.0.3 → 0.0.4
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/README.markdown +23 -3
- data/config/routes.rb +1 -1
- data/lib/scrap.rb +3 -3
- data/lib/scrap/engine.rb +8 -0
- data/lib/scrap/version.rb +1 -1
- data/sample.html +15 -11
- data/scrap.gemspec +1 -1
- metadata +4 -4
- data/lib/scrap/railtie.rb +0 -7
data/README.markdown
CHANGED
@@ -5,13 +5,32 @@ For use in Rack apps: install the gem, require 'scrap', and run Scrap as a middl
|
|
5
5
|
|
6
6
|
Scrap will provide a new url, <code>/stats/scrap</code>, which will report a number of metrics about your app.
|
7
7
|
|
8
|
-
For an example of the output, see
|
8
|
+
For an example of the output, see sample.html (taken from a very large
|
9
|
+
Rails app).
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
If you're running scrap in a Rails app, just add it to your Gemfile (or
|
14
|
+
install it and require it, if you're not using Bundler). Scrap comes
|
15
|
+
with a Rails::Engine that will automatically require the middleware and
|
16
|
+
add its route.
|
17
|
+
|
18
|
+
If you're not using Rails, then you'll have to add Scrap::Middleware to
|
19
|
+
your middleware stack.
|
20
|
+
|
21
|
+
Scrap is not recommended for long-term production usage, as it does
|
22
|
+
incur a significant (though not crippling) performance penalty.
|
23
|
+
Typically, you would install it for a few days at a time when you
|
24
|
+
suspect you have a memory problem and want to hunt it down, then remove
|
25
|
+
Scrap once you're done debugging.
|
9
26
|
|
10
27
|
## Dependencies
|
11
28
|
|
12
29
|
None, really, though Scrap is intended for Linux systems. On OS
|
13
30
|
X, the Ruby GC statistics will be displayed, but overall process memory
|
14
|
-
usage will not be reported.
|
31
|
+
usage will not be reported. Scrap has been tested extensively with Ruby 1.9 on Rails 3.0.x, and
|
32
|
+
less so on 3.1.x and 3.2.x. Reports of Scrap's usefulness in other
|
33
|
+
configurations are welcome.
|
15
34
|
|
16
35
|
## Config
|
17
36
|
|
@@ -30,7 +49,8 @@ If present, Scrap will use a config/scrap.yml file. See the provided example fil
|
|
30
49
|
Scrap was originally written for Ruby 1.8.7, with lots of switches to
|
31
50
|
enable it to take advantage of REE's better GC statistics visibility.
|
32
51
|
I've rewritten the switches to allow Scrap to use 1.9.3's statistics,
|
33
|
-
though they're harder to understand than REE's.
|
52
|
+
though they're harder to understand than REE's. Scrap should still work
|
53
|
+
well with REE, and less well (but as well as possible) on MRI 1.8.7.
|
34
54
|
|
35
55
|
## Contributing
|
36
56
|
|
data/config/routes.rb
CHANGED
data/lib/scrap.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "scrap/version"
|
2
2
|
module Scrap
|
3
3
|
|
4
|
-
class
|
4
|
+
class Middleware
|
5
5
|
COMMIFY_REGEX = /(\d)(?=(\d\d\d)+(?!\d))/
|
6
6
|
CRLF = "\r\n"
|
7
7
|
|
@@ -10,7 +10,7 @@ class Scrap
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(env)
|
13
|
-
|
13
|
+
self.class.call(env)
|
14
14
|
end
|
15
15
|
|
16
16
|
@@gc_stats = {}
|
@@ -212,6 +212,6 @@ class Scrap
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
-
require "scrap/
|
215
|
+
require "scrap/engine" if defined? Rails
|
216
216
|
|
217
217
|
end
|
data/lib/scrap/engine.rb
ADDED
data/lib/scrap/version.rb
CHANGED
data/sample.html
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
<html><head>
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Number of
|
11
|
-
|
12
|
-
|
2
|
+
<title>[24212] Garbage Report</title>
|
3
|
+
<style type="text/css"> body { font-family: monospace; color: #222; } td { border-bottom: 1px solid #eee; padding: 1px 9px; } td.t { background: #fafafa; } tr:hover td { background: #fafaf0; border-color: #e0e0dd; } h1,h2,h3 { border-bottom: 1px solid #ddd; font-family: sans-serif; } </style>
|
4
|
+
<body>
|
5
|
+
<h1>Scrap - PID 24212</h1>
|
6
|
+
<table>
|
7
|
+
<tr><td class="t">Virtual Memory usage:</td><td>964.59MB</td></tr><tr><td class="t">Real Memory usage:</td><td>188.09MB</td></tr><tr><td class="t">Vsize Delta:</td><td>0.00MB</td></tr><tr><td class="t">RSS Delta:</td><td>0.05MB</td></tr><tr><td class="t">Last Scrap req:</td><td>0.37 seconds ago</td></tr><tr><td class="t">Requests processed:</td><td>1</td></tr><tr><td class="t">Alive for:</td><td>0.37 seconds</td></tr><tr><td class="t">Total time spent in GC:</td><td>0.04 seconds</td></tr></table>
|
8
|
+
<h3>Top deltas since last request</h3><table border="0"><tr><td class='t'>String</td><td>+319,819</td></tr><tr><td class='t'>Array</td><td>+72,729</td></tr><tr><td class='t'>RubyVM::InstructionSequence</td><td>+54,822</td></tr><tr><td class='t'>Hash</td><td>+13,820</td></tr><tr><td class='t'>Proc</td><td>+11,491</td></tr><tr><td class='t'>RubyVM::Env</td><td>+8,470</td></tr><tr><td class='t'>Gem::Version</td><td>+5,438</td></tr><tr><td class='t'>Regexp</td><td>+5,035</td></tr><tr><td class='t'>Gem::Requirement</td><td>+4,871</td></tr><tr><td class='t'>Class</td><td>+4,459</td></tr><tr><td class='t'>Gem::Dependency</td><td>+3,179</td></tr><tr><td class='t'>Regin::Character</td><td>+2,873</td></tr><tr><td class='t'>Factory::Attribute::Static</td><td>+2,538</td></tr><tr><td class='t'>Factory::Attribute::Dynamic</td><td>+2,324</td></tr><tr><td class='t'>XSD::QName</td><td>+2,209</td></tr><tr><td class='t'>ActiveSupport::Callbacks::Callback</td><td>+2,108</td></tr><tr><td class='t'>Module</td><td>+1,871</td></tr><tr><td class='t'>SOAP::Mapping::SchemaElementDefinition</td><td>+1,556</td></tr><tr><td class='t'>MIME::Type</td><td>+1,517</td></tr><tr><td class='t'>Float</td><td>+1,061</td></tr><tr><td class='t'>Time</td><td>+725</td></tr><tr><td class='t'>Range</td><td>+687</td></tr><tr><td class='t'>ActiveSupport::Callbacks::CallbackChain</td><td>+667</td></tr><tr><td class='t'>Gem::Specification</td><td>+662</td></tr><tr><td class='t'>Regin::Expression</td><td>+611</td></tr><tr><td class='t'>ActiveRecord::ConnectionAdapters::Mysql2Column</td><td>+587</td></tr><tr><td class='t'>ActiveRecord::Reflection::AssociationReflection</td><td>+538</td></tr><tr><td class='t'>SOAP::Mapping::SchemaDefinition</td><td>+520</td></tr><tr><td class='t'>Factory::Attribute::Callback</td><td>+506</td></tr><tr><td class='t'>Factory</td><td>+503</td></tr><tr><td class='t'>Regin::Group</td><td>+421</td></tr><tr><td class='t'>Bundler::Dependency</td><td>+366</td></tr><tr><td class='t'>Regin::Anchor</td><td>+357</td></tr><tr><td class='t'>ActiveRecord::Relation</td><td>+343</td></tr><tr><td class='t'>Arel::Nodes::SelectStatement</td><td>+339</td></tr><tr><td class='t'>Arel::Nodes::SelectCore</td><td>+339</td></tr><tr><td class='t'>Arel::SelectManager</td><td>+339</td></tr><tr><td class='t'>Arel::SqlLiteral</td><td>+338</td></tr><tr><td class='t'>SOAP::Mapping::SchemaSequenceDefinition</td><td>+304</td></tr><tr><td class='t'>Rack::Mount::GeneratableRegexp::DynamicSegment</td><td>+277</td></tr><tr><td class='t'>Bundler::LazySpecification</td><td>+270</td></tr><tr><td class='t'>Regin::CharacterClass</td><td>+254</td></tr><tr><td class='t'>ActiveModel::Validations::PresenceValidator</td><td>+228</td></tr><tr><td class='t'>Rails::Initializable::Initializer</td><td>+227</td></tr><tr><td class='t'>Rails::Paths::Path</td><td>+219</td></tr><tr><td class='t'>TZInfo::TimezoneTransitionInfo</td><td>+212</td></tr><tr><td class='t'>Rack::Mount::Route</td><td>+202</td></tr><tr><td class='t'>ActionDispatch::Routing::Route</td><td>+202</td></tr><tr><td class='t'>ActionDispatch::Routing::RouteSet::Dispatcher</td><td>+201</td></tr><tr><td class='t'>LibXML::XML::XXPath</td><td>+192</td></tr></table><h3>Top objects</h3><table border="0"><tr><td class='t'>String</td><td>323,627</td></tr><tr><td class='t'>Array</td><td>70,462</td></tr><tr><td class='t'>RubyVM::InstructionSequence</td><td>54,822</td></tr><tr><td class='t'>Hash</td><td>13,679</td></tr><tr><td class='t'>Proc</td><td>11,484</td></tr><tr><td class='t'>RubyVM::Env</td><td>8,463</td></tr><tr><td class='t'>Gem::Version</td><td>5,438</td></tr><tr><td class='t'>Regexp</td><td>4,956</td></tr><tr><td class='t'>Gem::Requirement</td><td>4,871</td></tr><tr><td class='t'>Class</td><td>4,459</td></tr><tr><td class='t'>Gem::Dependency</td><td>3,179</td></tr><tr><td class='t'>Regin::Character</td><td>2,873</td></tr><tr><td class='t'>Factory::Attribute::Static</td><td>2,538</td></tr><tr><td class='t'>Factory::Attribute::Dynamic</td><td>2,324</td></tr><tr><td class='t'>XSD::QName</td><td>2,209</td></tr><tr><td class='t'>ActiveSupport::Callbacks::Callback</td><td>2,108</td></tr><tr><td class='t'>Module</td><td>1,871</td></tr><tr><td class='t'>SOAP::Mapping::SchemaElementDefinition</td><td>1,556</td></tr><tr><td class='t'>MIME::Type</td><td>1,517</td></tr><tr><td class='t'>Float</td><td>1,061</td></tr><tr><td class='t'>Time</td><td>725</td></tr><tr><td class='t'>Range</td><td>687</td></tr><tr><td class='t'>ActiveSupport::Callbacks::CallbackChain</td><td>667</td></tr><tr><td class='t'>Gem::Specification</td><td>662</td></tr><tr><td class='t'>Regin::Expression</td><td>611</td></tr><tr><td class='t'>ActiveRecord::ConnectionAdapters::Mysql2Column</td><td>587</td></tr><tr><td class='t'>ActiveRecord::Reflection::AssociationReflection</td><td>538</td></tr><tr><td class='t'>SOAP::Mapping::SchemaDefinition</td><td>520</td></tr><tr><td class='t'>Factory::Attribute::Callback</td><td>506</td></tr><tr><td class='t'>Factory</td><td>503</td></tr><tr><td class='t'>Regin::Group</td><td>421</td></tr><tr><td class='t'>Bundler::Dependency</td><td>366</td></tr><tr><td class='t'>Regin::Anchor</td><td>357</td></tr><tr><td class='t'>Arel::SelectManager</td><td>343</td></tr><tr><td class='t'>ActiveRecord::Relation</td><td>343</td></tr><tr><td class='t'>Arel::Nodes::SelectCore</td><td>343</td></tr><tr><td class='t'>Arel::SqlLiteral</td><td>343</td></tr><tr><td class='t'>Arel::Nodes::SelectStatement</td><td>343</td></tr><tr><td class='t'>SOAP::Mapping::SchemaSequenceDefinition</td><td>304</td></tr><tr><td class='t'>Rack::Mount::GeneratableRegexp::DynamicSegment</td><td>277</td></tr><tr><td class='t'>Bundler::LazySpecification</td><td>270</td></tr><tr><td class='t'>Regin::CharacterClass</td><td>254</td></tr><tr><td class='t'>ActiveModel::Validations::PresenceValidator</td><td>228</td></tr><tr><td class='t'>Rails::Initializable::Initializer</td><td>227</td></tr><tr><td class='t'>Rails::Paths::Path</td><td>219</td></tr><tr><td class='t'>TZInfo::TimezoneTransitionInfo</td><td>212</td></tr><tr><td class='t'>Rack::Mount::Route</td><td>202</td></tr><tr><td class='t'>ActionDispatch::Routing::Route</td><td>202</td></tr><tr><td class='t'>ActionDispatch::Routing::RouteSet::Dispatcher</td><td>201</td></tr><tr><td class='t'>LibXML::XML::XXPath</td><td>192</td></tr></table><h3>Request history</h3><p>vsize:[964.59 MB] rss:[188.04 MB] GET /stats/scrap</p><pre>GC cycles so far: 1245
|
9
|
+
Number of heaps : 1819
|
10
|
+
Number of objects : 743616
|
11
|
+
Heap length : 3272
|
12
|
+
Heap increment : 1453
|
13
|
+
Heap live num : 632437
|
14
|
+
Heap free num : 111147
|
15
|
+
Heap final num : 0
|
16
|
+
</pre></body></html>
|
data/scrap.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "scrap"
|
7
7
|
s.version = Scrap::VERSION
|
8
8
|
s.authors = ["Chris Heald", "Bradley Harris", "Ben Somers", "Joseph Chen"]
|
9
|
-
s.email = ["
|
9
|
+
s.email = ["somers.ben@gmail.com", "joseph.chen@gmail.com"]
|
10
10
|
s.homepage = "http://www.github.com/bensomers/scrap"
|
11
11
|
s.summary = %q{Scrap is a Rack endpoint designed to expose various garbage and memory-related metrics about your app. Intended for tracking down memory leaks and bloat.}
|
12
12
|
s.description = %q{Scrap is a Rack endpoint designed to expose various garbage and memory-related metrics about your app. Intended for tracking down memory leaks and bloat.}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,13 +12,13 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-09-
|
15
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description: Scrap is a Rack endpoint designed to expose various garbage and memory-related
|
18
18
|
metrics about your app. Intended for tracking down memory leaks and bloat.
|
19
19
|
email:
|
20
|
-
- joseph.chen@gmail.com
|
21
20
|
- somers.ben@gmail.com
|
21
|
+
- joseph.chen@gmail.com
|
22
22
|
executables: []
|
23
23
|
extensions: []
|
24
24
|
extra_rdoc_files: []
|
@@ -30,7 +30,7 @@ files:
|
|
30
30
|
- Rakefile
|
31
31
|
- config/routes.rb
|
32
32
|
- lib/scrap.rb
|
33
|
-
- lib/scrap/
|
33
|
+
- lib/scrap/engine.rb
|
34
34
|
- lib/scrap/version.rb
|
35
35
|
- sample.html
|
36
36
|
- scrap.gemspec
|