I just added 64-bit integer support to my Math::Random::MT::Auto module. To my surprise, I determined that the module was now 66% faster than before!

I don't think it has to do with the 64-bit version of the Mersenne Twister algorithm that the module uses, as it runs through essentially the same code as the 32-bit version (just using different constants). In fact, the 64-bit version has to refresh the random number buffer twice as often, so it's actually doing more work!

One source of improvement may be better utilization of the CPU (Pentium 4) with everything getting done in 64-bit mode to match the CPU registers.

Another may be that since my Perl is compiled with 'use64bitint', it may be using the 64-bit ints from the PRNG directly, and not having to convert them from 32-bits (output of the old PRNG) to 64-bits (Perl's internal representation). (Not sure about this.)

Regardless, it was totally unexpected. Anyone else had any experience with this sort of thing?


Remember: There's always one more bug.

Replies are listed 'Best First'.
Re: 64-bit Zoom!
by cbrandtbuffalo (Deacon) on Jul 07, 2005 at 20:41 UTC
    We recently upgraded perl on our 64-bit solaris systems and attempted to compile with 64-bit support. The main perl executable compiled OK, but when we started compiling modules things started failing. I think the first program to start throwing errors was expat for XML::Parser.

    We decided to back up and take the safe route and go 32-bit because I didn't think there would be a noticeable difference. Maybe I was wrong here? It's solaris vs. intel, but maybe we would have seen a performance improvement? We may never know. Interesting to read about your results.

      I just compiled Perl (with 'use64bitint' and NOT 'use64bitall'), Expat and XML::Parser on Solaris/UltraSPARC, and everything works fine. If you used the 'use64bitall' setting in Perl, that may have been what caused your problems. Try it again with the 'use64bitint' setting only.

      Remember: There's always one more bug.
Re: 64-bit Zoom!
by hossman (Prior) on Jul 07, 2005 at 21:16 UTC

    What a silly question,

    64-bit computing is obviously faster the 32-bit computing. There's almost 30 more bits executing your data!

Re: 64-bit Zoom!
by monarch (Priest) on Jul 08, 2005 at 08:10 UTC
    Does it go heaps faster on a 32 bit or 16 bit processor?