Closes #8731 Speed up sites by reducing WP Rocket's overhead on every request - #8736
Closes #8731 Speed up sites by reducing WP Rocket's overhead on every request#8736remyperona wants to merge 1 commit into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 10 |
🟢 Coverage 83.33% diff coverage
Metric Results Coverage variation Report missing for e53daf61 Diff coverage ✅ 83.33% diff coverage (50.00%) Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (e53daf6) Report Missing Report Missing Report Missing Head commit (7de35f0) 47715 22636 47.44% Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#8736) 18 15 83.33% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Note Generated by the AI delivery pipeline (qa-engineer · Claude Opus 4.8). QA: ✅ PASS Backend-only change (no UI surface); validated via code analysis + direct PHP execution of the new test suite (local PHP 8.2.29 binary, outside Docker).
Evidence for 1–3:
Note on AC #4 (full suite): the full local unit suite is blocked by a pre-existing, repo-wide issue unrelated to this PR: Blockers: none. |
|
Note Generated by the AI delivery pipeline (lead-reviewer · Claude Opus 4.8). Review: ✅ PASS Verified: all 3 Ran locally: PHPCS clean (0 violations) and PHPStan clean (0 errors) on all 4 changed production files; all 14 new unit tests pass (22 assertions, Noted the CI-red on unit tests/PHPStan is the pre-existing, repo-wide Blockers: none. Nice-to-haves:
|
559cbdf to
96ee92c
Compare
DefinitionAggregate (League Container v4, vendored) answers has()/getDefinition() with an O(N) linear scan. Plugin::load() eagerly resolves ~150 subscribers per request, forcing most of the ~51 ServiceProviders to register, so this scan runs hundreds of thousands of times per request. Add WP_Rocket\Engine\Container\IndexedDefinitionAggregate, extending the vendored DefinitionAggregate with a hashmap index keyed by normalised alias. has()/getDefinition() become O(1); all other behaviour (first-match-wins on duplicate add(), setContainer() on read, exception message parity, hasTag()) is unchanged. Inject it at the 3 existing Container instantiation sites (inc/main.php, Activation::activate_plugin(), Deactivation::deactivate_plugin()). No file under inc/Dependencies/ is touched. Fixes #8731 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
96ee92c to
7de35f0
Compare
Performance validationMeasured on wp-env (PHP 8.3.33, real provider set N = 344 services), stock
¹ |
Closes #8731
Description
WP Rocket adds a fixed delay (~90ms) to every request — including REST API and AJAX calls, not just cached pages — because its internal service lookups scan every registered service one by one. This change makes those lookups instant, so the delay is removed on every request.
Type of change
Detailed scenario
What was tested
Unit tests for the new lookup class (14 cases) plus an integration test that boots the real container — all passing on CI.
How to test
Run the test suite, or profile any request before and after: the repeated internal lookup cost is gone and behaviour is unchanged.
Affected Features & Quality Assurance Scope
Internal service resolution during WP Rocket startup, which runs on every request. No user-facing or UI changes.
Technical description
Adds an indexed container definition aggregate so
has()andgetDefinition()run in constant time instead of scanning all definitions. All existing behaviour is preserved. No vendored files are modified.Documentation
None.
New dependencies
None.
Mandatory Checklist
Code validation
Unticked items justification
All applicable items are ticked.
Additional Checks