Re: SV: Re: Referencing a row in a two dimensional array

JP Massar <[email protected]>
Newsgroups gmane.lisp.corman
Message-ID <[email protected]>
>
> >
> > I was hoping that READ-SEQUENCE actually read an entire block of
> > bytes in one shot, similar to "fread" in C, as this would probably
> > increase performance (in my case) by a factor of 100 or more.
> >
>
>Corman Lisp cannot read from file directly to Lisp data because
>blocks of Lisp data may be moved by garbage collector.
>
>Corman Lisp first reads to a "foreign block", than copies this block
>to file buffer, and read-byte reads from buffer to the target data.

Out of curiosity, it is theoretically possible to do (expressed in psuedocode):

(without-interrupts (without-gc (move-buffer-block-into-lisp-array-block ...)))


>So it is hardly possible to increase performance by a factor of 100.

I would not be all that surprised if there existed a theoretically 
implementable path to
getting a factor of something like 100 for a specialized array type
and for a large enough block of data.

Is there any sort of atomic memory-block-move instruction available?


>Here is a function that reads the block 3 times faster:
>
>(defun read-bytes (vector stream &optional (start 0) end)
>     (let (length buf buf-pos buf-end)
>         (multiple-value-setq (length end) (cl::validate-bounding-indices
>vector start end))
>         (unless (and (cl::binary-stream-p stream)(input-stream-p stream))
>                (error "Expected a binary input stream, got ~A" stream))
>         (setq buf (cl::stream-input-buffer stream))
>         (do ((p start))
>             (nil)
>             (setf buf-pos (cl::stream-input-buffer-pos stream)
>                   buf-end (cl::stream-input-buffer-num stream))
>             (when (= buf-pos buf-end)
>                 (funcall (cl::stream-underflow-function stream) stream)
>                 (setf buf-pos (cl::stream-input-buffer-pos stream)
>                       buf-end (cl::stream-input-buffer-num stream))
>                 (when (= buf-pos buf-end)
>                     (return-from read-bytes p)))
>             (do ((i buf-pos (+ i 1)))
>                 ((= i buf-end) (setf (cl::stream-input-buffer-pos stream)
>buf-end))
>                 (when (= p end)
>                     (setf (cl::stream-input-buffer-pos stream) i)
>                     (return-from read-bytes end))
>                 (setf (elt vector p) (elt buf i))
>                 (incf p)))))
>
>
>By redefining function elt I can read blocks 5 time faster.
>
>I am planning also to write functions for fast copying data;
>they may be used both to copy from "foreign buffer" to stream buffer
>and from stream buffer to target data (if no data conversion required).
>
>Pavel Grozman
>
>
>
>To unsubscribe from this group, send an email to:
>[email protected]
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/SyjtlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.