http://qs1969.pair.com?node_id=439884


in reply to Re: Muy Large File
in thread Muy Large File

Wow. Many deep bows of reverence for all that responded. As UK inferred, I was (indeed) doing something wrong. Based on the above suggestions, this was the script tested:

#!/usr/local/perl5.6.1/bin/perl -slw
use strict;
our $BUFSIZE ||= 2**30;
open my $fhi, '+<', "/data/p_dm200/ndm_ip_pull/test_customer1" or die $!;

while( sysread $fhi, $_, $BUFSIZE ) {
tr^M ;
sysseek $fhi, -length(), 1;
syswrite $fhi, $_, $BUFSIZE;
}
close $fhi;

which was tested against an 8,595,447,728 byte file. The time output was:
real 10m5.95s
user 1m48.55s
sys 0m17.24s

An amazing 10 minutes. I checked the output and it looks exactly as expected. I even retested 3 times and each time the results were similar.

Ok, now I am getting greedy and curious as to if this can be optimized more?? I ran top during this session and saw that SIZE and RES were both around 1026M throughout the duration and only 1 cpu seemed used. Would increasing BUFSIZE help performance linearly? If I was capable (and I am not) would either shared memory threads or parallel forks produce big gains? Any other low-hanging fruit?

Perlfan, the ROMIO seemed interesting but I could not find a perl sample. Still it seemed interesting. Anonymous Monk, please forgive my ignorance but what does HD mean?

A sincere thanks to all,
--Paul