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

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

KennedyTedesco
Copy link
Contributor

@KennedyTedesco KennedyTedesco commented Dec 20, 2022

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

Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

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

Lgtm!

@driesvints
Copy link
Member

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

@KennedyTedesco
Copy link
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
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
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