In-memory stream performance on word data

Joshua 'Schwa' Gargus schwa at cc.gatech.edu
Sat Aug 23 06:15:50 UTC 2003


Hi,

I am using ReferenceStream to serialize some objects, the bulk of
whose memory usage is in the form of B3DRotationArrays and
B3DMatrix4x4Arrays (implemented exactly as B3DRotationArray, except
the class-side method #contentsClass answers B3DMatrix4x4).

I am using a ReferenceStream on top of a RWBinaryOrTextStream.  This
is so I can create a ZipArchive containing several serialized objects
without having to write a temporary file to disk, and then add it to
the archive.

I have found that the performance is much worse when the
ReferenceStream is on top of an RWBinaryOrTextStream instead of a
StandardFileStream (by a factor of about 20).  This appears to be
because StandardFileStream uses a BitBlt-based hack to improve
performance in #nextWordsPutAll:, while RBBinaryOrTextStream defaults
to the implementation in Stream.

My questions are: 

1) Is there any reason why the StandardFileStream implementation shouldn't
be used in RWBinaryOrTextStream, or even in Stream?

2) I tried doing #1, and ran into trouble because my new
implementation of #nextWordsPutAll: calls RWBinaryOrTextStream>>nextPutAll:, 
which sends #asString to the byte-swapped B3DRotationArray copy, which
doesn't do anything sensible at all.  Instead of cloning the
B3DRotationArray, could I copy its bits into a ByteArray before
swapping bytes?  What is the easiest way to copy word data into a
ByteArray?

Thanks,
Joshua



More information about the Squeak-dev mailing list