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

Calculate Bullet.app_root and IS_RUBY_19(former ruby_19?) once #548

Merged
merged 1 commit into from
Feb 22, 2021

Conversation

s-mage
Copy link
Contributor

@s-mage s-mage commented Feb 22, 2021

Gem::Version.new and Gem::Version#<=> took more than half of all the execution time of Bullet::Detector::NPlusOneQuery.call_association, and Bullet.app_root roughly 1/5 more. None of this is changed without the app restart, so it's safe to calculate them once.

Before:
Screenshot 2021-02-22 at 09 48 12

After:
Screenshot 2021-02-22 at 11 07 28

Backstory: I was profiling an app with N+1s in it and realized that Bullet eats a lot of time, and Gem::Version takes most of it. After this patch call_association method time changed from 1300ms to 400ms.

Last but not least, you are doing great job with this gem, I can't count how many times it helped me. Thank you!

Gem::Version.new and Gem::Version#<=> took more than half of all the
execution time of Bullet::Detector::NPlusOneQuery.call_association, and
Bullet.app_root roughly 1/5 more. None of this is changed without the
app restart, so it's safe to calculate them once.
@flyerhzm flyerhzm merged commit 072b8e5 into flyerhzm:master Feb 22, 2021
@flyerhzm
Copy link
Owner

@s-mage good catch, thank you

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.

2 participants