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

Skip to content

[Serializer] make normalizers expose their vary-by characteristics, and use it for accurate caching #24436

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

Closed
nicolas-grekas opened this issue Oct 5, 2017 · 3 comments

Comments

@nicolas-grekas
Copy link
Member

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version 4.1

As discussed in #24206, we currently have a perf issue with serialization, related to the fact that our supports*() method are too dynamic and cannot be cached (supports can vary based on $context and/or $data, even if most normalizers vary only on "type($data)").

We spotted that if we allow normalizers to expose their vary-by characteristics, we might overcome the issue: we could add an new interface with a getProvidedTypes method, that would return an array keyed by PHP-type/class (with a wildcard to match all types), valued by a bitfield of "vary" consts: DATA | CONTEXT | TYPE.
This would tell the outside what the supports*() methods vary on, so that we could implement an accurate caching layer in Serializer.

@Simperfit
Copy link
Contributor

I'm willing to help on this @nicolas-grekas could you guide me a little bit ?

So we have to:

  • Create a new interface for the getProvidedTypes
  • Implement it and add the value in the return
  • use it in supports ?

@bendavies
Copy link
Contributor

@nicolas-grekas just wondering if you had any intention of working on this? otherwise i may try take a look with some others

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Apr 25, 2018

@bendavies I don't, please do, that'd be awesome :)

nicolas-grekas added a commit that referenced this issue Apr 29, 2018
… (dunglas, nicolas-grekas)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Serializer] Cache the normalizer to use when possible

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #24436   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | todo

Still a WIP:

* [x] Support `supportsDenormalization`

As this will dramatically improve the performance of the Serializer component, can we consider introducing this change in 4.1 @symfony/deciders?

ping @bendavies

Commits
-------

16f8a13 [Serializer] Generalize caching support a bit
c1e850f [Serializer] Cache the normalizer to use when possible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants