-
Notifications
You must be signed in to change notification settings - Fork 53
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
Optimize association eager loading for a single model #80
Conversation
…ations for a single model
# Conflicts: # benchmark/main.rb
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.
🚢
benchmark/single_model_benchmark.rb
Outdated
require_relative 'performance_helper' | ||
|
||
ForkingBenchmark.ips do |x| | ||
x.time = 5 |
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.
is there any reason for 5 and 2 or just because they sounded fine?
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.
They were copied from the benchmark that landed in #77. Looks like these are the defaults for benchmark-ips though so I'll remove them.
@@ -2,6 +2,7 @@ | |||
|
|||
### 3.0.3 | |||
- Optimize association eager loadable checks by caching information on the association's reflection. | |||
- Optimize association eager loading if we're only eager loading associations for a single model. |
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.
I assume you havent released the gem, otherwise this should go into 3.0.4.
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.
Yup. I haven't released 3.0.3 yet.
This change optimizes automatic eager loading when there's only a single model in the auto include context by just doing regular Rails association loading. This bypasses a bunch of extra work that the Rails preloader does. In benchmarks this reduces object allocations by 5% but does not result in a statistically significant throughput change (even though it was faster by about 10% in all of the experiments I ran):
I added a new benchmark as part of this change so I factored out some commonality between the benchmarks and added a script for running all benchmarks.
@fgarces - you're prime