Unleashing the power of Symfony 6.3 with Blackfire

By Thomas di Luccio, on Jun 14, 2023

Open source software (OSS) has become the backbone of the tech industry, powering countless applications and services. In today’s fast-paced technology landscape, the importance of performance OSS cannot be overstated.

As more and more users leverage OSS in their projects and day-to-day activities, high-performance frameworks and libraries become essential to maintain speed, efficiency, and overall user satisfaction.

Performance is a critical aspect of OSS because it directly impacts the end user’s experience. Faster, more efficient software means that users can accomplish their goals faster, with less frustration and fewer barriers.

Not only does this benefit the industry by accelerating development cycles and driving innovation, but it also helps reduce the environmental footprint of digital infrastructure, aligning with global sustainability goals.

This is why we are particularly thrilled to reveal the role Blackfire played in the release of Symfony 6.3. Many of the performance optimizations introduced with this release were made possible using our unique Observability solution.

Translation message extraction optimization:

In Symfony 6.3, the translation:extract command, which scans application files for translatable content to update translation files, has been optimized. This command can be slow for large codebases, as it employs an Abstract Syntax Tree (AST) to parse PHP file contents.

To enhance the extraction process, Symfony 6.3 now only generates an AST for PHP files with translation-related content. A speedy regular expression is used to detect the presence of elements like ->trans(...), and if they’re absent, the file’s contents aren’t parsed.

This update, contributed by Mathieu Santostefano, has resulted in a more than 70% reduction in the time it takes to run the command in a project with 100 000 PHP files.

Possible deactivation of the XML Dumping of the Container

Symfony 6.3 introduces a new configuration option, debug.container.dump, to address performance issues in large applications during debug mode. Previously, the service container information was compiled into an XML file used by various commands, but this process could take a few seconds for extensive applications and produce a 20 MB file. For some projects and developers, the benefits of the XML file don’t justify the performance decrease.

Ruud Kamphuis’ contribution allows setting debug.container.dump to false, and lets developers disable dumping container information into an XML file, potentially improving performance in debug mode for sizable applications.

Optimizing normalizers and denormalizers:

Tugdual Saunier, who used to work for Blackfire, improved the normalizers/denormalizers, which are responsible for converting objects into arrays and vice versa. A new method, getSupportedTypes(), has been added, allowing normalizers/denormalizers to declare the object types they can handle and their ability to be cached.

Instead of always calling the supportsNormalization() and supportsDenormalization() methods, Symfony now tries to call this new method first.

This change can significantly boost performance in certain applications. In tests, some applications experienced more than an 80% reduction in the time spent on getNormalizer() calls.

And many more optimizations!

This post on the Symfony blog details all the performance improvements introduced with Symfony 6.3. We are proud that Blackfire helped optimize Symfony even more.

Markus Staab is among the contributors to the latest Symfony releases. Markus improved the GlobResource class by reordering some conditions, ultimately reducing the I/O instructions by 20%! You could check his Pull Request (PR), and the before/after profiles comparison.

Markus is an avid Blackfire user and made numerous contributions to multiple open-source projects. We will present him and his work in an upcoming blog post.

In the meantime, you can find him on Twitter @markusstaab, and support his work on GitHub.

Blackfire is committed to OSS and OSS Maintainers

Blackfire is a resolute advocate of open-source software and recognizes the hard work and dedication of OSS maintainers. To show our support, we offer free licenses to OSS maintainers, ensuring that they have access to the best profiling tool to enhance their projects.

By providing these resources, Blackfire aims to foster a thriving open-source community and contribute to the development of innovative, high-quality software that benefits everyone.

Know more about our Open-Source program and apply on our website: blackfire.io/open-source

Please join the conversation

We hope you are as excited as we are about the new performance improvements introduced in Symfony 6.3. This release demonstrates the power of collaboration and innovation in the open-source community, leading to a brighter future for users, developers, and the planet.

We invite you to continue the conversation on Slack, Reddit, and Twitter. Share your experiences with Symfony and Open-Source contributions, ask questions, and engage with the community to further explore the possibility of performance improvement. Together, let’s continue to push the boundaries of open-source software and create a more efficient, sustainable digital world.

Happy Performance Optimization!

Thomas di Luccio

Thomas is a Developer Relations Engineer at Platform.sh for Blackfire.io. He likes nothing more than understanding the users' needs and helping them find practical and empowering solutions. He’ll support you as a day-to-day user.