Heap based mutable arrays?

Bjorn Gustavsson bjorn@REDACTED
Wed May 2 12:30:50 CEST 2001


Thomas Lindgren <thomasl@REDACTED> writes:

.
.
.

> 
> I know there has been discussions about implementing something like
> this in OTP, but I don't know the precise status. Björn G. probably
> knows more :-)

Actually, the code for a vector type is included in R7B, but the
BIFs used to create vectors (vector:new/2 and vector:from_list/1)
are disabled. By a few simple changes to the erl_vector.c source
file in the open source distribution vector support can be enabled.

The following features are not implemented (and will crasch the emulator
if you try to use them):

   - Term comparisions of whole vectors.
   - Taking hash values of vectors.
   - term_to_binary(Vector)
   - Creating circular terms will cause an infinite loop in term copying
     (and perhaps in other places).

I bypass the garbage collection problem by forcing a fullsweep collection
as soon as any vector is updated.

My time measurements were somewhat of a disappointment. You'll get a noticeable
performance improvement if you use vectos with many elements (typically more
than several hundred elements) compared to using a tuple of the same size,
but for many algorithm data structures using lists and/or tuples are faster
than vectors.

Vectors may get more useful if we'll fix the garbage collector (implementing
a proper write barrier).

/Bjorn
-- 
Björn Gustavsson            Ericsson Utvecklings AB
bjorn@REDACTED      ÄT2/UAB/F/P
			    BOX 1505
+46 8 727 56 87 	    125 25 Älvsjö



More information about the erlang-questions mailing list