From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UarVA-0002zL-89 for qemu-devel@nongnu.org; Fri, 10 May 2013 13:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UarV8-0006kv-Uz for qemu-devel@nongnu.org; Fri, 10 May 2013 13:53:04 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:42659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UarV8-0006gU-Bt for qemu-devel@nongnu.org; Fri, 10 May 2013 13:53:02 -0400 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 11 May 2013 03:40:08 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id D1E702BB0023 for ; Sat, 11 May 2013 03:52:36 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4AHqSLB17432720 for ; Sat, 11 May 2013 03:52:29 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4AHqZmO028996 for ; Sat, 11 May 2013 03:52:35 +1000 From: Anthony Liguori In-Reply-To: <1368188203-3407-9-git-send-email-pbonzini@redhat.com> References: <1368188203-3407-1-git-send-email-pbonzini@redhat.com> <1368188203-3407-9-git-send-email-pbonzini@redhat.com> Date: Fri, 10 May 2013 12:52:22 -0500 Message-ID: <87sj1uiuy1.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH for-1.5 8/9] qom: simplify object_class_dynamic_cast, part 1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: Andreas Faerber , Aurelien Jarno , mst@redhat.com Paolo Bonzini writes: > Access everything from the class. > > Signed-off-by: Paolo Bonzini > --- > qom/object.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/qom/object.c b/qom/object.c > index f5f416b..f82f12c 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -457,15 +457,13 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, > { > ObjectClass *ret = NULL; > TypeImpl *target_type; > - TypeImpl *type; > > if (!class) { > return NULL; > } > > /* A simple fast path that can trigger a lot for leaf classes. */ > - type = class->type; > - if (type->name == typename) { > + if (class->type->name == typename) { This won't trigger because we unconditionally strdup(). Can you add this the bit from my patch that sets ->name appropriately? Aurelien, can you try the resulting series with --{enable,disable}-qom-casts? My suspicion is that this is the primary source of speed up. If you can make an image available too, I can try this myself. Regards, Anthony Liguori > return class; > } > > @@ -475,7 +473,7 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, > return NULL; > } > > - if (type->class->interfaces && > + if (class->interfaces && > type_is_ancestor(target_type, type_interface)) { > int found = 0; > GSList *i; > @@ -493,7 +491,7 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, > if (found > 1) { > ret = NULL; > } > - } else if (type_is_ancestor(type, target_type)) { > + } else if (type_is_ancestor(class->type, target_type)) { > ret = class; > } > > -- > 1.8.1.4