Giter VIP home page Giter VIP logo

bumbler's Introduction

Bumbler

Find slow loading gems in your Bundler-based projects!

Bumbler tracks how long the main require of each gem takes, for example with gem 'bar' it tracks require 'bar'. If the gem name and the require name are different, add require: manually for correct time tracking, for example gem 'bar-foo', require: 'bar_foo'. This require tracking can sometimes lead to false positives, because of dependencies, for example foo requires rails which leads to foo being marked as slow.

For rails projects it loads config/environment.rb, for all others it runs Bundler.require *Bundler.groups.

gem install bumbler
cd project && bumbler

Custom entrypoints

Add bumbler to your Gemfile

gem 'bumbler'
RUBYOPT=-rbumbler/go bundle exec ruby -r./lib/foo.rb -e Bumbler::Stats.print_slow_items

Custom threshold

Set the minimum number of milliseconds before something slow is listed. For example, to show anything >= 10ms:

bumbler -t 10

Rails: Track load-time of initializers

See how slow your app's initializers are (./config/initializers/*), as well as the initializers for any engines you rely on.

bumbler --initializers

Show all loaded gems

Rails:

bumbler --all

Ruby:

-e Bumbler::Stats.print_tracked_items

Development

Rails

We don't have any integration tests with rails, so when touching rails code make sure to test it in a real app.

cd my-rails-app && ~/Code/tools/bumbler/bin/bumbler

Release new version

rake bump:[major|minor|patch] && rake release

License

Bumbler is MIT licensed. See the accompanying file for the full text.

bumbler's People

Contributors

ariccio avatar fladson avatar grosser avatar mark-ellul avatar mauro-oto avatar mokhan avatar nevir avatar pelargir avatar petergoldstein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bumbler's Issues

No results output when running RSpec

Hi, there!

I was hoping to use Bumbler to profile the (currently very slow) boot up of our RSpec test suite. Unfortunately, Bumbler doesn't output the results after the loading finished. It displays the progress bar correctly, i.e.:

$ bundle exec rspec
[#########                                                                     ]
( 7/59)  492.04ms loaded pry

However, after the loading finished, the test suite starts, and no Bumbler results are ever printed.

Recommended way to have Bumber on some projects but not others

I just installed Bumbler on one project, and edit my .zshrc to set the RUBY_OPT. Problem now is that all my projects complain cannot load such file -- bumbler/go. What is the recommended way to handle multiple projects where some may not have Bumbler?

Thanks!

not working in rails 6.0

         3: from /home/andrew/.rvm/gems/ruby-2.5.5/gems/activesupport-6.0.0/lib/active_support/deprecation/proxy_wrappers.rb:128:in `new'
         2: from /home/andrew/.rvm/gems/ruby-2.5.5/gems/activesupport-6.0.0/lib/active_support/deprecation/proxy_wrappers.rb:128:in `new'
         1: from /home/andrew/.rvm/gems/ruby-2.5.5/gems/activesupport-6.0.0/lib/active_support/deprecation/proxy_wrappers.rb:132:in `initialize'
/home/andrew/.rvm/gems/ruby-2.5.5/gems/activesupport-6.0.0/lib/active_support/deprecation/proxy_wrappers.rb:168:in `method_missing': private method `warn' called for nil:NilClass (NoMethodError)

Add MIT Licence?

Hi there,

We are unable to use your Gem at Swrve because it has no license. Can you add a license to the project (most Gems use an MIT license).

You can do this by adding a s.license = 'MIT' to the Gemspec. Let me know if you want me to make a pull request.

Thanks,

Marc

Ruby broken. Cannot load such file -- bumble/go (LoadError)

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bumbler/go (LoadError)

I've tried numerous things to get past this error. Has anyone dealt with this and was able to get past it?

Gems with require: true are ignored

If a Gemfile specifies require: true for a given gem, that gem is ignored by Bumbler.

Specifying require: true may seem redundant, but it is supported syntax per the Bundler documentation and can be a useful callout:
https://bundler.io/man/gemfile.5.html

The reason this is happening can be found in bundler.rb on line 43:

Array(spec.autorequire || spec.name).each do |path|
  @require_map[path] = spec.name
  @gem_state[spec.name][path] = false
end

When require: true is set in the Gemfile, the result of spec.autorequire is also true which gets inserted into the @require_map as the path key (instead of an actual path). This causes #gem_for_require to return nil for that gem.

This bug can be reliably reproduced by running Bumbler, noting one of the slow gems listed, and modifying the Gemfile with require: true for this gem. Run Bumbler again and you won't see the gem appear anywhere in the list of slow gems.

Mysterious :finisher_hook in results?

I am seeing the following in my Rails 5.1.2 app:

$ bumbler --initializers
Slow requires:
    212.38  :set_routes_reloader_hook
    315.04  ./config/initializers/mac_address_db.rb
    650.10  ./config/initializers/preview_interceptors.rb
   2203.82  ./config/initializers/messaging.rb
   3208.06  :load_config_initializers
  110146.25  :finisher_hook

Any ideas what is this weird :finisher_hook that is taking up the majority of the load time?

unitialized constant Bumbler::Bundler on ruby 2.3.0

I think there is a problem with Ruby 2.3.0 and Rails 3.2.18

This is what I'm getting:

etagwerker:ombushop/ (develop✗) $ bumbler                                                                                                       /Users/etagwerker/.rvm/gems/ruby-2.3.0@ombu/gems/bumbler-0.3.1/lib/bumbler/hooks.rb:67:in `handle_require': uninitialized constant Bumbler::Bundler (NameError)
Did you mean?  Bumbler::Bundler
               Bundler
               Bumbler
    from /Users/etagwerker/.rvm/gems/ruby-2.3.0@ombu/gems/bumbler-0.3.1/lib/bumbler/hooks.rb:34:in `block (2 levels) in hook_require!'
    from /Users/etagwerker/.rvm/gems/ruby-2.3.0@ombu/gems/bumbler-0.3.1/lib/bumbler/hooks.rb:67:in `handle_require'
    from /Users/etagwerker/.rvm/gems/ruby-2.3.0@ombu/gems/bumbler-0.3.1/lib/bumbler/hooks.rb:34:in `block (2 levels) in hook_require!'
    from /Users/etagwerker/.rvm/gems/ruby-2.3.0@ombu/gems/bumbler-0.3.1/bin/bumbler:37:in `<top (required)>'
    from /Users/etagwerker/.rvm/gems/ruby-2.3.0@ombu/bin/bumbler:23:in `load'
    from /Users/etagwerker/.rvm/gems/ruby-2.3.0@ombu/bin/bumbler:23:in `<main>'
    from /Users/etagwerker/.rvm/gems/ruby-2.3.0@ombu/bin/ruby_executable_hooks:15:in `eval'
    from /Users/etagwerker/.rvm/gems/ruby-2.3.0@ombu/bin/ruby_executable_hooks:15:in `<main>'

It seems to work fine on ruby-2.2.4

not working in rails 4.1?

Thanks for this neat project!

I have bumbler in my Gemfile. bumbler alone does give output, but it doesn't seem to be hooking into the other rails commands.

➔ bundle exec bumbler --version
0.3.1
➔ bundle exec rails c
Loading development environment (Rails 4.1.6)
app(dev)> 
➔ bundle exec bumbler          
[######################################################                    ]
( 74/100)                                                [redacted] (  15.65ms)
Slow requires:
    128.31 [redacted] 
    129.65 [redacted] 
    133.85 [redacted] 
    170.97 [redacted] 
    219.30 [redacted] 
    236.02 [redacted] 
    317.85 [redacted] 
    328.58 [redacted] 
    328.78 [redacted] 
    339.01 [redacted] 
    368.24 [redacted] 
    395.12 [redacted] 
    449.70 [redacted] 
    622.40 [redacted] 
    687.46 [redacted] 
    713.75 [redacted] 

Bumbler stops at half of the gems

Running on Ruby 2.6.3, bumbler stops when about half the gems are loaded. You can see this here, that the progress bar is not filled:

root@7d8364656441:/usr/src/app# bumbler
[########################################################################################################                                                                        ]
( 78/132) aws-sdk-s3...                                                                                                                                           thin (  66.78ms)
Slow requires:
    104.80  elasticsearch-dsl
    107.16  paperclip
    121.61  typhoeus
    121.98  stripe

Is this a known issue? How could I debug this?

Make it work for any Bundler-based projects?

The description of the gem says that it works for any "Bundler-based" projects, but when I tried to run it inside the root directory of one of my gems, I get an error:

LoadError: cannot load such file -- ./config/environment
  /Users/janko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bumbler-0.3.2/lib/bumbler/hooks.rb:35:in `require'
  /Users/janko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bumbler-0.3.2/lib/bumbler/hooks.rb:35:in `call'
  /Users/janko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bumbler-0.3.2/lib/bumbler/hooks.rb:35:in `block (3 levels) in hook_require!'
  /Users/janko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bumbler-0.3.2/lib/bumbler/hooks.rb:68:in `handle_require'
  /Users/janko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bumbler-0.3.2/lib/bumbler/hooks.rb:34:in `block (2 levels) in hook_require!'
  /Users/janko/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bumbler-0.3.2/bin/bumbler:37:in `<top (required)>'
  /Users/janko/.rbenv/versions/2.4.1/bin/bumbler:22:in `load'
  /Users/janko/.rbenv/versions/2.4.1/bin/bumbler:22:in `<top (required)>'

Would it be possible to make it work for any Bundler-based project, not just Rails? Btw, I'm really impressed with the gem, my friend executed it on one of his Rails projects and the information was super useful (I care about load time).

RVM compatibility?

Not sure if this is a problem unique to my setup, but is this gem known to work with RVM?

Some relevant versions:

bundler (1.3.3, 1.2.3)
rubygems-bundler (1.1.1, 1.1.0)
rvm (1.11.3.5)

I gem install bumbler then RUBYOPT=-rbumbler/go rails c returns

~/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bumbler/go (LoadError)
    from~/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.