[erlang-questions] Is it possible to align binary's byte array to cache line boundary?

Jon Watte <>
Sat Sep 24 19:35:59 CEST 2011


Maybe LazyByteStrings and Erlang binaries approach the performance of
randomly aligned heap blocks in C.

But, if I do data streaming processing (say, transforming vertices for 3D
graphcs, transcoding media in multimedia, detecting intersections in rigid
body dynamics, etc) then the specific alignment and stride of my data
matters. Neither Erlang nor Haskell allows me to specify that "the first
byte of this byte string is always aligned on a multiple of 16 bytes" (for
architecture-specific SIMD exploitation) or "the first byte of this byte
string is always aligned on a multiple of 64 bytes" (for
architecture-specific cache line exploitation) or "no word within this
binary will share a L3 cache line with any other word allocated in the same
manner" (for architecture-specific cache contention reduction for
spinlocks).

C allows you to control these things. That's why it's a systems programming
language, and Erlang isn't (although it's a language for programming systems
:-)

Sincerely,

jw


--
Americans might object: there is no way we would sacrifice our living
standards for the benefit of people in the rest of the world. Nevertheless,
whether we get there willingly or not, we shall soon have lower consumption
rates, because our present rates are unsustainable.



On Thu, Sep 22, 2011 at 1:46 PM, Jesper Louis Andersen <
> wrote:

> On Thu, Sep 22, 2011 at 17:49, max tan <> wrote:
>
> >
> > I just found Haskell has "Data.ByteString.Lazy", according to a paper
> titled
> > "Rewriting Haskell Strings":
> >
> >   A library for ByteStrings is implemented,   providing a purely
> functional
> > interface, which approaches the speed of low-level mutable arrays in C.
> > _______________________________________________
>
> This is true. In many ways, a Lazy ByteString in Haskell corresponds
> to a list of binaries in Erlang, which is a subset of the iolist()
> type in Erlang. If Haskells Lazy Bytestring implementation approaches
> the speed of low-level mutable arrays, so does binaries in Erlang.
>
> My experience is they perform at about the same speed. I don't know
> what happened in my brain when I called Haskell a dynamic language
> though. It is statically typed, and very much so.
>
>
> --
> J.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110924/d4c40b07/attachment.html>


More information about the erlang-questions mailing list