Magento InterfaceValidator improvements

By Jérôme Vieilledent, on Apr 21, 2020

In Magento 2, the InterfaceValidator is a component which role is to technically validate the plugins loaded in the system, by e.g. validating the plugins methods parameters and their type, or their origin method name (which corresponds to the loading order of each plugin). This class is an important axis of Magento plugin system and is called every single time a plugin is mentioned. It is therefore critical for it to be as optimized as possible.

In this context, Łukasz Bajsarowicz, who contributes to the Magento ecosystem on a regular basis, started to profile the InterfaceValidator with the help of Blackfire. He implemented a few tweaks e.g.:

  • Changing the order of conditions;
  • Replacing the Elvis operator (?:) by the null coalescing operator (??);
  • Replacing substr comparisons with strpos.

This may seem minimal, but it improved the overall performance of the component by 21%! Łukasz opened a pull-request on Magento

Thanks Łukasz for making Magento faster!

Jérôme Vieilledent

As a Developer Advocate, Jérôme is all about spreading the love! His technical/development background enable him to talk as a peer to peers with our developer users. You’ll read his tips and advices on performance management with Blackfire. And he’ll support you as a day-to-day user.