derailed_benchmarks 2.0.1 → 2.1.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +41 -2
- data/bin/derailed +3 -0
- data/lib/derailed_benchmarks/tasks.rb +36 -0
- data/lib/derailed_benchmarks/version.rb +1 -1
- data/test/derailed_test.rb +15 -0
- data/test/integration/tasks_test.rb +5 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1004e69d7a94d86e514586324fc21ce1871ca9f8690c989eafcf5283fc69e293
         | 
| 4 | 
            +
              data.tar.gz: 0bfbb09013d068279ee58e1361ef44f122c944662cc590941299b12d80151a80
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 48dee96d301b69c53f17467bd19918c9ea788568b5d630fe3888e2c0659345dfdef66be0b911ed2624af1cc11c9507a3700760b40f261d846f092b5e49743b79
         | 
| 7 | 
            +
              data.tar.gz: d69df370bb2cd4aebc48d1b077eb0d81b9da5dc659209da091d15b49df76af196f32c3b4daa0d402db2fa1aaf968067fc8eb9e3c690a9fce1c2c4458087256aa
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,13 @@ | |
| 1 1 | 
             
            ## HEAD
         | 
| 2 2 |  | 
| 3 | 
            +
            ## 2.1.1
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            - Fix Thor's deprecation warning by implementing `exit_on_failure?` (https://github.com/schneems/derailed_benchmarks/pull/195)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## 2.1.0
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            - Add `perf:heap_diff` tool (https://github.com/schneems/derailed_benchmarks/pull/193)
         | 
| 10 | 
            +
             | 
| 3 11 | 
             
            ## 2.0.1
         | 
| 4 12 |  | 
| 5 13 | 
             
            - `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 [ | 
| 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.
         | 
    
        data/bin/derailed
    CHANGED
    
    
| @@ -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,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
         | 
    
        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.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: 2021- | 
| 11 | 
            +
            date: 2021-07-09 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. | 
| 390 | 
            +
            rubygems_version: 3.2.22
         | 
| 391 391 | 
             
            signing_key:
         | 
| 392 392 | 
             
            specification_version: 4
         | 
| 393 393 | 
             
            summary: Benchmarks designed to performance test your ENTIRE site
         |