Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[10.x] Use faster hash algorithm (xxh128) - #45371

Merged
taylorotwell merged 1 commit into
laravel:masterfrom
KennedyTedesco:hash
Dec 20, 2022
Merged

[10.x] Use faster hash algorithm (xxh128)#45371
taylorotwell merged 1 commit into
laravel:masterfrom
KennedyTedesco:hash

Conversation

@KennedyTedesco

@KennedyTedesco KennedyTedesco commented Dec 20, 2022

Copy link
Copy Markdown
Contributor

As we are requiring PHP 8.1 or higher, what about starting to use xxh128 hashing on views?

Are there any further implications to consider with this change that I'm not aware of?

Twig has made this move successfully. See the following references for more information:

twigphp/Twig#3588

They are also using it for http cache store key:

symfony/symfony#47094

About the hash:

https://php.watch/versions/8.1/xxHash

@driesvints driesvints left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@driesvints

Copy link
Copy Markdown
Member

@KennedyTedesco some benchmarks are always appreciated when sending in performance PRs.

@KennedyTedesco

Copy link
Copy Markdown
Contributor Author

Specifically, about sha1 vs xxh128, the second one is way faster.

image

Reference: https://php.watch/articles/php-hash-benchmark

I haven't benchmarked the View component, and I don't have a starting point to do it yet (tips are welcome! :D). I'm willing to work on this by the end of the week.

@taylorotwell

Copy link
Copy Markdown
Member

I think this seems OK to me. The only breaking change I could think of would be if a third-party package was depending on the file names being in the exact format of a SHA-1 hash.

@taylorotwell
taylorotwell merged commit 1997729 into laravel:master Dec 20, 2022
@KennedyTedesco

Copy link
Copy Markdown
Contributor Author

I agree. Worth to document this in future release notes. Since we're working on a major version, I think we're fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants