Re: Use decent entropy for uniqid($prefix, TRUE)
| From: | Kazuo Oishi | Date: | Mon, 09 Jan 2017 00:27:02 +0000 |
| Subject: | Re: Use decent entropy for uniqid($prefix, TRUE) | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97607@lists.php.net to get a copy of this message | ||
Hi,
>>> [original uniqid() using php_combined_lcg]
>>> $ time ./php_uniqid_orig -r 'for($i=0; $i<1000000;$i++)
>>> uniqid("",true);'
>>> real 0m0.366s
>>> user 0m0.350s
>>> sys 0m0.010s
>>>
>>> [your php_random_bytes_throw version (commit
>>> 48f1a17886d874dc90867c669481804de90509e8)]
>>> $ time ./php_uniqid_yohgaki -r 'for($i=0; $i<1000000;$i++)
>>> uniqid("",true);'
>>> real 0m4.509s
>>> user 0m0.430s
>>> sys 0m4.070s
>>>
>>> [Lauri's php_random_int version]
>>> $ time ./php_uniqid_lauri -r 'for($i=0; $i<1000000;$i++)
>>> uniqid("",true);'
>>> real 0m0.664s
>>> user 0m0.260s
>>> sys 0m0.400s
>>
>> Interesting result. AFAIK, I didn't get significant difference when I made
>> the patch.
>> What is your system? It seems your PRNG is significantly slow.
Core i7-5600U 2.60GHz
Linux version 4.8.10, gcc version 4.9.3, gentoo
> The performance will be improved by reducing multiple PRNG calls to 1.
> I'll modify patch later, could you test it with your system?
Sure. But as you said, Lauri's version would be optimal.
--
Kazuo Oishi