twigphp / Twig

Twig, the flexible, fast, and secure template language for PHP
https://twig.symfony.com/
BSD 3-Clause "New" or "Revised" License
8.06k stars 1.24k forks source link

Performance regression since v3.9.0 #4103

Open vbrouet opened 1 month ago

vbrouet commented 1 month ago
          What is the performance impact of the runtime check combined with yield ?

Originally posted by @stof in https://github.com/twigphp/Twig/pull/3999#pullrequestreview-1875847101

Hello,

While investigating a performance regression in a symfony app (6.4) I found that the source was twig/twig version 3.9.0.

I made a small repro and used git bissect to find this pull request #3999 where performance is briefly discussed.

After some trial and error, performance was partially restored by passing 'use_yield' => true to the twig Environment constructor.

Not sure if this is a bug but in certain cases the performance impact was pretty huge (from 800 ms to 2200ms).

j0r1s commented 4 weeks ago

Probably related to this discussion I opened a few days ago