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

Replace Kernel#caller by the faster Kernel#caller_locations #25352

Merged
merged 1 commit into from Jun 10, 2016

Conversation

Projects
None yet
6 participants
@casperisfine

casperisfine commented Jun 10, 2016

While profiling our application boot time I noticed Module#delegate was a noticeable part of it:

capture d ecran 2016-06-10 a 11 37 58

Since caller as the reputation of being relatively inefficient I looked for alternatives and found caller_locations introduced in MRI 2.0. I wrote a small benchmark against 5.0.0rc1: https://gist.github.com/casperisfine/a40137b7b3ce0413d23f16cd7d1d8a05

The improvement is only 10ish % which I admit is not ground breaking, it's better against 4.2 though, because before the caller call wasn't bounded:

file, line = caller.first.split(':', 2)
line = line.to_i

But since it makes the code more readable, it believe it's worth it.

@rafaelfranca @sgrif thoughts?

@rails-bot

This comment has been minimized.

rails-bot commented Jun 10, 2016

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @kaspth (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rafaelfranca rafaelfranca merged commit 7fd477c into rails:master Jun 10, 2016

1 check failed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details

@rafaelfranca rafaelfranca deleted the Shopify:optimized-delegate branch Jun 10, 2016

rafaelfranca added a commit that referenced this pull request Jun 10, 2016

Merge pull request #25352 from Shopify/optimized-delegate
Replace Kernel#caller by the faster Kernel#caller_locations

@rafaelfranca rafaelfranca restored the Shopify:optimized-delegate branch Jun 10, 2016

@rafaelfranca

This comment has been minimized.

Member

rafaelfranca commented Jun 10, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment