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):
Goldiloader: Single model's association
2.287k (± 8.5%) i/s - 22.848k in 10.069578s
Goldiloader: Single model's association optimized
2.536k (± 7.9%) i/s - 25.194k in 10.004004s
Comparison:
Goldiloader: Single model's association optimized: 2535.6 i/s
Goldiloader: Single model's association: 2287.4 i/s - same-ish: difference falls within error
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.
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