Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

padrino-perf: watch out for problematic conditions in your app #1027

Merged
merged 1 commit into from Jan 30, 2013

Conversation

skade
Copy link
Contributor

@skade skade commented Jan 26, 2013

First of all: this is alpha, ugly and just a proof of concept that I wanted to show you.

This adds a small binary that allows to watch for know error conditions
and hook into certain aspects at startup time of a padrino application
to gather info.

Currently implemented is suite to detect json and yajl being loaded at the same time and tracking who loaded it.

Also, there is a horrible hack to ensure that load_paths added by padrino-perf are always in front of the $LOAD_PATH.

To try a sample run: add padrino-perf, json and yajl to your Gemfile. Run:

bundle exec padrino-perf -j -- padrino console

This is basically a nice alias for:

$ruby -r$PADRINO_PERF_SUITES/json -S padrino console

where $ruby is the ruby that called padrino-perf.

Then require json and yajl in any order:

.9.3-p125 :001 > require 'json'
 => true 
1.9.3-p125 :002 > require 'yajl'
Concurring json libraries have been loaded. This incurs an
unneccessary memory overhead at should be avoided. Consult the
following call stacks to see who loaded the offending libraries
and contact the authors if necessary:"

============
libname: json
============
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/json.rb:35:in `each'
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/json.rb:35:in `loaded_lib!'
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/yajl/yajl.rb:1:in `<top (required)>'
(irb):2:in `require'
(irb):2:in `irb_binding'
... cont
============
libname: yajl
============
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/json.rb:35:in `each'
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/json.rb:35:in `loaded_lib!'
/Users/skade/padrino/padrino-framework/padrino-framework/padrino-perf/lib/suites/yajl/yajl.rb:1:in `<top (required)>'
(irb):2:in `require'
(irb):2:in `irb_binding'

Its not really there yet and the implementation is very straigth-forward and generalized, but the technique can be used to built suites that track memory consumption during loading etc.

Its main strength is that it is not a library that you have to put in your Gemfile, but instead 'just' an extended Runtime.

This adds a small binary that allows to watch for know error conditions
and hook into certain aspects at startup time of a padrino application
to gather info.

Currently implemented is suite to detect json and yajl being loaded
concurrently.
@dariocravero
Copy link

I think it's a great start! Thanks @skade!.. I reckon that the community will be happy to see that we're looking after performance so much that we even have a performance analyser tool! :) In which direction do you see this growing? I've found a really good presentation that may help towards getting ideas of what we can include in a performance analyser too.

@skade
Copy link
Contributor Author

skade commented Jan 26, 2013

At the moment, its just a fun thing to play around. Basically, its a proof of concept on how to inject certain tests into a padrino binary call.

@DAddYE
Copy link
Member

DAddYE commented Jan 26, 2013

👍

dariocravero pushed a commit that referenced this pull request Jan 30, 2013
padrino-perf: watch out for problematic conditions in your app
@dariocravero dariocravero merged commit dd4453e into padrino:master Jan 30, 2013
@dariocravero
Copy link

I'm merging this in. It's a great start point and will force us towards building/improving a performance tool in the long run :)

@dariocravero
Copy link

@minad's memory usage script in #1018 brought up an idea... Quick & dirty draft. Wouldn't it be a great fit in somewhere in the perf tools?

@basex
Copy link
Contributor

basex commented Apr 17, 2013

I have used rack-mini-profiler in the past with padrino. It's quite useful and easy to use.
https://github.com/SamSaffron/MiniProfiler/tree/master/Ruby

@dariocravero
Copy link

@basex, I think that's a good idea. I haven't used it properly myself (just some particular tests) but I reckon we can easily integrate it. Feel free to push a PR anytime :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants