[Openmcl-devel] Binary IO...

Jon S. Anthony j-anthony at comcast.net
Tue Jun 9 15:52:11 PDT 2009


Hi Gary,

Thanks for the help and information.  The enclosed file shows a starting
proof of concept that works exactly as wanted/expected.  Just as fast as
the C code!:

(time (main2 nil))
(MAIN2 NIL) took 832 milliseconds (0.832 seconds) to run 
                    with 2 available CPU cores.
During that period, 0 milliseconds (0.000 seconds) were spent in user
mode
                    820 milliseconds (0.820 seconds) were spent in
system mode
 2,744 bytes of memory allocated.
 1 minor page faults, 0 major page faults, 0 swaps.


And results:

(time (main2 32))
(MAIN2 32) took 1,311 milliseconds (1.311 seconds) to run 
                    with 2 available CPU cores.
During that period, 488 milliseconds (0.488 seconds) were spent in user
mode
                    804 milliseconds (0.804 seconds) were spent in
system mode
 2,744 bytes of memory allocated.
 1 minor page faults, 0 major page faults, 0 swaps.
T
? (subseq (second *input-page*) 0 12)
#(32 32 32 32 32 32 32 32 32 32 32 32)

Just works.

BTW, are stuff like ccl:make-heap-ivector, ccl:stream-device, #_lseek,
#_read, #_write, etc. indicated as being available somewhere?  I scanned
the documentation but don't see them there.

Thanks again!

/Jon


On Tue, 2009-06-09 at 13:52 -0600, Gary Byers wrote:
> If a file stream  is opened with :direction :io, then there's a single
> underlying FD that can be used for reading and writing, and STREAM-DEVICE
> should return the same value for :INPUT and :OUTPUT.
> 
> (A TWO-WAY-STREAM is generally composed of separate input and output streams
> that may have underlying FDs that're distinct).
> 
> On Tue, 9 Jun 2009, Jon S. Anthony wrote:
> 
> >
> > This appears to be pretty much exactly what I need.  Since these vectors
> > behave like "regular vectors" in normal code, I really don't even need
> > the capabilities of WITH-HEAP-IVECTOR (at least I don't now think
> > so...).  The only thing left is the ability to have (or simulate) a
> > bidirectional stream with this.
> >
> > So, is it legitimate to do this sort of thing (basically use the same
> > stream for reading and writing)?  Or can there be two separate streams
> > open at the same time for the same file (one for input, one for output)?
> >
> 
> I'd assume that reading and writing the same file (via separate streams/fds)
> could be problematic; I don't know how much the OS tries to ensure that
> the right things happen (e.g., that the reader will always see what
> the writer writes, even if readahead and caching mechanisms had prepared
> it to see something else.)
> 
> I don't know, though, and if I ever knew anything useful about this I've
> forgotten it.  If there are issues there, it seems likely that those issues
> aren't lisp- or CCL-specific.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: megabyte-binary-io.lisp
Type: text/x-emacs-lisp
Size: 3133 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20090609/e24aeea7/attachment.bin>


More information about the Openmcl-devel mailing list