develooper Front page | perl.perl5.porters | Postings from July 2018

Re: regen/mph.pl reuse troubles

Thread Previous | Thread Next
From:
Karl Williamson
Date:
July 13, 2018 15:40
Subject:
Re: regen/mph.pl reuse troubles
Message ID:
7e67b132-60e0-5272-53ab-8c9f0c7dcfe9@cpan.org
On 07/13/2018 08:42 AM, demerphq wrote:
> On Thu, 5 Jul 2018, 12:12 bulk 88, <bulk88@hotmail.com 
> <mailto:bulk88@hotmail.com>> wrote:
> 
> 
>     32 bit perl generates different numbers in the mph hash than 64 bit
>     perl. I'll guess more "use integer" is needed somewhere in the code.
> 
> 
> Actually no, more use integer doesn't fix this and causes other issues.
> 
> The problem is that while use integer disables conversion to floating 
> point, which we *want*, it also causes the return from _fnv() to be 
> *signed* which then causes the minimum perfect hash construction to 
> produce surprising results. A simple fix on little endian boxen is to 
> change the return of _fnv() to
> 
> return unpack "V", pack "l", $h;
> 
> Which in my testing causes the 32bit builds to produce the same output 
> as the 64bit builds.
> 
> I am traveling right now so it's a bit difficult to do more than write 
> this mail. If no-one beats me to it I will push the patch when I return.

Last week I pushed 'use bignum' globally in the program in 
00d503c441212052333efea48fdca1499869a60c.

That solves the problem.  Any slowdown is inconsequential in perl's 
usage, as it is executed only during development, and even then only 
rarely (usually by me) when very particular things in the build change, 
such as getting a new Unicode release.

> 
> Fwiw, it would be nice to have a "no float_conversion" instead of "use 
> integer" for situations like this where we want to avoid floating point 
> conversion but where we do NOT want signed/integer semantics. "use 
> integer" affects too much and easily results in surprise, such as how it 
> changesĀ  the behaviour of the % (Modulo operator), which for instance 
> causes an infinite loop in the seed selection logic due to signedness 
> issues.
> 
> Sigh.
> 
> Yves
> 
> 
> 

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About