Repository navigation
Look up relation types without rebuilding each type's definitions - #275
austinderrick wants to merge 1 commit into
Conversation
getRelationType() and getRelationTypeDefinition() rebuilt every relation type's definition array (and scanned the relation methods for each type) on each call. They now read the relation property directly. About 7x faster on a 140k-lookup benchmark; no behavior change.
|
No actionable comments were generated in the recent review. Walkthrough
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Merge Risk:
|
|
That seems like a very nice improvement, just want to make sure this won't affect the method type relations. |
|
Thanks for the PR @austinderrick. I'm not opposed to this, but it is a micro-optimisation. I don't feel that many people would reach 140,000 calls to those methods in a single request - it would be limited to maybe exports, perhaps. |
getRelationType()andgetRelationTypeDefinition()rebuilt every relation type's definition array, and scanned the relation methods for each type, on every call. They now read the relation property directly; method relations still go through the cached method lookup first.On a model with 11 property relations, 140,000
getRelationType()andgetRelationDefinition()calls took 1615 ms before and 233 ms after. The test suite gives the same result with and without the change.Summary by CodeRabbit