derailed_benchmarks 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd9db4d2438152b5594f932fa35b162859a60024b4d74d00f3d4c7d5ada3f09f
4
- data.tar.gz: f77ae05368c875fee001102adbd9652c1ef8001d2160064260c8b59dd455b00b
3
+ metadata.gz: 9519f087d4eeae220039bb6d4566757d627655ac96789809608b9a93af642b1d
4
+ data.tar.gz: a3f52d5df02db7a7c94043abe86cdf8d2f2bfad72595d36410ac55fc6b036faa
5
5
  SHA512:
6
- metadata.gz: f97fc2da5011cad2e69a6269776ceb7f4c769c3a7bd8bc5813848fc367f6f11ae6fdef1306139f3b8a3d5ead9cc93f4ce6d199688643111a794964392dd2d5d2
7
- data.tar.gz: 39597ebde572f3ea60dcf0224c5986a6480055e5a50b4998f277c2a7fe70503b36d288e0ea146f02bf99a15edafb7c06d6d3be1ed1ba1cee81c3dfc2c0c165f7
6
+ metadata.gz: 817dd67a37109e785bd8c87bdc12235c41bf8de4fa7803cf241aee6c285fcf760290e52598534498a798efd3e1b0505dd39e2124413b8c65be8b6223a6b01439
7
+ data.tar.gz: 0c2aeeffa9460fd920ac28945ce081cd8134397999586cc0c4e508833d9bbd93d5924c2438439fc5445ee403c345ab1149406f67fc0c468e598c44562ffd0127
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## HEAD
2
2
 
3
+ ## 2.1.0
4
+
5
+ - Add `perf:heap_diff` tool (https://github.com/schneems/derailed_benchmarks/pull/193)
6
+
3
7
  ## 2.0.1
4
8
 
5
9
  - `rack-test` dependency added (https://github.com/schneems/derailed_benchmarks/pull/187)
data/README.md CHANGED
@@ -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 [heap_inspect](https://github.com/schneems/heapy).
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 [SamSaffron's slides](https://speakerdeck.com/samsaffron/why-ruby-2-dot-1-excites-me?slide=27)
307
+ (or [a more recent inspired blog post](https://blog.skylight.io/hunting-for-leaks-in-ruby/))
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
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://speakerdeck.com/samsaffron/why-ruby-2-dot-1-excites-me?slide=27 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.
@@ -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://speakerdeck.com/samsaffron/why-ruby-2-dot-1-excites-me?slide=27 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?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DerailedBenchmarks
4
- VERSION = "2.0.1"
4
+ VERSION = "2.1.0"
5
5
  end
@@ -11,4 +11,19 @@ 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
23
+ assert_equal(
24
+ expected,
25
+ `bundle exec derailed exec --help`,
26
+ "Please update README.md:#{lineno}"
27
+ )
28
+ end
14
29
  end
@@ -153,6 +153,10 @@ class TasksTest < ActiveSupport::TestCase
153
153
  end
154
154
 
155
155
  test 'ips' do
156
- rake "perf:mem_over_time"
156
+ rake "perf:ips"
157
+ end
158
+
159
+ test 'heap_diff' do
160
+ rake "perf:heap_diff", env: { "TEST_COUNT" => 5 }
157
161
  end
158
162
  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: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heapy
@@ -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.2.3
390
+ rubygems_version: 3.2.15
391
391
  signing_key:
392
392
  specification_version: 4
393
393
  summary: Benchmarks designed to performance test your ENTIRE site