Skip to content

Low speed render #4676

@PowerMakc

Description

@PowerMakc

Hello. I recently rewrote my site to another engine and installed Twig 3 there. I found that the render file function with a minimum number of HTML tags and without any attachments or data is rendered for a very long time - 70 ms. While loading Twig itself takes only 14 ms. It is the render function that slows down the site a lot. Tell me where to look for the problem?

nginx, php - 8.4, twig - 3, cache = off, ssd speed 1.5Gb/s

public static function twig($viewDir = null, $getShared = true)
{
$appPaths = new \Config\Paths();
$appViewPaths = $viewDir ?? $appPaths->viewDirectory;

    $loader = new \Twig\Loader\FilesystemLoader($appViewPaths);

    $twig = new \Twig\Environment($loader, [
        'debug' => false,
        'cache' => false,
        'autoescape' => 'html',
        'charset' => 'utf-8',
    ]);

    $twig->addFilter( new \Twig\TwigFilter('is_array', 'is_array') );

    return $twig;

}

page.tpl

{{ text|raw }}

In the view() function I call twig:

$twig = \Config\Services::twig(); // 14ms

$tpl_data = [];
$template = $twig->render('page.tpl', $tpl_data); // 70ms

If I use insertion into the index.tpl (extends), the time increases to 200ms
The previous project had the same templates and they were loaded in !!! 9ms with insertion into the index.tpl

Previous version of the site - nginx, php 7.4, twig 2.15.5, cache = off

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions