top | item 43965319

(no title)

rbjorklin | 9 months ago

Does anyone have some hard numbers on the expected performance uplift when using GADTs? Couldn't see any mentioned in the article.

discuss

order

ackfoobar|9 months ago

The example here is basically an 8-fold memory saving going from `long[]` from `byte[]` - while still retaining polymorphism (whereas in Java the two are unrelated types).

Hard to say exactly how much performance one would get, as that depends on access patterns.

misja111|9 months ago

The reason that a byte array is in reality layed out as a (mostly empty) long array in Java, is actually for performance. Computers tend to have their memory aligned at 8 byte intervals and accessing such an address is faster than accessing an address that's at an offset of an 8 byte interval.

Of course it depends on your use case, in some cases a compact byte array performs better anyway, for instance because now you're able to fit it in your CPU cache.