Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: perl io and linux issues

by jeroenes (Priest)
on Mar 30, 2001 at 15:20 UTC ( [id://68334]=note: print w/replies, xml ) Need Help??


in reply to perl io and linux issues

For one thing, a readline must search for a newline in the file. Of course that is slower that a read, that just takes a predefined length of bytes from a file.

Others will have more to say about the linux file IO. As far as I know, it is fast.

Jeroen
"We are not alone"(FZ)

Replies are listed 'Best First'.
Re: Re: perl io and linux issues
by Malkavian (Friar) on Mar 30, 2001 at 15:40 UTC
    I think the issue in question is that even running over a file, finding newlines, and forming lines, in the same way that readline should do, works faster in linux as a read of a block of data and subsequent line formation than as a readline.
    An initial answer to this has already been made by tye in the note here.

    I believe the question is asking more why Perl IO is broken on Linux, and what can be done to work around this in the meantime.
    Cheers,

    Malk
      After a little digging it appears not to be a problem with linux per se but glibc 2. (Please correct me if I'm wrong) Fast stdio io in perl uses the hooks _ptr and _cnt specified in the normal stdio.h. Unfortunately _cnt is not visible in the glibc 2 version. I've seen mentions of a glue.c file in glibc source that may allow a work around.

      If this is a glibc 2 then there may be future problems on other platforms, or do other platforms that use glibc 2 and have fast perl io, have a modified stdio.h?

      Perhaps sfio allows such direct hooks, has anybody else made progress on this issue?

      regards dino

Re: Re: perl io and linux issues
by dino (Sexton) on Mar 30, 2001 at 17:30 UTC
    I can do a read, run a split over it to extract lines and it will still be faster than the equiv no of readlines under linux 2.2.x. Of course I have to do a bit of work to catch broken lines, buts thats little perf penalty. If I don't do a split and use s/// over the string its a lot faster
    Dino

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://68334]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found