-
-
Notifications
You must be signed in to change notification settings - Fork 906
Any ideas on how we could speed up ResourceClassResolver? #1068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
if the slow part is the custom iterator, than maybe using ResourceMetadataFactoryInterface directly (with a special instance that is configured to "fail fast", if cache didnt hit) could help. Or extending the ResourceNameCollectionInterface to have a "contains" method. |
I think the slow part is getResourceClass. Or, it's not that slow but it gets called a lot: Blackfire |
Closing this because I'm not sure we can do anything about that. #212 |
I'm allowing myself to reopen it because Just adding a local cache clear everything: if (isset($this->localMostSpecificResourceClassCache[$targetClass])) {
return $this->localMostSpecificResourceClassCache[$targetClass];
}
foreach ($this->resourceNameCollectionFactory->create() as $resourceClassName) {
if (!is_a($targetClass, $resourceClassName, true)) {
continue;
}
if (null === $mostSpecificResourceClass || is_subclass_of($resourceClassName, $mostSpecificResourceClass)) {
$mostSpecificResourceClass = $resourceClassName;
}
}
if (null === $mostSpecificResourceClass) {
throw new \LogicException('Unexpected execution flow.');
}
$this->localMostSpecificResourceClassCache[$targetClass] = $mostSpecificResourceClass; Before : Diff : |
This class gets called a lot. I already speed up things by ~20% by avoiding the
resourceNameCollectionFactory->create()
call (quick & dirty):Though,
getResourceClass
is still slow \o/. I'm not sure that we can find anykey
to cache our$value
though.I think that by removing
try/catch
we could improve it a bit, but this would break a lot of things (returningnull
instead of throwing anInvalidArgumentException
). WDYT?Any ideas appreciated!
The text was updated successfully, but these errors were encountered: