Received: from eggs.gnu.org ([2001:4830:134:3::10]:50080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zz7OL-00028E-Rz for qemu-devel@nongnu.org; Wed, 18 Nov 2015 13:23:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zz7OG-00022o-WA for qemu-devel@nongnu.org; Wed, 18 Nov 2015 13:23:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zz7OG-00022k-Mp for qemu-devel@nongnu.org; Wed, 18 Nov 2015 13:23:32 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 2550C6566C for ; Wed, 18 Nov 2015 18:23:32 +0000 (UTC) From: Markus Armbruster References: <1447836791-369-1-git-send-email-eblake@redhat.com> <1447836791-369-29-git-send-email-eblake@redhat.com> Date: Wed, 18 Nov 2015 19:23:29 +0100 In-Reply-To: <1447836791-369-29-git-send-email-eblake@redhat.com> (Eric Blake's message of "Wed, 18 Nov 2015 01:53:03 -0700") Message-ID: <87r3jnjhem.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v12 28/36] qapi: Simplify QObject List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Luiz Capitulino Eric Blake writes: > The QObject hierarchy is small enough, and unlikely to grow further > (since we only use it to map to JSON and already cover all JSON > types), that we can simplify things by not tracking a separate > vtable, but just inline all two elements of the vtable QType > directly into QObject. We can drop qnull_destroy_obj() in the > process. > > This also has the nice benefit of moving the typename 'QType' > out of the way, so that the next patch can repurpose it for a > nicer name for 'qtype_code'. > > The various objects are now 8 bytes larger on 64-bit platforms, but > hopefully this is in the noise. If size is absolutely critical due > to cache line speed effects, we could do some bit packing to > restore the previous size (qtype_code currently only requires three > distinct bits, so we could assert an assumption that architecture > ABIs will give function pointers at least an 8-byte alignment, and > that the three low-order bits of destroy are always zero; or we > could use a bitfield for refcnt, with a maximum of SIZE_MAX/8, and > given that a QObject already occupies at least 8 bytes, that won't > artificially limit us). Or we could expose the currently static > destroy methods and instead create a table in qobject.h that maps > QType to destructor. That's what I'd do. A type registration function would keep the destructors static. But why bother. > But let's save any size compression for a > followup patch, if at all. Okay. > On the other hand, by avoiding a separate vtable, there is less > indirection, so use of QObjects may be slightly more efficient. > > However, as we don't have evidence pointing at either QObject size > or access speed as being a hot spot, I didn't think it was worth > benchmarking. > > Suggested-by: Markus Armbruster > Signed-off-by: Eric Blake Works for me.