Skip to content

Look up relation types without rebuilding each type's definitions - #4

Closed
austinderrick wants to merge 1 commit into
developfrom
perf/relation-type-fast-path
Closed

austinderrick wants to merge 1 commit into
developfrom
perf/relation-type-fast-path

Conversation

@austinderrick

Copy link
Copy Markdown

getRelationType() and getRelationTypeDefinition() 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.

  • Benchmark (model with 11 property relations, 140k getRelationType() + getRelationDefinition() calls): 1615 ms before, 233 ms after.
  • Storm suite: 984 tests, same result before and after. phpcs and PHPStan clean.

Fork stopgap ahead of an upstream wintercms/storm PR.

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.
@austinderrick
austinderrick force-pushed the perf/relation-type-fast-path branch from 4d03f10 to da779cd Compare November 5, 2026 20:39
@austinderrick
austinderrick changed the base branch from wip/1.3 to develop November 5, 2026 20:39
@austinderrick

Copy link
Copy Markdown
Author

Moved to wintercms#275.

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.

1 participant