why is non-crypto hashes excluded from /ext/hash/bench.php ?

php.internals

Hans Henrik Bergan

5 years ago
 

Nikita Popov

5 years ago
Are they? When I run the script, I see things like crc and fnv show up. How did you draw the conclusion that non-crypto hashes are not included? Nikita

Hans Henrik Bergan

5 years ago
@Nikita Popov
> How did you draw the conclusion that non-crypto hashes are not included?
yeah i know they're there when you run them, but if you look at the benchmarks in the source code, from line 4 - 71, all the non-crypto hashes are absent there, https://github.com/php/php-src/blob/master/ext/hash/bench.php#L4 On Mon, 26 Oct 2020 at 10:49, Nikita Popov <nikita.ppv@gmail.com> wrote:

Christoph Becker

5 years ago
On 26.10.2020 at 11:16, Hans Henrik Bergan wrote:
> @Nikita Popov > >> How did you draw the conclusion that non-crypto hashes are not included? > > yeah i know they're there when you run them, but if you look at the > benchmarks in the source code, from line 4 - 71, all the non-crypto > hashes are absent there, > https://github.com/php/php-src/blob/master/ext/hash/bench.php#L4
Well, these results look a bit old. Maybe remove that?
-- Christoph M. Becker

Hans Henrik Bergan

5 years ago
@Christoph M. Becker haha that's probably it, i guess that long ago PHP didn't have any non-crypto hash algos, one of the results read "256MB Windows 2000" when was the last time someone rolled a 256MB ram windows 2000? (am rolling some 128MB ram VPS's, but rolling Windows with such amounts of ram would be insane today) nevermind then, thanks for pointing it out (also seems Nikita Popov just removed the old results from master) .. another thing, imo /ext/hash/bench.php should hash a constant size, not some size that change every time the code changes, in my opinion $data = file_get_contents(__FILE__); should be replaced with something like $data = str_repeat("\x00", 2 * 1024); - the old size of bench.php (before Nikita's edit) was 2240 bytes, and 2*1024 is pretty close, 2048 bytes - if you for some reason want random bytes instead of 0, i guess random_bytes() can be used instead, but i don't think it should make any difference in the benchmarked parts

Hans Henrik Bergan

5 years ago
PR to make it "a constant number of bytes to hash" here: https://github.com/php/php-src/pull/6386 .. was bugging me