Commit bec315e
committed
Cache constructor signatures in serviceCache for cross-request persistence
getCallableConstructorSignature() was the hottest injector code path
(8.1ms/req self CPU) but only cached results in a per-instance PHP
array that was rebuilt every request. The serviceCache (which can be
backed by a precomputed PHP file loaded via OPcache) was not consulted.
This meant the build step `service:precompute_service_cache` — which
calls warmCache for every container key — produced an effectively empty
cache file, since constructor signatures were never stored in it.
Changes:
- CachingClassInspector::getCallableConstructorSignature now checks
serviceCache as an L2 cache behind the per-instance constructorCache.
Only array results (valid signatures) are persisted; false/null
(non-public/missing constructors) are kept in the per-instance cache
only, since those classes are resolved from the container rather than
auto-created.
Measured impact (30-request Excimer profiles on a storefront product
page, with the precomputed PHP file cache active):
- ClassInspector::getReflectionClass: 8.4 → 2.8 ms/req (-67%)
- Total injector self CPU: 18.1 → 12.4 ms/req (-31%)
- Total request CPU: 267 → 215 ms/req (-20%, t=-5.24)1 parent ba488a6 commit bec315e
4 files changed
Lines changed: 44 additions & 7 deletions
File tree
- .phpstan
- src
- Reflection
- tests/Reflection
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | 33 | | |
40 | 34 | | |
41 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
202 | 201 | | |
203 | 202 | | |
204 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
112 | 120 | | |
113 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
114 | 125 | | |
115 | 126 | | |
116 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
71 | 88 | | |
72 | 89 | | |
73 | 90 | | |
| 91 | + | |
74 | 92 | | |
75 | 93 | | |
76 | 94 | | |
| |||
82 | 100 | | |
83 | 101 | | |
84 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
85 | 116 | | |
86 | 117 | | |
| 118 | + | |
87 | 119 | | |
88 | 120 | | |
89 | 121 | | |
| |||
94 | 126 | | |
95 | 127 | | |
96 | 128 | | |
| 129 | + | |
97 | 130 | | |
98 | 131 | | |
99 | 132 | | |
| |||
0 commit comments