derailed_benchmarks 2.0.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +2 -0
- data/CHANGELOG.md +13 -0
- data/README.md +45 -4
- data/bin/derailed +6 -2
- data/derailed_benchmarks.gemspec +1 -1
- data/gemfiles/rails_git.gemfile +1 -1
- data/lib/derailed_benchmarks/load_tasks.rb +2 -2
- data/lib/derailed_benchmarks/tasks.rb +36 -0
- data/lib/derailed_benchmarks/version.rb +1 -1
- data/test/derailed_test.rb +16 -0
- data/test/integration/tasks_test.rb +5 -1
- data/test/test_helper.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 812e6f5e721e4baf5dd1911b6d4a21d00e3502d5a9c2c882c825026f174f0df7
|
4
|
+
data.tar.gz: ba3f9978aebf3652f767835edbbb0805d75c127e1a1df247057a04f7f0dde228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f422494ba5fd286bf36531b1c8bf1a8dc28cd6366f1d3ff9f2e81215307969eb1c8f60a6e3f6e27588f95cd7e5ad3c10ba963dfd820769a6f76656ae35d11ae9
|
7
|
+
data.tar.gz: ecbd77956660e6d0f5ca957fe718d564b2f7463f2197eaf84bad1b0c3ae1e3a42bf7bb58ed46bffc9153c819dd32f13335728556704da9bf9191f82bf95ce467
|
data/.circleci/config.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
## HEAD
|
2
2
|
|
3
|
+
## 2.1.2
|
4
|
+
|
5
|
+
- Support rails 7 for bundle exec derailed exec mem (https://github.com/zombocom/derailed_benchmarks/pull/212)
|
6
|
+
- Update the gemspec's homepage to the current repo URL (https://github.com/zombocom/derailed_benchmarks/pull/212)
|
7
|
+
|
8
|
+
## 2.1.1
|
9
|
+
|
10
|
+
- Fix Thor's deprecation warning by implementing `exit_on_failure?` (https://github.com/schneems/derailed_benchmarks/pull/195)
|
11
|
+
|
12
|
+
## 2.1.0
|
13
|
+
|
14
|
+
- Add `perf:heap_diff` tool (https://github.com/schneems/derailed_benchmarks/pull/193)
|
15
|
+
|
3
16
|
## 2.0.1
|
4
17
|
|
5
18
|
- `rack-test` dependency added (https://github.com/schneems/derailed_benchmarks/pull/187)
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ A series of things you can use to benchmark a Rails or Ruby app.
|
|
4
4
|
|
5
5
|
![](http://media.giphy.com/media/lfbxexWy71b6U/giphy.gif)
|
6
6
|
|
7
|
-
[![
|
7
|
+
[![CircleCI](https://circleci.com/gh/zombocom/derailed_benchmarks/tree/main.svg?style=svg)](https://circleci.com/gh/zombocom/derailed_benchmarks/tree/main)
|
8
8
|
[![Help Contribute to Open Source](https://www.codetriage.com/schneems/derailed_benchmarks/badges/users.svg)](https://www.codetriage.com/schneems/derailed_benchmarks)
|
9
9
|
|
10
10
|
## Compatibility/Requirements
|
@@ -198,12 +198,17 @@ You can run commands against your app by running `$ derailed exec`. There are se
|
|
198
198
|
```
|
199
199
|
$ bundle exec derailed exec --help
|
200
200
|
$ derailed exec perf:allocated_objects # outputs allocated object diff after app is called TEST_COUNT times
|
201
|
+
$ derailed exec perf:app # runs the performance test against two most recent commits of the current app
|
201
202
|
$ derailed exec perf:gc # outputs GC::Profiler.report data while app is called TEST_COUNT times
|
203
|
+
$ derailed exec perf:heap # heap analyzer
|
202
204
|
$ derailed exec perf:ips # iterations per second
|
205
|
+
$ derailed exec perf:library # runs the same test against two different branches for statistical comparison
|
203
206
|
$ derailed exec perf:mem # show memory usage caused by invoking require per gem
|
204
|
-
$ derailed exec perf:objects # profiles ruby allocation
|
205
207
|
$ derailed exec perf:mem_over_time # outputs memory usage over time
|
208
|
+
$ derailed exec perf:objects # profiles ruby allocation
|
209
|
+
$ derailed exec perf:stackprof # stackprof
|
206
210
|
$ derailed exec perf:test # hits the url TEST_COUNT times
|
211
|
+
$ derailed exec perf:heap_diff # three heaps generation for comparison
|
207
212
|
```
|
208
213
|
|
209
214
|
Instead of going over each command we'll look at common problems and which commands are best used to diagnose them. Later on we'll cover all of the environment variables you can use to configure derailed benchmarks in it's own section.
|
@@ -271,7 +276,7 @@ This is similar to `$ bundle exec derailed bundle:objects` however it includes o
|
|
271
276
|
|
272
277
|
## I want a Heap Dump
|
273
278
|
|
274
|
-
If you're still struggling with runtime memory you can generate a heap dump that can later be analyzed using [
|
279
|
+
If you're still struggling with runtime memory you can generate a heap dump that can later be analyzed using [heapy](https://github.com/schneems/heapy).
|
275
280
|
|
276
281
|
```
|
277
282
|
$ bundle exec derailed exec perf:heap
|
@@ -295,6 +300,40 @@ For more help on getting data from a heap dump see
|
|
295
300
|
$ heapy --help
|
296
301
|
```
|
297
302
|
|
303
|
+
### I want more heap dumps
|
304
|
+
|
305
|
+
When searching for a leak, you can use heap dumps for comparison to see what is
|
306
|
+
retained. See [Analyzing memory heaps](https://medium.com/klaxit-techblog/tracking-a-ruby-memory-leak-in-2021-9eb56575f731#875b)
|
307
|
+
(inspired from [SamSaffron's original idea](https://speakerdeck.com/samsaffron/why-ruby-2-dot-1-excites-me?slide=27))
|
308
|
+
for a clear example. You can generate 3 dumps (one every `TEST_COUNT` calls) using the
|
309
|
+
next command:
|
310
|
+
|
311
|
+
```
|
312
|
+
$ bundle exec derailed exec perf:heap_diff
|
313
|
+
Endpoint: "/"
|
314
|
+
Running 1000 times
|
315
|
+
Heap file generated: "tmp/2021-05-06T15:19:26+02:00-heap-0.ndjson"
|
316
|
+
Running 1000 times
|
317
|
+
Heap file generated: "tmp/2021-05-06T15:19:26+02:00-heap-1.ndjson"
|
318
|
+
Running 1000 times
|
319
|
+
Heap file generated: "tmp/2021-05-06T15:19:26+02:00-heap-2.ndjson"
|
320
|
+
|
321
|
+
Diff
|
322
|
+
====
|
323
|
+
Retained STRING 90 objects of size 4790/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/utils.rb:461
|
324
|
+
Retained ICLASS 20 objects of size 800/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/sinatra-contrib-2.0.8.1/lib/sinatra/namespace.rb:198
|
325
|
+
Retained DATA 20 objects of size 1360/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/2.7.0/monitor.rb:238
|
326
|
+
Retained STRING 20 objects of size 800/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-protection-2.0.8.1/lib/rack/protection/xss_header.rb:20
|
327
|
+
Retained STRING 10 objects of size 880/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/newrelic_rpm-5.4.0.347/lib/new_relic/agent/transaction.rb:890
|
328
|
+
Retained CLASS 10 objects of size 4640/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/sinatra-contrib-2.0.8.1/lib/sinatra/namespace.rb:198
|
329
|
+
Retained IMEMO 10 objects of size 480/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1017
|
330
|
+
...
|
331
|
+
|
332
|
+
Run `$ heapy --help` for more options
|
333
|
+
|
334
|
+
Also read https://medium.com/klaxit-techblog/tracking-a-ruby-memory-leak-in-2021-9eb56575f731#875b to understand better what you are reading.
|
335
|
+
```
|
336
|
+
|
298
337
|
### Memory Is large at boot.
|
299
338
|
|
300
339
|
Ruby memory typically goes in one direction, up. If your memory is large when you boot the application it will likely only increase. In addition to debugging memory retained from dependencies obtained while running `$ derailed bundle:mem` you'll likely want to see how your own files contribute to memory use.
|
@@ -556,12 +595,14 @@ Note: this plugs in the given webserver directly into rack, it doesn't use any `
|
|
556
595
|
|
557
596
|
### Excluding ActiveRecord
|
558
597
|
|
559
|
-
By default, derailed will load ActiveRecord if the gem is included as a dependency. It is included by default, if you just include the `rails` gem. If you are using a different ORM, you will either need to only include the `railties` gem, or set the `DERAILED_SKIP_ACTIVE_RECORD`
|
598
|
+
By default, derailed will load ActiveRecord if the gem is included as a dependency. It is included by default, if you just include the `rails` gem. If you are using a different ORM, you will either need to only include the `railties` gem, or set the `DERAILED_SKIP_ACTIVE_RECORD` environment variable.
|
560
599
|
|
561
600
|
```
|
562
601
|
$ DERAILED_SKIP_ACTIVE_RECORD=true
|
563
602
|
```
|
564
603
|
|
604
|
+
Alternatively, use the `DERAILED_SKIP_RAILS_REQUIRES` environment variable to have derailed not require any Rails gems. Your app will then need to require them as part of its boot sequence.
|
605
|
+
|
565
606
|
### Running in a different environment
|
566
607
|
|
567
608
|
Tests run against the production environment by default, but it's easy to
|
data/bin/derailed
CHANGED
@@ -20,6 +20,9 @@ Bundler.setup
|
|
20
20
|
require 'thor'
|
21
21
|
|
22
22
|
class DerailedBenchmarkCLI < Thor
|
23
|
+
def self.exit_on_failure?
|
24
|
+
true
|
25
|
+
end
|
23
26
|
|
24
27
|
desc "exec", "executes given derailed benchmark"
|
25
28
|
def exec(task = nil)
|
@@ -77,9 +80,10 @@ class DerailedBenchmarkCLI < Thor
|
|
77
80
|
require 'bundler/setup'
|
78
81
|
|
79
82
|
begin
|
80
|
-
if ENV["
|
83
|
+
if ENV["DERAILED_SKIP_RAILS_REQUIRES"]
|
84
|
+
# do nothing. your app will handle requiring Rails for booting.
|
85
|
+
elsif ENV["DERAILED_SKIP_ACTIVE_RECORD"]
|
81
86
|
require "action_controller/railtie"
|
82
|
-
require "action_mailer/railtie"
|
83
87
|
require "sprockets/railtie"
|
84
88
|
require "rails/test_unit/railtie"
|
85
89
|
else
|
data/derailed_benchmarks.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.email = ["richard.schneeman+rubygems@gmail.com"]
|
13
13
|
gem.description = %q{ Go faster, off the Rails }
|
14
14
|
gem.summary = %q{ Benchmarks designed to performance test your ENTIRE site }
|
15
|
-
gem.homepage = "https://github.com/
|
15
|
+
gem.homepage = "https://github.com/zombocom/derailed_benchmarks"
|
16
16
|
gem.license = "MIT"
|
17
17
|
|
18
18
|
gem.files = `git ls-files`.split($/)
|
data/gemfiles/rails_git.gemfile
CHANGED
@@ -6,7 +6,7 @@ source "https://rubygems.org"
|
|
6
6
|
|
7
7
|
gem "rails", github: "rails/rails", ref: "12bb9d32f56883914abcd98fd72e3c68c444808d"
|
8
8
|
|
9
|
-
gem 'devise', github: "plataformatec/devise"
|
9
|
+
gem 'devise', github: "plataformatec/devise", ref: "6d32d2447cc0f3739d9732246b5a5bde98d9e032"
|
10
10
|
|
11
11
|
group :development, :test do
|
12
12
|
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
@@ -40,9 +40,9 @@ namespace :perf do
|
|
40
40
|
ActiveRecord::Migrator.migrations_paths = DERAILED_APP.paths['db/migrate'].to_a
|
41
41
|
ActiveRecord::Migration.verbose = true
|
42
42
|
|
43
|
-
if Rails.version
|
43
|
+
if Rails.version >= "6.0"
|
44
44
|
ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths, ActiveRecord::SchemaMigration).migrate
|
45
|
-
elsif Rails.version.start_with?
|
45
|
+
elsif Rails.version.start_with?("5.2")
|
46
46
|
ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths).migrate
|
47
47
|
else
|
48
48
|
ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, nil)
|
@@ -247,6 +247,42 @@ namespace :perf do
|
|
247
247
|
puts "Also try uploading #{file_name.inspect} to http://tenderlove.github.io/heap-analyzer/"
|
248
248
|
end
|
249
249
|
|
250
|
+
desc "three heaps generation for comparison."
|
251
|
+
task :heap_diff => [:setup] do
|
252
|
+
require 'objspace'
|
253
|
+
|
254
|
+
launch_time = Time.now.iso8601
|
255
|
+
FileUtils.mkdir_p("tmp")
|
256
|
+
ObjectSpace.trace_object_allocations_start
|
257
|
+
3.times do |i|
|
258
|
+
file_name = "tmp/#{launch_time}-heap-#{i}.ndjson"
|
259
|
+
puts "Running #{ TEST_COUNT } times"
|
260
|
+
TEST_COUNT.times {
|
261
|
+
call_app
|
262
|
+
}
|
263
|
+
GC.start
|
264
|
+
|
265
|
+
puts "Heap file generated: #{ file_name.inspect }"
|
266
|
+
ObjectSpace.dump_all(output: File.open(file_name, 'w'))
|
267
|
+
end
|
268
|
+
|
269
|
+
require 'heapy'
|
270
|
+
|
271
|
+
puts ""
|
272
|
+
puts "Diff"
|
273
|
+
puts "===="
|
274
|
+
Heapy::Diff.new(
|
275
|
+
before: "tmp/#{launch_time}-heap-0.ndjson",
|
276
|
+
after: "tmp/#{launch_time}-heap-1.ndjson",
|
277
|
+
retained: "tmp/#{launch_time}-heap-2.ndjson"
|
278
|
+
).call
|
279
|
+
|
280
|
+
puts ""
|
281
|
+
puts "Run `$ heapy --help` for more options"
|
282
|
+
puts ""
|
283
|
+
puts "Also read https://medium.com/klaxit-techblog/tracking-a-ruby-memory-leak-in-2021-9eb56575f731#875b to understand better what you are reading."
|
284
|
+
end
|
285
|
+
|
250
286
|
def run!(cmd)
|
251
287
|
out = `#{cmd}`
|
252
288
|
raise "Error while running #{cmd.inspect}: #{out}" unless $?.success?
|
data/test/derailed_test.rb
CHANGED
@@ -11,4 +11,20 @@ class DerailedBenchmarksTest < ActiveSupport::TestCase
|
|
11
11
|
assert DerailedBenchmarks.gem_is_bundled?("rack")
|
12
12
|
refute DerailedBenchmarks.gem_is_bundled?("wicked")
|
13
13
|
end
|
14
|
+
|
15
|
+
test "readme contains correct output" do
|
16
|
+
readme_path = File.join(__dir__, "..", "README.md")
|
17
|
+
lines = File.foreach(readme_path)
|
18
|
+
lineno = 1
|
19
|
+
expected = lines.lazy.drop_while { |line|
|
20
|
+
lineno += 1
|
21
|
+
line != "$ bundle exec derailed exec --help\n"
|
22
|
+
}.drop(1).take_while { |line| line != "```\n" }.force.join.split("\n").sort
|
23
|
+
actual = `bundle exec derailed exec --help`.split("\n").sort
|
24
|
+
assert_equal(
|
25
|
+
expected,
|
26
|
+
actual,
|
27
|
+
"Please update README.md:#{lineno}"
|
28
|
+
)
|
29
|
+
end
|
14
30
|
end
|
data/test/test_helper.rb
CHANGED
@@ -32,9 +32,9 @@ require_relative "rails_app/config/environment"
|
|
32
32
|
|
33
33
|
# https://github.com/plataformatec/devise/blob/master/test/orm/active_record.rb
|
34
34
|
migrate_path = File.expand_path("../rails_app/db/migrate", __FILE__)
|
35
|
-
if Rails.version
|
35
|
+
if Rails.version >= "6.0"
|
36
36
|
ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
|
37
|
-
elsif Rails.version.start_with?
|
37
|
+
elsif Rails.version.start_with? "5.2"
|
38
38
|
ActiveRecord::MigrationContext.new(migrate_path).migrate
|
39
39
|
else
|
40
40
|
ActiveRecord::Migrator.migrate(migrate_path)
|
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: 2.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: heapy
|
@@ -368,7 +368,7 @@ files:
|
|
368
368
|
- test/rails_app/script/rails
|
369
369
|
- test/support/integration_case.rb
|
370
370
|
- test/test_helper.rb
|
371
|
-
homepage: https://github.com/
|
371
|
+
homepage: https://github.com/zombocom/derailed_benchmarks
|
372
372
|
licenses:
|
373
373
|
- MIT
|
374
374
|
metadata: {}
|
@@ -387,7 +387,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
387
387
|
- !ruby/object:Gem::Version
|
388
388
|
version: '0'
|
389
389
|
requirements: []
|
390
|
-
rubygems_version: 3.
|
390
|
+
rubygems_version: 3.3.7
|
391
391
|
signing_key:
|
392
392
|
specification_version: 4
|
393
393
|
summary: Benchmarks designed to performance test your ENTIRE site
|