On 25/11/24 12:03, Daniel P. Berrangé wrote:
On Fri, Nov 22, 2024 at 09:49:23AM +0100, Thomas Huth wrote:
While looking at the QEMU binary with "pahole", I noticed that we
could optimize the size of MachineClass a little bit: So far we
are using a mixture of a bitfield and single "bool" members here
for the boolean flags. Declaring all flags as part of the bitfield
helps to shrink the size of the struct a little bit.

Signed-off-by: Thomas Huth <th...@redhat.com>
---
  It's just a micro-optimization (the size of the struct decreases by
  eight bytes), so I'm not sure whether it's worth the effort...?

Given that this is a QOM class, rather than an instance, we'll
only ever save memory once. That's an unmeasurably small real
world improvement. We also have no ABI reasons to use bitfields
for this.

So if anything I'd suggest we take the opposite approach, and
eliminate that bitfields in favour of just using 'bool' for
everything, on the basis that a bitfield has no reason to
exist.

While I agree with you on this, and the patch would take less
than 1 minute, all of these fields are legacy options. Maybe
a good opportunity to tackle this technical debt.

I.e. as of 2024 having to set no_parallel/no_floppy/no_cdrom
to true to every new machines seems counter intuitive.

This could become useful if we aim to institute a general ban
on the use of bitfields in QEMU, as a way to avoid the struct
packing differences on Windows.

  include/hw/boards.h | 20 ++++++++++----------
  1 file changed, 10 insertions(+), 10 deletions(-)


Reply via email to