From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14649 invoked by alias); 14 Jun 2013 12:11:05 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 14537 invoked by uid 89); 14 Jun 2013 12:10:58 -0000 X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,DATE_IN_PAST_12_24,FREEMAIL_FROM,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,SPF_NEUTRAL,TW_DQ,TW_VD autolearn=no version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from popelka.ms.mff.cuni.cz (HELO popelka.ms.mff.cuni.cz) (195.113.20.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 14 Jun 2013 12:10:57 +0000 Received: from domone.kolej.mff.cuni.cz (popelka.ms.mff.cuni.cz [195.113.20.131]) by popelka.ms.mff.cuni.cz (Postfix) with ESMTPS id D838F69490; Fri, 14 Jun 2013 14:10:50 +0200 (CEST) Received: by domone.kolej.mff.cuni.cz (Postfix, from userid 1000) id C35C95FB95; Fri, 14 Jun 2013 01:01:22 +0200 (CEST) Date: Fri, 14 Jun 2013 12:11:00 -0000 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: bugdal at aerifal dot cx Cc: glibc-bugs@sourceware.org Subject: Re: [Bug libc/15615] Poor quality output from rand_r Message-ID: <20130613230122.GA6346@domone.kolej.mff.cuni.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-SW-Source: 2013-06/txt/msg00109.txt.bz2 On Thu, Jun 13, 2013 at 12:38:42PM +0000, bugdal at aerifal dot cx wrote: > http://sourceware.org/bugzilla/show_bug.cgi?id=15615 > > --- Comment #2 from Rich Felker --- > On Thu, Jun 13, 2013 at 08:26:27AM +0000, neleai at seznam dot cz wrote: > > A problem here is that for many users predictability is much more > > important than quality. Developer expects that when he uses rand_r with > > state that he controls will not vary. This can cause extra debbuging hastle > > when > > code mysteriously fails on one machine but not other or desync issues. > > Could you explain better what you're concerned about? By > "predictable", do you mean keeping the same sequence it's had in the > past? Aside from that, any PRNG with 32-bit state and 31-bit output is > equally "predictable". > > > > To fully fix rand_r, the approach of concatenating multiple iterations should > > > be abandoned in favor of a single-LCG-iteration approach followed by an > > > invertable transformation on the output. Obviously a 32-bit cryptographic block > > > cipher would give the best statistical properties, but it would be slow. In > > > > This is false, I have a replacement of this with four rounds of AES. On > > intel using aesenc I performance is better than current, I did not > > propose that due of problems above. I wrote a RFC for random > > replacement on libc-alpha, browse archives. > > AES itself does not use 32-bit blocks, so you must be using a modified > version. Would you care to explain? I searched the archives but could > not find your post. > Here, I wrote a version relevant to random. I did this to see how fast I could get if I employ paralellism and inlining. http://sourceware.org/ml/libc-help/2012-12/msg00005.html To test rand_r equivalent I wrote a simple generator (which is for mostly to test performance, I did not look for quality.) movd (%rdi),%xmm0 movdqa %xmm0,%xmm1 aesenc %xmm0,%xmm1 aesenc %xmm0,%xmm1 aesenc %xmm0,%xmm1 aesenc %xmm0,%xmm1 movd %xmm1, (%rdi) movd %xmm1, %eax shr $1, %eax On sandy bridge this code runs at half of speed of rand_r.