Callbacks from C into Squeak

David T. Lewis lewis at mail.msen.com
Wed Dec 20 16:06:31 UTC 2006


On Tue, Dec 19, 2006 at 01:15:23PM +0000, dan wrote:
> David T. Lewis wrote:
> >On Mon, Dec 18, 2006 at 10:11:46AM +0000, dan wrote:
> >>Hi Dave
> >>
> >>That makes it an overhead 0.15ms per callback, which is acceptable. I 
> >>will need to pass back an forth a packed array of floating point numbers 
> >>with a few hundred elements in it (representing the state of the system 
> >>and its calculated derivative). How could that be achieved without 
> >>denting that 0.15ms overhead too much?
> > 
> >Daniel,
> >
> >The only way to find out is to try it. Do you have an example of the
> >packed array binary data to work with? We could plug it in to the test
> >and see what happens.
> >
> >Dave
> 
> Hi Dave
> 
> The data we would use would be very much like Squeaks FloatArray class, 
> except double precision. If we used shared memory, as has been suggested 
> in a branch of this thread elsewhere, then it should all be good.

Daniel,

I am attaching a set of tests that demonstrate performance of two
cooperating Squeak images exchanging binary floating point data.

Results on my (old and slow) Pentium box:

- With 4000 byte uninterpreted data messages, overall transaction
  time is under 0.5 msec per end-to-end transaction..

- With a packed binary array of 500 doubles (4000 bytes long), and
  one of the cooperating images doing data conversion to and from
  the binary message, transaction time is 18 msec.

- With both cooperating images doing data conversion, transaction
  time is 36 msec.

- With a packed binary array of 1000 floats (4000 bytes long) and
  one of the cooperating images doing data conversion, transaction
  time is 31 msec.

My conclusions:

- Communication of raw data over OS pipes is quite fast.

- The associated data conversion to and from raw data is up to
  two orders of magnitude slower than the actual image-to-image
  communication.

- Do not bother with shared memory for data sets of this size,
  because moving data is a small part of the performance problem.

- The first thing to optimize (if actually needed) would be the
  data conversion to and from raw data. This can be done from the
  image, calling a primitive.

- No callbacks from primitives are needed. The required data
  communication and conversion can and should be done from the
  image, adding simple primitives to speed up the data conversion
  if necessary.

- Transmitting data as 64 bit doubles is more efficient than
  transmitting 32 bit floats because this is Squeak's internal
  format for Float. Note, pay attention to endianness, my tests
  are hard coded for little-endian data.

Dave

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestCooperatingSqueaks.dtl.3.cs.gz
Type: application/octet-stream
Size: 14529 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20061220/54e686b3/TestCooperatingSqueaks.dtl.3.cs.obj


More information about the Squeak-dev mailing list