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

Closed
@nicolas-grekas

Description

@nicolas-grekas
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions