in reply to meaningful LENGTH value in read() builtin

Perl's read is already buffered, so you can really read in whatever size block is most convenient without having a huge impact on performance. But generally I used a multiple of the system disk block, since the OS usually reads one block at a time, and the input buffer is usually also a multiple of the blocksize. Rather than try to figure out the system block size, I usually just use 8192 bytes, which is between 1 and 8 blocks on most systems.

Depending on exactly what you want to do, I've found that using mmap is a very fast way to read through a mailbox. Sys::Mmap seems to provide a way to do this, although I've not used it (the program I wrote was in C).

Replies are listed 'Best First'.
Re^2: meaningful LENGTH value in read() builtin
by Anonymous Monk on Dec 12, 2004 at 12:30 UTC
    Thanks for that, exactly what I wanted to know. I suppose my *real* issue was knowing if there is a trade-off in performance by specifying a LENGTH of a particular type.