Performance optimizations#400
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #400 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 184 221 +37
===========================================
Files 11 11
Lines 500 599 +99
===========================================
+ Hits 500 599 +99 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Performance-focused update to the DI container implementation, adding internal caching and restructuring definition preparation to reduce overhead in common code paths.
Changes:
- Added caching for
Container::has()results andCompositeContainerdelegate lookups. - Reworked definition preparation/validation paths (including a no-validation fast path) and reduced redundant work in
build(). - Expanded benchmarks and added a unit test for empty-string class definitions.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/Container.php |
Adds has() caching, refactors definition preparation/validation, and optimizes build path. |
src/CompositeContainer.php |
Adds lookup caching for faster delegate resolution. |
tests/Unit/ContainerTest.php |
Adds regression test for empty string definition validation. |
tests/Benchmark/ContainerBench.php |
Adds no-validation benchmark variants for construct/lookups. |
tests/Benchmark/TypicalUsageBench.php |
Introduces a new benchmark suite covering typical container usage scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
� Conflicts: � src/Container.php
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| */ | ||
| public function shouldValidate(): bool; | ||
|
|
||
| /** | ||
| * @return int Maximum number of cached `has()` results. `0` disables the cache. | ||
| */ | ||
| public function getHasCacheLimit(): int; | ||
|
|
There was a problem hiding this comment.
Adding getHasCacheLimit() to ContainerConfigInterface is a backwards-incompatible API change: any downstream code that provides its own ContainerConfigInterface implementation will now fail to compile until it adds this method. The PR metadata says “Breaks BC? ❌”; either adjust that statement / release notes accordingly, or avoid changing the existing interface (e.g., add a separate optional interface and fall back to the default limit when the method is absent).
|
Should be re-evaluated after yiisoft/definitions#114 |
Performance optimizations. Overall results compared to
master:What was done:
There's a BC break because it makes a cache cap for
has()configurable by adding it to the interface.