Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle] Add cache configuration for PropertyInfo #31452

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

Merged
merged 1 commit into from
May 13, 2019

Conversation

alanpoulain
Copy link
Contributor

@alanpoulain alanpoulain commented May 9, 2019

Q A
Branch? 4.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations?
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

The PropertyInfoExtractor was not cached by default but the class to do it was surprisingly here, unused.

I've added the configuration to enable it by default when it's not the development environment.

I haven't added the warmup part because there are too much arguments for the methods (class, property, context).

It will be a big boost for the performance! For this code:

$book = $this->serializer->deserialize('{"id":3,"reviews":[{"id": 7, "body": "This book is fantastic!", "rating": 9, "letter": "A", "publicationDate": "2019"}],"isbn":"978-0-5533-9243-2","title":"Fool\'s Assassin","description":"A famous saga","author":"Robin Hobb","publicationDate":"2014"}', Book::class, 'json');
$this->serializer->serialize($book, 'json');

We obtain this:

image

The Blackfire comparison is here: https://blackfire.io/profiles/compare/2c746d26-320a-4aab-80ef-7276c2e92b96/graph

@dunglas
Copy link
Member

dunglas commented May 10, 2019

Usually, we don't accept performance improvements (even huge ones like this) as bug fixes. Maybe could it be included in the next 4.3 beta (it's already late, but it's a huge improvement ; ping @symfony/deciders), but definitely not in 4.2.

It looks like a introduced this class a while ago... and forgot to open the follow up PR with the FrameworkBundle wiring 😕. Thanks for finding this.

@alanpoulain
Copy link
Contributor Author

The test failures seem unrelated.

@nicolas-grekas nicolas-grekas added this to the 4.3 milestone May 11, 2019
@alanpoulain alanpoulain force-pushed the cache-configuration-property-info branch from c04e598 to 7290c4a Compare May 11, 2019 10:22
@alanpoulain alanpoulain changed the base branch from 4.2 to 4.3 May 11, 2019 10:23
@alanpoulain
Copy link
Contributor Author

Rebased for 4.3.

@alanpoulain
Copy link
Contributor Author

Should I take account of @dunglas's comment:

IIRC, it's preferred to use XML for the service definition and to remove it in the extension is appropriate, to allow IDEs like PHPStorm to detect the services. Not sure if it's really matter here has it's the same interface that is implemented, it's more for consistency.

And do the same for ClassMetadataFactory (I don't think it's a BC break)?

@nicolas-grekas
Copy link
Member

Yes please.

@alanpoulain alanpoulain force-pushed the cache-configuration-property-info branch from e685d6f to 05bb11c Compare May 11, 2019 13:25
@alanpoulain
Copy link
Contributor Author

Changes done.

@fabpot fabpot force-pushed the cache-configuration-property-info branch from 05bb11c to 17f6225 Compare May 13, 2019 06:44
@fabpot
Copy link
Member

fabpot commented May 13, 2019

Thank you @alanpoulain.

@fabpot fabpot merged commit 17f6225 into symfony:4.3 May 13, 2019
fabpot added a commit that referenced this pull request May 13, 2019
…Info (alanpoulain)

This PR was squashed before being merged into the 4.3 branch (closes #31452).

Discussion
----------

[FrameworkBundle] Add cache configuration for PropertyInfo

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? |
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

The PropertyInfoExtractor was not cached by default but the class to do it was surprisingly here, unused.

I've added the configuration to enable it by default when it's not the development environment.

I haven't added the warmup part because there are too much arguments for the methods (class, property, context).

It will be a big boost for the performance! For this code:

```php
$book = $this->serializer->deserialize('{"id":3,"reviews":[{"id": 7, "body": "This book is fantastic!", "rating": 9, "letter": "A", "publicationDate": "2019"}],"isbn":"978-0-5533-9243-2","title":"Fool\'s Assassin","description":"A famous saga","author":"Robin Hobb","publicationDate":"2014"}', Book::class, 'json');
$this->serializer->serialize($book, 'json');
```

We obtain this:

![image](https://user-images.githubusercontent.com/10920253/57487994-2874d000-72b2-11e9-92a2-28b14a038194.png)

The Blackfire comparison is here: https://blackfire.io/profiles/compare/2c746d26-320a-4aab-80ef-7276c2e92b96/graph

Commits
-------

17f6225 [FrameworkBundle] Add cache configuration for PropertyInfo
@fabpot fabpot mentioned this pull request May 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants