[racket-dev] bit-vectors and serialization

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Mon Dec 17 04:30:31 EST 2012

2012/12/17 Ryan Culpepper <ryan at cs.utah.edu>:
> I'd like to make bit-vectors serializable so I can replace sql-bits with
> them. I'll deprecate the current sql-bits names but keep them around for a
> while.
>
> The issue is that bit-vectors are implemented using fxvectors, which are
> serializable, but simply serializing them will presumably cause errors if a
> bit-vector is serialized on a 64-bit machine and deserialized on a 32-bit
> machine or vice versa.
>
> One solution would be to use bytes instead of fxvectors. The performance is
> about the same as far as I could tell using the sieve benchmark.
>
> Another option is to declare that serialization across word sizes doesn't
> work for bit vectors.
>
> Any opinions?

The sieve-benchmark works on individual bits, so it makes sense that
the performance is about the same. What happens for operations that
work on words (e.g. the popcount operation)? My intuition is that
these operations will be slower.

An alternative to switching to bytevectors is to write a pair of functions
bit-vector->integer and integer->bit-vector and simply serialize the
bit-vector as an integer.

/Jens Axel

Posted on the dev mailing list.