Given that Sys::Mmap ties a scalar to the memory region returned by OS-level mmap() and that you get exponential run-time (and not just a constant increase) when using Sys::Mmap, my guess is that the regex seeks at the beginning of the string for each iteration of the loop but somehow/possibly does not mess results up.
If you avoid using the tie'd variable, you should get equal performance. E.g., my $str1 = $str; and apply regex to $str1.
Each time Sys::Mmap's tied scalar FETCH()es, it dereferences the original scalar ref (see https://metacpan.org/source/SWALTERS/Sys-Mmap-0.19/Mmap.pm). Perhaps the dereference of the mmap-ed string combined with regex-ing it in a loop via the g modifier causes the problem.
bw, bliako
In reply to Re: match operator linear with PerlIO :mmap, exponential with Sys::Mmap
by bliako
in thread match operator linear with PerlIO :mmap, exponential with Sys::Mmap
by daxim
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |