Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hello BrowserUk,

I running on: This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi and I can see two different observations based on your script.

When I am executing your script with new line characters \n sample of the script bellow:

#!/usr/bin/perl use strict; use warnings; use Benchmark ':hireswallclock'; # enable hires wallclock (microsecond +s) timing if possible my $iterations = 1; my $regexEngineCode = sub { my $x = "the quick brown fox\n"; $x x= 107374182; print length $x +. "\n"; ### 8 bytes less than 2^31. my $n=0; ++$n while $x =~ m[^.*$]mg; print $n . "\n"; ### finds al +l the lines. ### Add another line that pushes the length a few bytes over 2^ $x .= "the straw that broke the camel's back\n"; print length $x . + "\n"; $n=0; ++$n while $x =~ m[^.*$]mg; print $n . "\n"; ### and it sile +ntly fails to find any of them. }; my $time = timeit($iterations, $regexEngineCode); print "It took ", timestr($time), "\n";

I am getting the following output:

2147483641107374182 Out of memory! real 1m29.931s user 0m50.376s sys 0m4.824s

I forgot to mention I am using also Benchmark and time(1) - Linux man page to see the process time.

But when I remove the new line characters \n sample of code bellow:

#!/usr/bin/perl use strict; use warnings; use Benchmark ':hireswallclock'; # enable hires wallclock (microsecond +s) timing if possible my $iterations = 1; my $regexEngineCode = sub { my $x = "the quick brown fox\n"; $x x= 107374182; print length $x; + ### 8 bytes less than 2^31. my $n=0; ++$n while $x =~ m[^.*$]mg; print $n; ### finds all the l +ines. ### Add another line that pushes the length a few bytes over 2^ $x .= "the straw that broke the camel's back\n"; print length $x; $n=0; ++$n while $x =~ m[^.*$]mg; print $n . "\n"; ### and it sile +ntly fails to find any of them. }; my $time = timeit($iterations, $regexEngineCode); print "It took ", timestr($time), "\n";

I get on the output:

214748364010737418221474836780 It took 32.7849 wallclock secs (31.79 usr + 1.02 sys = 32.81 CPU) @ +0.03/s (n=1) real 0m32.942s user 0m31.839s sys 0m1.129s

So based on the observations/results provided by karlgoethebier above, shows that if you have appropriate HW, you can get a complete output on v5.18.2 even if with the new line characters. Instead of my HW failure. Although that on the 4th print statement he is getting a zero indicating that probably Perl v5.18.2 can not handle so big numbers.

So in conclusion I would say a combination of HW and latest SW version of Perl can provide you with the result that you expect.

Update: I am not expert (not even close) but I think this might be the reason. Short description about memory limitation between LinuxOS and WindowsOS Memory Limits in R.

Update 2: I also found this regarding Perl 5.20.0 Better 64-bit support:

On 64-bit platforms, the internal array functions now use 64-bit offsets, allowing Perl arrays to hold more than 2**31 elements, if you have the memory available. The regular expression engine now supports strings longer than 2**31 characters. perl #112790, #116907 The functions PerlIO_get_bufsiz, PerlIO_get_cnt, PerlIO_set_cnt and PerlIO_set_ptrcnt now have SSize_t, rather than int, return values and parameters..

Update 3: update hyper-link and modified text output.

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Another 64-bit Perl bug. Is it fixed post 5.18? by thanos1983
in thread Another 64-bit Perl bug. Is it fixed post 5.18? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (2)
    As of 2021-05-08 02:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Perl 7 will be out ...





      Results (95 votes). Check out past polls.

      Notices?