derailed_benchmarks 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +3 -3
- data/README.md +17 -17
- data/derailed_benchmarks.gemspec +1 -1
- data/lib/derailed_benchmarks/tasks.rb +1 -1
- data/lib/derailed_benchmarks/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c95cc3fd294dd14030ec457fcd746aa388a7de20
|
4
|
+
data.tar.gz: 643e3f6d830fd7b0e256b484eef779d68f7e2b1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be87224b84945a0c9e9dec491647df53b2371de77b6c2fd4af672c63743a9e9137fe59b9da7d4d8a96f7ab610e49fb3a220eec6b930d87e09c965051ffbcda85
|
7
|
+
data.tar.gz: bbce0a2c86379d1e2a8a2f1bc278fb6982415a3af58263ce17d62a093632ec50ccabc4ab34972871c339646d85ff609833fa884d2803883792f8dceb9acc980c
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
derailed_benchmarks (1.3.
|
4
|
+
derailed_benchmarks (1.3.1)
|
5
5
|
benchmark-ips (~> 2)
|
6
6
|
get_process_mem (~> 0)
|
7
7
|
heapy (~> 0)
|
8
8
|
memory_profiler (~> 0)
|
9
9
|
rack (>= 1)
|
10
|
-
rake (
|
10
|
+
rake (> 10, < 12)
|
11
11
|
thor (~> 0.19)
|
12
12
|
|
13
13
|
GEM
|
@@ -42,7 +42,7 @@ GEM
|
|
42
42
|
multi_json (~> 1.0)
|
43
43
|
arel (3.0.3)
|
44
44
|
bcrypt (3.1.10)
|
45
|
-
benchmark-ips (2.
|
45
|
+
benchmark-ips (2.5.0)
|
46
46
|
builder (3.0.4)
|
47
47
|
capybara (2.4.4)
|
48
48
|
mime-types (>= 1.16)
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ You must be using Ruby 2.1+ to install these libraries. If you're on an older ve
|
|
42
42
|
|
43
43
|
## Use
|
44
44
|
|
45
|
-
There are two ways to
|
45
|
+
There are two ways to benchmark an app. Derailed can either try to boot your web app and run requests against it while benchmarking, or it can statically give you more information about the dependencies that are in your Gemfile. Booting your app will always be more accurate, but if you cannot get your app to run in production locally, you'll still find the static information useful.
|
46
46
|
|
47
47
|
## Static Benchmarking
|
48
48
|
|
@@ -75,8 +75,8 @@ TOP: 54.1836 MiB
|
|
75
75
|
|
76
76
|
_Aside: A "MiB", which is the [IEEE] and [IEC] symbol for Mebibyte, is 2<sup>20</sup> bytes / 1024 Kibibytes (which are in turn 1024 bytes)._
|
77
77
|
|
78
|
-
[IEEE]:
|
79
|
-
[IEC]:
|
78
|
+
[IEEE]: https://en.wikipedia.org/wiki/IEEE_1541-2002
|
79
|
+
[IEC]: https://en.wikipedia.org/wiki/IEC_80000-13
|
80
80
|
|
81
81
|
Here we can see that `mail` uses 18MiB, with the majority coming from `mime/types`. You can use this information to prune out large dependencies you don't need. Also if you see a large memory use by a gem that you do need, please open up an issue with that library to let them know (be sure to include reproduction instructions). Hopefully as a community we can identify memory hotspots and reduce their impact. Before we can fix performance problems, we need to know where those problems exist.
|
82
82
|
|
@@ -88,7 +88,7 @@ $ bundle exec derailed bundle:mem development
|
|
88
88
|
|
89
89
|
You can use `CUT_OFF=0.3` to only show files that have above a certain memory useage, this can be used to help eliminate noise.
|
90
90
|
|
91
|
-
Note: This method won't include files in your own app, only items in your Gemfile. For that you'll need to use `derailed exec mem`. See below for more info.
|
91
|
+
Note: This method won't include files in your own app, only items in your Gemfile. For that you'll need to use `bundle exec derailed exec mem`. See below for more info.
|
92
92
|
|
93
93
|
The same file may be required by several libraries, since Ruby only requires files once, the cost is only associated with the first library to require a file. To make this more visible duplicate entries will list all the parents they belong to. For example both `mail` and `fog` require `mime/types. So it may show up something like this in your app:
|
94
94
|
|
@@ -101,7 +101,7 @@ TOP: 54.1836 MiB
|
|
101
101
|
mail/message: 0.3906 MiB
|
102
102
|
```
|
103
103
|
|
104
|
-
That way you'll know that simply removing the top level library (mail) would not result in a memory reduction. The output is
|
104
|
+
That way you'll know that simply removing the top level library (mail) would not result in a memory reduction. The output is truncated after the first two entries:
|
105
105
|
|
106
106
|
|
107
107
|
```
|
@@ -141,7 +141,7 @@ allocated memory by gem
|
|
141
141
|
8103432 json-1.8.2
|
142
142
|
```
|
143
143
|
|
144
|
-
Once you identify a gem that creates a large amount of memory using `$ derailed bundle:mem` you can pull that gem into it's own Gemfile and run `$ derailed bundle:objects` to get detailed information about it. This information can be used by contributors and library authors to identify and eliminate object creation hotspots.
|
144
|
+
Once you identify a gem that creates a large amount of memory using `$ bundle exec derailed bundle:mem` you can pull that gem into it's own Gemfile and run `$ bundle exec derailed bundle:objects` to get detailed information about it. This information can be used by contributors and library authors to identify and eliminate object creation hotspots.
|
145
145
|
|
146
146
|
|
147
147
|
By default this task will only return results from the `:default` and `"production"` groups. If you want a different group you can run with.
|
@@ -150,14 +150,14 @@ By default this task will only return results from the `:default` and `"producti
|
|
150
150
|
$ bundle exec derailed bundle:objects development
|
151
151
|
```
|
152
152
|
|
153
|
-
Note: This method won't include files in your own app, only items in your Gemfile. For that you'll need to use `derailed exec objects`. See below for more info.
|
153
|
+
Note: This method won't include files in your own app, only items in your Gemfile. For that you'll need to use `bundle exec derailed exec objects`. See below for more info.
|
154
154
|
|
155
155
|
|
156
156
|
## Dynamic app Benchmarking
|
157
157
|
|
158
|
-
This benchmarking will attempt to boot your Rails app and run benchmarks against it. Unlike the static benchmarking with `$ derailed bundle:*` these will include information about your specific app. The pro is you'll get more information and potentially identify problems in your app code, the con is that it requires you to be able to boot and run your application in a `production` environment locally, which for some apps is non-trivial.
|
158
|
+
This benchmarking will attempt to boot your Rails app and run benchmarks against it. Unlike the static benchmarking with `$ bundle exec derailed bundle:*` these will include information about your specific app. The pro is you'll get more information and potentially identify problems in your app code, the con is that it requires you to be able to boot and run your application in a `production` environment locally, which for some apps is non-trivial.
|
159
159
|
|
160
|
-
You may want to check out [mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler), here's a [mini-profiler walkthrough](http://www.justinweiss.com/
|
160
|
+
You may want to check out [mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler), here's a [mini-profiler walkthrough](http://www.justinweiss.com/articles/a-new-way-to-understand-your-rails-apps-performance/). It's great and does slightly different benchmarking than what you'll find here.
|
161
161
|
|
162
162
|
### Running in Production Locally.
|
163
163
|
|
@@ -198,7 +198,7 @@ Once you've fixed all errors and you can run a server in production, you're almo
|
|
198
198
|
You can run commands against your app by running `$ derailed exec`. There are sections on setting up Rack and using authenticated requests below. You can see what commands are available by running:
|
199
199
|
|
200
200
|
```
|
201
|
-
$ derailed exec --help
|
201
|
+
$ bundle exec derailed exec --help
|
202
202
|
$ derailed exec perf:allocated_objects # outputs allocated object diff after app is called TEST_COUNT times
|
203
203
|
$ derailed exec perf:gc # outputs GC::Profiler.report data while app is called TEST_COUNT times
|
204
204
|
$ derailed exec perf:ips # iterations per second
|
@@ -241,9 +241,9 @@ PID: 78675
|
|
241
241
|
Here we can see that while the memory use is increasing, it levels off around 183 MiB. You'll want to run this task using ever increasing values of `TEST_COUNT=` for example
|
242
242
|
|
243
243
|
```
|
244
|
-
$ TEST_COUNT=5000 derailed exec perf:mem_over_time
|
245
|
-
$ TEST_COUNT=10_000 derailed exec perf:mem_over_time
|
246
|
-
$ TEST_COUNT=20_000 derailed exec perf:mem_over_time
|
244
|
+
$ TEST_COUNT=5000 bundle exec derailed exec perf:mem_over_time
|
245
|
+
$ TEST_COUNT=10_000 bundle exec derailed exec perf:mem_over_time
|
246
|
+
$ TEST_COUNT=20_000 bundle exec derailed exec perf:mem_over_time
|
247
247
|
```
|
248
248
|
|
249
249
|
Adjust your counts appropriately so you can get results in a reasonable amount of time. If your memory never levels off, congrats! You've got a memory leak! I recommend copying and pasting values from the file generated into google docs and graphing it so you can get a better sense of the slope of your line.
|
@@ -264,7 +264,7 @@ This task hits your app and uses memory_profiler to see where objects are create
|
|
264
264
|
|
265
265
|
|
266
266
|
```
|
267
|
-
$ TEST_COUNT=10 derailed exec perf:objects
|
267
|
+
$ TEST_COUNT=10 bundle exec derailed exec perf:objects
|
268
268
|
```
|
269
269
|
|
270
270
|
This is an expensive operation, so you likely want to keep the count lowish. Once you've identified a hotspot read [how ruby uses memory](http://www.sitepoint.com/ruby-uses-memory/) for some tips on reducing object allocations.
|
@@ -273,7 +273,7 @@ This is is similar to `$ bundle exec derailed bundle:objects` however it include
|
|
273
273
|
|
274
274
|
## I want a Heap Dump
|
275
275
|
|
276
|
-
If you're still struggling with runtime memory you can generate a heap dump that can later be analyzed using [heap_inspect](https://github.com/schneems/
|
276
|
+
If you're still struggling with runtime memory you can generate a heap dump that can later be analyzed using [heap_inspect](https://github.com/schneems/heapy).
|
277
277
|
|
278
278
|
```
|
279
279
|
$ bundle exec derailed exec perf:heap
|
@@ -406,7 +406,7 @@ $ TEST_COUNT=100_000 bundle exec derailed exec perf:test
|
|
406
406
|
By default tasks will hit your homepage `/`. If you want to hit a different url use `PATH_TO_HIT` for example if you wanted to go to `users/new` you can execute:
|
407
407
|
|
408
408
|
```
|
409
|
-
$ PATH_TO_HIT=/users/new derailed exec perf:mem
|
409
|
+
$ PATH_TO_HIT=/users/new bundle exec derailed exec perf:mem
|
410
410
|
```
|
411
411
|
|
412
412
|
### Using a real web server with USE_SERVER
|
@@ -420,7 +420,7 @@ $ USE_SERVER=webrick bundle exec derailed exec perf:mem
|
|
420
420
|
Or
|
421
421
|
|
422
422
|
```
|
423
|
-
$ USE_SERVER=puma derailed exec perf:mem
|
423
|
+
$ USE_SERVER=puma bundle exec derailed exec perf:mem
|
424
424
|
```
|
425
425
|
|
426
426
|
This boots a webserver and hits it using `curl` instead of in memory. This is useful if you think the performance issue is related to your webserver.
|
data/derailed_benchmarks.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_dependency "get_process_mem", "~> 0"
|
24
24
|
gem.add_dependency "benchmark-ips", "~> 2"
|
25
25
|
gem.add_dependency "rack", ">= 1"
|
26
|
-
gem.add_dependency "rake", "
|
26
|
+
gem.add_dependency "rake", "> 10", "< 12"
|
27
27
|
gem.add_dependency "thor", "~> 0.19"
|
28
28
|
|
29
29
|
gem.add_development_dependency "capybara", "~> 2"
|
@@ -80,7 +80,7 @@ namespace :perf do
|
|
80
80
|
sleep 1
|
81
81
|
|
82
82
|
def call_app(path = File.join("/", PATH_TO_HIT))
|
83
|
-
cmd = "curl http://localhost:#{@port}#{path} -s --fail 2>&1"
|
83
|
+
cmd = "curl 'http://localhost:#{@port}#{path}' -s --fail 2>&1"
|
84
84
|
response = `#{cmd}`
|
85
85
|
raise "Bad request to #{cmd.inspect} Response:\n#{ response.inspect }" unless $?.success?
|
86
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: derailed_benchmarks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: heapy
|
@@ -84,16 +84,22 @@ dependencies:
|
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '10'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '12'
|
90
93
|
type: :runtime
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
|
-
- - "
|
97
|
+
- - ">"
|
95
98
|
- !ruby/object:Gem::Version
|
96
99
|
version: '10'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '12'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: thor
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -250,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
256
|
version: '0'
|
251
257
|
requirements: []
|
252
258
|
rubyforge_project:
|
253
|
-
rubygems_version: 2.5.
|
259
|
+
rubygems_version: 2.5.1
|
254
260
|
signing_key:
|
255
261
|
specification_version: 4
|
256
262
|
summary: Benchmarks designed to performance test your ENTIRE site
|