johnmyleswhite has asked for the wisdom of the Perl Monks concerning the following question:
Lately I've been using PDF::API2 within a CGI script that handles the uploading and processing of PDF files. Because my program ran so slowly on the antiquated box I have at work, I started to run the script with Devel::Profiler on. After a single run, I found that the vast majority of the program's running time was spent making call after call to IO::Handle's read.
After looking at the source for PDF::API2, I found that each read call was pulling in only 512 characters at a time. I made an alternative version that pulled in 65536 characters instead and found that my program ran more than four times as fast.
With that observation in mind, I wrote to the module's author, suggesting that the LENGTH used by read calls be an option that could be set by the user of the module. He responded by noting that 512 bytes is the POSIX limit on file blocks and that, therefore, a larger size cannot be guaranteed to work on all systems.
I'm interested in knowing how many types of systems this could be a problem on, because almost all of the Perl programs I've seen written these days contain read calls fetching more than 512 characters at a time. My understanding is that the Perl read calls are translated into as many stdio fread(3) calls as necessary. Is this not true? And is my program going to mysteriously fail on a modern platform if I take the risk of using the larger length?
Thanks for whatever details anyone has to offer about read lengths.
-- John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Portability of Large read Lengths
by BrowserUk (Patriarch) on May 26, 2008 at 14:59 UTC | |
|
Re: Portability of Large read Lengths
by moritz (Cardinal) on May 26, 2008 at 14:53 UTC | |
by johnmyleswhite (Initiate) on May 26, 2008 at 17:28 UTC | |
by tye (Sage) on May 26, 2008 at 20:10 UTC | |
|
Re: Portability of Large read Lengths
by Corion (Patriarch) on May 26, 2008 at 14:59 UTC | |
|
Re: Portability of Large read Lengths
by ysth (Canon) on May 27, 2008 at 03:22 UTC |