Is your feature request related to a problem? Please describe.
While working on Printout I noticed that we don't optimally pack bits. Ideally we should pack bits so that fields that take up more space are fields earlier in the struct, e.g.
struct Foo {
a: u8,
b: u64,
}
packs less efficiently than
struct Foo {
b: u64,
a: u8,
}
which leads to memory bloat and performance degradation (since caches will be more frequently invalidated).
Describe the solution you'd like
Pack bits efficiently!
Additional context
I had thought this might be a breaking change, but I've convinced myself it is not for everything that gets serialized to JSON. The reason is that JSON objects have unordered fields, so as long as things go through the serialization step it doesn't matter how they're packed when they are deserialized into a given runtime's structs.
This might not be the case for other serialization formats, e.g., MessagePack may be fine but bincode will probably not (we need to doublecheck).
Is your feature request related to a problem? Please describe. While working on
Printout
I noticed that we don't optimally pack bits. Ideally we should pack bits so that fields that take up more space are fields earlier in the struct, e.g.packs less efficiently than
which leads to memory bloat and performance degradation (since caches will be more frequently invalidated).
Describe the solution you'd like Pack bits efficiently!
Additional context I had thought this might be a breaking change, but I've convinced myself it is not for everything that gets serialized to JSON. The reason is that JSON objects have unordered fields, so as long as things go through the serialization step it doesn't matter how they're packed when they are deserialized into a given runtime's
struct
s.This might not be the case for other serialization formats, e.g., MessagePack may be fine but bincode will probably not (we need to doublecheck).