ion-docs icon indicating copy to clipboard operation
ion-docs copied to clipboard

Evaluate whether switching `float` to little endian in Ion 1.1 is worthwhile

Open zslayton opened this issue 1 year ago • 3 comments

Our int encodings (including primitives) have switched to little endian in Ion 1.1 for a performance boost. Floats also rely on the CPU's native endianness, but the current version of the spec leaves them big endian.

zslayton avatar Jan 11 '24 20:01 zslayton

For reference, here's the assembly generated by the conversion to LE bytes and to BE bytes on x86_64:

image

Depending on your perspective, that's either a trivial difference or it's 100% more instructions! 😛

zslayton avatar Jan 12 '24 16:01 zslayton

It does look pretty trivial (unless, perhaps, you're encoding lots of floats in a tight loop). We should see if there's a significant performance difference in Java (and maybe some other languages) to make a more informed decision.

popematt avatar Jan 12 '24 19:01 popematt

Per team discussion, we're leaning little endian for consistency. Java's ByteBuffer has an API for swapping endianness.

zslayton avatar Mar 01 '24 19:03 zslayton

@zslayton, I'm going to close this as completed. Feel free to re-open if you disagree.

popematt avatar May 14 '24 19:05 popematt