B
Bart Van der Donck
Hello,
I am doing a bit of research about Perl's I/O memory consumption.
Using ">>" seems a very memory-efficient strategy for logging. In so
far I can see, the log file would not need to be opened. Web servers
use such techniques for HTTP logs - I've seen very busy web servers
that don't have trouble to write many log lines simultaneously into
already huge files. My best guess would be that the new data is stored
separately into some memory blocks (in C?), and that then the new
blocks are somehow added to the original file. I could be wrong, but
this could maybe explain the low memory use of ">>". In this logic, I
could write at the beginning of a file with exactly the same amount of
memory.
Using Perl's ">" would require more memory, as the occupied memory
would first need to be freed, and then new memory is allocated to
store the new data.
A traditional "Edit File" action would stand apart from this. It
requires much more memory: namely (1) open, (2) edit, and (3) save.
Like you would for example modify a text-document on your computer.
I'm not very confident with low-level memory handling; maybe some of
my thoughts are wrong.
Are these mechanisms done by the O.S. ? Or are they done by the Perl
executive in C (in a broader sense, the application that processes the
data) ? Or is this a general principle with identical results, e.g.
when I would do it from PHP/ASP ?
Thanks,
I am doing a bit of research about Perl's I/O memory consumption.
Using ">>" seems a very memory-efficient strategy for logging. In so
far I can see, the log file would not need to be opened. Web servers
use such techniques for HTTP logs - I've seen very busy web servers
that don't have trouble to write many log lines simultaneously into
already huge files. My best guess would be that the new data is stored
separately into some memory blocks (in C?), and that then the new
blocks are somehow added to the original file. I could be wrong, but
this could maybe explain the low memory use of ">>". In this logic, I
could write at the beginning of a file with exactly the same amount of
memory.
Using Perl's ">" would require more memory, as the occupied memory
would first need to be freed, and then new memory is allocated to
store the new data.
A traditional "Edit File" action would stand apart from this. It
requires much more memory: namely (1) open, (2) edit, and (3) save.
Like you would for example modify a text-document on your computer.
I'm not very confident with low-level memory handling; maybe some of
my thoughts are wrong.
Are these mechanisms done by the O.S. ? Or are they done by the Perl
executive in C (in a broader sense, the application that processes the
data) ? Or is this a general principle with identical results, e.g.
when I would do it from PHP/ASP ?
Thanks,