Fabien Potencier 9f3798bafd minor #3588 Use faster hash algorithm (xxh128) on PHP 8.1+ (GromNaN)
This PR was merged into the 2.x branch.

Discussion
----------

Use faster hash algorithm (xxh128) on PHP 8.1+

Twig uses the `hash` function at runtime to convert template paths class names, each time a template is loaded. In a large project with a high granularity of templates (hundreds of `include` per page), this can become the most time consuming function as reported by Blackfire:
<img src="https://user-images.githubusercontent.com/400034/140626949-c4876b7d-c91c-4e07-b2f4-8ebbcaa72f61.png" width="220">

To optimise this use-case, [PHP 8.1 supports the xxHash hash algorithms](https://php.watch/versions/8.1/xxHash). `xxh128` is 60x faster that `sha256` according to the [benchmarks](https://php.watch/articles/php-hash-benchmark), and guarantee a very [low risk of collision](http://cyan4973.github.io/xxHash/).

I'm not able to test with PHP 8.1 for now. Before going further I would like to validate performance impact on a large list of file names.

Commits
-------

4fcc6b1c Use faster hash algorithm (xxh128) on PHP 8.1
2021-12-16 11:53:56 -08:00
2021-11-29 07:20:05 +02:00
2021-11-08 13:29:10 +01:00
2021-05-12 09:37:17 +02:00
2021-10-04 11:04:25 +02:00
2021-11-25 14:44:38 +01:00
2021-05-20 16:22:31 +02:00
2020-12-30 09:16:13 +01:00

Twig, the flexible, fast, and secure template language for PHP
==============================================================

Twig is a template language for PHP.

Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.

Sponsors
--------

.. raw:: html

    <a href="https://blackfire.io/docs/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
        <img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
    </a>

More Information
----------------

Read the `documentation`_ for more information.

.. _documentation: https://twig.symfony.com/documentation
Languages
PHP 99.9%