From: Johannes Lorenz
Subject: Q: fast read-line, file I/O in lisp
Date: 
Message-ID: <3ku8eu$i11@sunserver.lrz-muenchen.de>
Hello,

i have to read a finite element result file, which contains several thousand
ouput lines. The standard functions read-char or read-line need to much time
for that operation.
Has anybody realized a faster read-line or read-char function in lisp, with a
performance comparable or equivalent to C getchar.

Any help is appreciated
Johannes
····@lft.mw.tu-muenchen.de

From: William D. Gooch
Subject: Re: Q: fast read-line, file I/O in lisp
Date: 
Message-ID: <Pine.A32.3.91.950324164321.48234N-100000@swim5.eng.sematech.org>
On 24 Mar 1995, Johannes Lorenz wrote:

> i have to read a finite element result file, which contains several thousand
> ouput lines. The standard functions read-char or read-line need to much time
> for that operation.
> Has anybody realized a faster read-line or read-char function in lisp, with a
> performance comparable or equivalent to C getchar.

You need to be sure that your assessment of where the time is going is
an accurate one before trying to improve things.  Based on my experience
with this sort of thing in Lisp, I would guess that your code might be
spending a lot of time allocating line buffers and/or doing disk waits.
One approach that may help in such cases is to read a large chunk of
the file into a string buffer, then process it, then read another chunk
into the same buffer, and so on.  Reading the entire file at once may not
be practical, but a reasonably large buffer should get away from some of
the delays you may be seeing.  Before doing anything, though, I strongly
recommend using a performance metering/profiling tool to find out where
time is actually being spent.
From: Henry Baker
Subject: Re: Q: fast read-line, file I/O in lisp
Date: 
Message-ID: <hbaker-2603951512460001@192.0.2.1>
In article <··········@sunserver.lrz-muenchen.de>,
····@lft.mw.tu-muenchen.de wrote:

> Hello,
> 
> i have to read a finite element result file, which contains several thousand
> ouput lines. The standard functions read-char or read-line need to much time
> for that operation.
> Has anybody realized a faster read-line or read-char function in lisp, with a
> performance comparable or equivalent to C getchar.

I added support for memory-mapped I/O in KCL on an i860 Unix platform.

If someone knows C, Unix and KCL, it isn't a terribly difficult thing
to do.

A bigger problem is what to do with the stuff you mapped in.  E.g., it
had better be binary-compatible with your machine, or it will be worthless.
This means that your file has to have the right byte-ordering and floating
point formats.

-- 
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html
From: Martin Cracauer
Subject: Re: Q: fast read-line, file I/O in lisp
Date: 
Message-ID: <1995Mar27.085840.13057@wavehh.hanse.de>
····@lft.mw.tu-muenchen.de (Johannes Lorenz) writes:

>i have to read a finite element result file, which contains several thousand
>ouput lines. The standard functions read-char or read-line need to much time
>for that operation.
>Has anybody realized a faster read-line or read-char function in lisp, with a
>performance comparable or equivalent to C getchar.

The dpANS (didn't check for ANSI-CL) included (read-sequence ...) and
(write-sequence ...). They can fill a previously allocated sequence
(array) of fixed length. Should be the raw system call and few else
and therefore as fast as a C call.

CLISP includes this functions. It should be easy to implement as a
foreign C call in other Lisps, since very few checks and no allocation
have to be made beside the system call.

Martin

P.S.: The newsgroups- and/or followup-to: header line of your posting
is not valid.
--
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Private email ···············@wavehh.hanse.de Fax +4940 522 8536. No NeXTMail!
"As far as I'm concerned, if something is so complicated that you can't ex-
 plain it in 10 seconds, then it's probably not worth knowing anyway" - Calvin