-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[ObjectMapper] cache attributes in memory #61497
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
Conversation
src/Symfony/Component/ObjectMapper/Metadata/ReflectionObjectMapperMetadataFactory.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/ObjectMapper/Metadata/ReflectionObjectMapperMetadataFactory.php
Outdated
Show resolved
Hide resolved
|
The table in the PR header does not match our standards |
I understood that as long as MIT was present this was ok, I removed the columns that are not relevant... |
Spomky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the $reflectionClassCache keys are only strings, the SplObjectStorage is not needed right?
(because of $this->reflectionClassCache[$object::class] it will throw an exception)
src/Symfony/Component/ObjectMapper/Metadata/ReflectionObjectMapperMetadataFactory.php
Outdated
Show resolved
Hide resolved
Spomky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good iterative improvement. To get the best performance, this cache should be generated in the DIC cache and injected at instantiation.
|
As this is a perf improvement, it cannot be considered as a bug and as such, it will be merged in 7.4. |
|
Thank you @soyuka. |
Profile:
phpbench
```php namespace Symfony\Component\ObjectMapper\Benchmarks;use PhpBench\Attributes as Bench;
use Symfony\Component\ObjectMapper\ObjectMapper;
use Symfony\Component\ObjectMapper\Tests\Fixtures\A;
use Symfony\Component\ObjectMapper\Tests\Fixtures\C;
use Symfony\Component\ObjectMapper\Tests\Fixtures\D;
#[Bench\BeforeMethods('setUp')]
class ObjectMapperBench
{
private ObjectMapper $objectMapper;
private A $sourceObject;
}