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

regen/mk_invlist.pl aka regen/mph.pl infinite loop?

Thread Next
From:
bulk 88
Date:
July 2, 2018 10:18
Subject:
regen/mk_invlist.pl aka regen/mph.pl infinite loop?
Message ID:
BN6PR04MB096330CA048FBDCA7890D695DF430@BN6PR04MB0963.namprd04.prod.outlook.com
I tried to reuse the MinimalPerfectHash code in regen/mph.pl for another 
use in core. I tried to run regen/mk_invlist.pl and overnight, it is 
still running at max CPU.

I wrote a cut down case of regen/mk_invlist.pl as mpht.pl and attached 
that, and mpht.pl is also an infinite loop. Is this MPH code only 
correctly work on a 64 bit int perl (I am using 32 bit int perl)? or 
only works correctly on KHW's machine? I'll note regen/mk_invlist.pl is 
not executed by the typical p5p "regen.pl" tool.

Console output:
-----------------------------
No preprocessing, initial blob size 0
Length old blob: 8124 length new blob: 8248, keeping old blob
Using preprocessing, initial blob size 30002
Length old blob: 30121 length new blob: 8018, recomputing using new blob
Length old blob: 8533 length new blob: 8486, recomputing using new blob
Length old blob: 8486 length new blob: 8458, recomputing using new blob
Length old blob: 8458 length new blob: 8383, recomputing using new blob
Length old blob: 8383 length new blob: 8383, keeping old blob
Using greedy-smart blob, length: 8124 (vs 8383)
******infinite100% CPU hang at this****
-----------------------------

Using a debugger shows sub _fnv always returns 4294967295 aka 0xFFFFFFFF 
no matter what the seed number is after an hour of running random seed 
numbers through. I've isolated this into mpht2.pl.  The 4294967295 aka 
0xFFFFFFFF number causes the infinite loop because $max_h is
4294965933  aka 0xFFFFFAAD.
---------------------------------
    SEED1:
    for ($seed1++;1;$seed1++) {
        my %hash_to_key;
        my %key_to_hash;
        my %key_buckets;
        my %high;
        $length_all_keys= 0;
        foreach my $key (sort keys %$hash) {
            $length_all_keys += length $key;
            my $h= _fnv($key,$seed1);
            next SEED1 if $h >= $max_h; #NOW BACK TO SEED1 LABEL FOREVER 
because $h always 4294967295
---------------------------------

does mph.pl work (not infinite loop) for anyone?

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