Hi all,

Dan's tuple-arrays library in basis implements a memory-saving data
structure that packs tuple instances together in an array, so that the
overhead of each instance having its own header in the heap is
eliminated. It also provides value semantics; if you pull an element
out and modify it, the original in the array isn't changed, you have
to store it back in for the change to persist.

Until now tuple-arrays were pretty slow because they used reflection
at runtime to construct and deconstruct tuples. I rewrote them using a
new approach. Instead of reflection, there is a parsing word which
takes a tuple class name, and generates a new sequence type for you.

For example,

USE: tuple-arrays

TUPLE: point x y z ;

TUPLE-ARRAY: point

This generates words in the current vocabulary named <point-array> and
>point-array, which construct point arrays. These new point arrays
implement the sequence protocol and implement the value semantics
described above.

The generated nth and set-nth methods do not involve any reflection
and have very little dispatch. There is still some unnecessary
allocation and copying, but hopefully that will be eliminated over
time. On a benchmark, the new tuple-arrays are 10x faster than the old
ones, and the performance will likely improve further. Eventually its
possible that they might be as fast or faster as ordinary arrays, so
for storing homogeneous collections of small immutable tuples,
tuple-arrays will likely become a good choice in the near future.

Slava

------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to