NeilFawcett
Programmer
I've been doing some analysis of some of my perl scripts...
Take this simple example reading/writing a 1 meg file (with about 3000 lines):-
When I watch this running (XP Pro SP2) using File Monitor (by SysInternals) I can see the read generates a new IO process 4K at a time. Worse still, when writing, it generates an IO process for each 1 K... In total this simple operation generates over 1500 IO processes (in File Monitor).
I've tried the same thing running perl in CYGWin with File Monitor looking, and the same results are shown, 4K chunks are read, and 1K chunks are written.
Is there anyway around this? Am I monitoring it correctly? You can see by my example I've tried using the more exotic calls to try and stop this "buffering"...
Here's a link to an example output from FileMonitor showing the 4K chunks being read in. Click Me (Rememember to maximise the image size)
Note: This is all because my service provider informed me my IO Processes were getting a bit high, so I'm trying to reduce them by examing how efficient my code is and what it's up to...
Take this simple example reading/writing a 1 meg file (with about 3000 lines):-
Code:
#!/usr/bin/perl
$|=1;
print "Content-type:text/html;charset=ISO-8859-1\n\n";
open DF,"test.txt";
@test=<DF>;
close DF;
my $rec;
foreach(@test){$rec.=$_;}
sysopen (DF,"test.txt",O_WRONLY | O_CREAT);
syswrite DF,$rec,length($rec);
close DF;
exit;
When I watch this running (XP Pro SP2) using File Monitor (by SysInternals) I can see the read generates a new IO process 4K at a time. Worse still, when writing, it generates an IO process for each 1 K... In total this simple operation generates over 1500 IO processes (in File Monitor).
I've tried the same thing running perl in CYGWin with File Monitor looking, and the same results are shown, 4K chunks are read, and 1K chunks are written.
Is there anyway around this? Am I monitoring it correctly? You can see by my example I've tried using the more exotic calls to try and stop this "buffering"...
Here's a link to an example output from FileMonitor showing the 4K chunks being read in. Click Me (Rememember to maximise the image size)
Note: This is all because my service provider informed me my IO Processes were getting a bit high, so I'm trying to reduce them by examing how efficient my code is and what it's up to...