Dict parsing question

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Fri Dec 15 21:03:26 UTC 2023


On Fri, 15 Dec 2023 15:55:38 +0000, Simon McVittie wrote:

> It's misleading to say that the beginning of a dict is 8-byte-aligned
> ...

You are right about that, because the spec did say “dict entries”, not
“dicts” (as I thought).

> The array is *4*-byte aligned, the same as any other array (because it
> starts with a 4-byte length). After the length, the dict entries
> inside it are 8-byte aligned, the same as structs.

It seems to me that having aligned fields within wire protocols is just
a recipe for adding to the confusion. Is there really a measurable
performance improvement from keeping things aligned? Is the wasted
space worth it? And then we have the issue that the optimum alignment
for some things on 64-bit architectures is different from that for
32-bit ones. So layout decisions made back in the 32-bit era start to
look a bit anachronistic now that 64-bit machines are dominant.

“Premature optimization is the root of all evil.”
  -- variously attributed to Tony Hoare or Donald Knuth


More information about the dbus mailing list