Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[performance] provide a simpler name converter than MetadataAwareNameConverter #35085

Copy link
Copy link
Closed
@bastnic

Description

@bastnic
Issue body actions

Description
I dug a lot it Symfony internals lastly and the name converter stack was very costly. I reduced it a lot with #35041... Then I realized than I don't need at all a name converter.

The default one is MetadataAwareNameConverter, that allow a fallbackNameConverter. But the fallback is called ONLY after having grab all the metadata, checked for a SerializerName. I never saw a project using this attribute, and it troubles me that it costs so much. So just giving a simpler NameConverter as fallback is not enough because the worse already happened.

I tried another way: replacing MetadataAwareNameConverter completely. It seems to work flawlessly and gives me a 11% performance improvement (AFTER the previously mentioned patch, so more than a 25% gain from master)

image (1)

<?php
namespace Lib\Core\Serializer\NameConverter;

use Symfony\Component\Serializer\NameConverter\NameConverterInterface;

/**
 * Do nothing name converter
 */
class NullNameConverter implements NameConverterInterface
{
    public function normalize($propertyName)
    {
        return $propertyName;
    }
    public function denormalize($propertyName)
    {
        return $propertyName;
    }
}
services:
    serializer.name_converter.metadata_aware: '@Lib\Core\Serializer\NameConverter\NullNameConverter'

Questions:

  • Did I miss something that I could break with that?
  • Should a simpler Name Converter should be added in Symfony?
  • Should it be the default? Or as least purposed by default
  • Maybe add a pass somewhere "hi you are not using any SerializerName and you didn't provide a NameConverter fallback, switching to NullNameConverter"?

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.