amp-library icon indicating copy to clipboard operation
amp-library copied to clipboard

Performance: Instanciating the AMP class takes 120ms

Open GromNaN opened this issue 7 years ago • 2 comments

Hello,

Above all, I would like to thank you for the high quality and reliability of this library. I'm using it for on demand conversion of my HTML pages to AMP, in a Symfony application.

But just after the deployment this feature on production, I noticed a huge performance slump. Average response time went from 90ms to 210ms. The only fact of instantiating the AMP class takes 120ms, even if it is not used. image

✗ blackfire run php amp-console amp:convert sample-html/sample-html-fragment.html

Here is a Blackfire profile that spot the glutton:

image

We can clearly see that the init of the library creates 18679 instances ofLullabot\AMP\Validate\ParsedAttrSpec and makes 93545 calls to Lullabot\AMP\Validate\ParsedAttrSpec::getSpec().

Is there any way to make a lighter HTML conversion, without the huge performance cost of loading the validation rules ?

GromNaN avatar Oct 06 '17 18:10 GromNaN

we're experiencing the same issue here

killerwolf avatar Apr 16 '18 12:04 killerwolf

same issues here, does anyone find a fix for that?

guiajlopes avatar Oct 30 '18 08:10 guiajlopes