Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97607 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6077 invoked from network); 9 Jan 2017 00:27:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jan 2017 00:27:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=oishi@giraffy.jp; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kazuo@o-ishi.jp; sender-id=pass Received-SPF: pass (pb1.pair.com: domain giraffy.jp designates 49.212.134.110 as permitted sender) X-PHP-List-Original-Sender: oishi@giraffy.jp X-Host-Fingerprint: 49.212.134.110 www7096uf.sakura.ne.jp Received: from [49.212.134.110] ([49.212.134.110:47147] helo=xii.giraffy.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9D/60-31343-CD8D2785 for ; Sun, 08 Jan 2017 19:27:10 -0500 Received: from localhost (localhost [127.0.0.1]) by xii.giraffy.jp (Postfix) with ESMTP id 436C77C2F01; Mon, 9 Jan 2017 09:27:04 +0900 (JST) X-Virus-Scanned: amavisd-new at giraffy.jp Received: from xii.giraffy.jp ([127.0.0.1]) by localhost (xii.giraffy.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zvEHnUlnHYi8; Mon, 9 Jan 2017 09:27:02 +0900 (JST) Received: from lil.giraffy.jp (aa024044.ppp.asahi-net.or.jp [110.5.24.44]) by xii.giraffy.jp (Postfix) with ESMTPSA id 9B72A7C2E5D; Mon, 9 Jan 2017 09:27:02 +0900 (JST) To: Yasuo Ohgaki Cc: Lauri =?iso-8859-1?Q?Kentt=E4?= , "internals\@lists.php.net" In-Reply-To: (Yasuo Ohgaki's message of "Mon, 9 Jan 2017 05:37:17 +0900") References: <7500b0c6a50baf49beac70ae01e8b50d@koti.fimnet.fi> <87o9zhju4d.fsf@lil.giraffy.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Date: Mon, 09 Jan 2017 09:27:02 +0900 Message-ID: <87k2a5jcx5.fsf@lil.giraffy.jp> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [PHP-DEV] Use decent entropy for uniqid($prefix, TRUE) From: kazuo@o-ishi.jp (Kazuo Oishi) 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