Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Efficient file handling (was Re^3: trouble parsing log file...) (stranger than fiction)

by tye (Sage)
on Nov 23, 2006 at 15:50 UTC ( #585736=note: print w/replies, xml ) Need Help??

in reply to Efficient file handling (was Re^3: trouble parsing log file...)
in thread trouble parsing log file...

Perl did some old tricks that reached a little bit too far inside the <stdio.h> macros to be completely portable but that allowed Perl line-at-a-time I/O to be about twice as fast as C line-at-a-time I/O... on sufficiently "standard enough" systems. That was back in the days of AT&T Unix, before Linux. Last time I checked (long enough ago that I hope things have improved but not long enough ago that I've heard that they have), Perl still did line-at-a-time I/O unnecessarilly inefficiently when compiled on a system that isn't "standard enough" (which is nearly every system these days).

This meant that Perl line-at-a-time I/O was 4 times slower than it really should be on Linux (for example). This actually made re-implementing line-at-a-time I/O in Perl code faster than using Perl's own line-at-a-time I/O implemented in C code (about twice as fast, which means that when Perl gets fixed, it would be about twice as slow, which would be expected).

Yes, it makes little sense for Perl code to be faster than Perl's own C code. Unfortunately, that was certainly the case not too long ago.

The command perl -V:d_stdstdio will tell you whether Perl thinks your platform is "standard enough".

But, yes, the speed difference between line-at-a-time I/O and "slurping" is usually small enough not to matter (even considering Perl's quirk here). The memory consumption difference can be hugely significant, of course.

- tye        

  • Comment on Re: Efficient file handling (was Re^3: trouble parsing log file...) (stranger than fiction)
  • Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://585736]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2018-02-20 16:13 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (272 votes). Check out past polls.