Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8c68d5

Browse filesBrowse files
committed
bug #32165 revert #30525 due to performance penalty (bendavies)
This PR was merged into the 4.3 branch. Discussion ---------- revert #30525 due to performance penalty | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | This reverts #30525, because it introduced a large performance penalty. Here is the effect of that PR when I upgrade my Api Platform project from 4.2.9 to 4.3.1: https://blackfire.io/profiles/compare/28bfbc61-3649-4896-bd03-7201239134cd/graph?settings%5Bdimension%5D=wt&settings%5Bdisplay%5D=landscape&settings%5BtabPane%5D=nodes&selected=Symfony%5CComponent%5CVarExporter%5CInternal%5CExporter%3A%3Aexport%403&callname=main() The reverted PR targeted master. This should go in 4.3? Commits ------- 3d37cc9 revert #30525 due to performance penalty
2 parents 32fd8e0 + 3d37cc9 commit e8c68d5
Copy full SHA for e8c68d5

File tree

1 file changed

+8
-27
lines changed
Filter options

1 file changed

+8
-27
lines changed

‎src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php
+8-27Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ class PropertyInfoCacheExtractor implements PropertyInfoExtractorInterface, Prop
2424
{
2525
private $propertyInfoExtractor;
2626
private $cacheItemPool;
27-
28-
/**
29-
* A cache of property information, first keyed by the method called and
30-
* then by the serialized method arguments.
31-
*
32-
* @var array
33-
*/
3427
private $arrayCache = [];
3528

3629
public function __construct(PropertyInfoExtractorInterface $propertyInfoExtractor, CacheItemPoolInterface $cacheItemPool)
@@ -110,34 +103,22 @@ private function extract(string $method, array $arguments)
110103
}
111104

112105
// Calling rawurlencode escapes special characters not allowed in PSR-6's keys
113-
$encodedMethod = rawurlencode($method);
114-
if (\array_key_exists($encodedMethod, $this->arrayCache) && \array_key_exists($serializedArguments, $this->arrayCache[$encodedMethod])) {
115-
return $this->arrayCache[$encodedMethod][$serializedArguments];
106+
$key = rawurlencode($method.'.'.$serializedArguments);
107+
108+
if (\array_key_exists($key, $this->arrayCache)) {
109+
return $this->arrayCache[$key];
116110
}
117111

118-
$item = $this->cacheItemPool->getItem($encodedMethod);
112+
$item = $this->cacheItemPool->getItem($key);
119113

120-
$data = $item->get();
121114
if ($item->isHit()) {
122-
$this->arrayCache[$encodedMethod] = $data[$encodedMethod];
123-
// Only match if the specific arguments have been cached.
124-
if (\array_key_exists($serializedArguments, $data[$encodedMethod])) {
125-
return $this->arrayCache[$encodedMethod][$serializedArguments];
126-
}
127-
}
128-
129-
// It's possible that the method has been called, but with different
130-
// arguments, in which case $data will already be initialized.
131-
if (!$data) {
132-
$data = [];
115+
return $this->arrayCache[$key] = $item->get();
133116
}
134117

135118
$value = $this->propertyInfoExtractor->{$method}(...$arguments);
136-
$data[$encodedMethod][$serializedArguments] = $value;
137-
$this->arrayCache[$encodedMethod][$serializedArguments] = $value;
138-
$item->set($data);
119+
$item->set($value);
139120
$this->cacheItemPool->save($item);
140121

141-
return $this->arrayCache[$encodedMethod][$serializedArguments];
122+
return $this->arrayCache[$key] = $value;
142123
}
143124
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.