Integration / D Bus Interview Questions
Why is message alignment important in D-Bus marshaling?
D-Bus's binary wire format aligns each data type to a boundary matching its size, for example 4-byte alignment for a 32-bit integer and 8-byte alignment for a 64-bit integer or double, padding with filler bytes as needed before a value that isn't already at the right offset.
This matters for performance: with values guaranteed to start on their natural alignment boundary, a receiving implementation can often read them directly from the buffer using native machine types, without the extra step of copying bytes into a separately aligned location first. On architectures that fault or slow down on unaligned memory access, this isn't just a performance nicety, it avoids real correctness or speed problems entirely.
The cost is a slightly larger message on the wire due to padding bytes, but this is a deliberate trade-off in the D-Bus specification favoring fast, low-overhead marshaling and unmarshaling over minimal message size.
More Related questions...