Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More optimizations on respond_to after a profile and benching:
App with simple respond_to: def index respond_to do |format| format.html format.xml format.json end end On JRuby (after complete hotspot warmup) -- 8% improvement: 550 requests per second after this commit 510 requests per second with old method_missing technique On MRI (8% improvement): 430 requests per second after this commit 400 requests per second with old method_missing technique
- Loading branch information
4f043a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing you might want to benchmark is using something like:
def #{sym} custom(Mime::#{const}) { |format| yield(format) } end
In DM we benchmarked this as faster than using &block explicitly.
4f043a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a wycats in my railz.
Help pls.
4f043a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dkubb has a great idea. Anytime that you use &block ruby makes a new Proc from the parameter, even when no block is given. This can slow you down.
4f043a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not always. http://gist.github.com/11326
4f043a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually already do that optimisation with active record (for count, all, etc) and it did make a difference there, but as pratik mentions it’s not quite so simple.
There’s also some subtle differences between the two with some uses (have a look at the core list around september).
If the benchmarks show it faster here, let’s go for it. but it’s not ‘free performance’
4f043a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, going to have to do a little research to figure out when it is better and when it is not.