All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Pavel Fedin <p.fedin@samsung.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v2] qobject: Replace property list with GHashTable
Date: Thu, 8 Oct 2015 11:19:54 +0100	[thread overview]
Message-ID: <20151008101954.GH31017@redhat.com> (raw)
In-Reply-To: <018801d1003d$bd86fb00$3894f100$@samsung.com>

Nit-pick on subject line - s/qobject/qom/ and also copy
Andreas Färber on the patch, since he's the primary
maintainer of the QOM subsystem.

On Tue, Oct 06, 2015 at 04:48:53PM +0300, Pavel Fedin wrote:
> ARM GICv3 systems with large number of CPUs create lots of IRQ pins. Since
> every pin is represented as a property, number of these properties becomes
> very large. Every property add first makes sure there's no duplicates.
> Traversing the list becomes very slow, therefore qemu initialization takes
> significant time (several seconds for e. g. 16 CPUs).
> 
> This patch replaces list with GHashTable, making lookup very fast. The only
> drawback is that object_child_foreach() and object_child_foreach_recursive()
> cannot modify their objects during traversal, since GHashTableIter does not
> have modify-safe version. However, the code seems not to modify objects via
> these functions.
> 
> Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
> ---
> v1 => v2:
> - Fixed stupid bug in object_unparent(), use correct object
> ---
>  include/qom/object.h |  4 +--
>  qmp.c                |  8 +++--
>  qom/object.c         | 98 +++++++++++++++++++++++-----------------------------
>  vl.c                 |  4 ++-
>  4 files changed, 54 insertions(+), 60 deletions(-)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index be7280c..b100923 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -345,7 +345,7 @@ typedef struct ObjectProperty
>      ObjectPropertyRelease *release;
>      void *opaque;
>  
> -    QTAILQ_ENTRY(ObjectProperty) node;
> +    Object *obj;

I have a patch which adds property registration against the
class, so requiring ObjectProperty to have a back-poointer
to an object instance is not desirable.

> diff --git a/qom/object.c b/qom/object.c
> index 4805328..1c7c42a 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -326,6 +326,20 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
>      }
>  }
>  
> +static void property_destroy(gpointer data)
> +{
> +    ObjectProperty *prop = data;
> +
> +    if (prop->release) {
> +        prop->release(prop->obj, prop->name, prop->opaque);
> +    }

Instead of calling the release() callback here, use a hash iterator
to call it from the object_finalize() method, before unref'ing the
hash table, and also call it from objecT_property_del directly. That
way you don't need to store the Object * back pointer in the
ObjectProperty struct.

> +
> +    g_free(prop->name);
> +    g_free(prop->type);
> +    g_free(prop->description);
> +    g_free(prop);
> +}

> @@ -410,7 +404,7 @@ static void object_finalize(void *data)
>      Object *obj = data;
>      TypeImpl *ti = obj->class->type;
>  
> -    object_property_del_all(obj);
> +    g_hash_table_unref(obj->properties);
>      object_deinit(obj, ti);
>  
>      g_assert(obj->ref == 0);

>  void object_property_del(Object *obj, const char *name, Error **errp)
>  {
> -    ObjectProperty *prop = object_property_find(obj, name, errp);
> -    if (prop == NULL) {
> +    if (g_hash_table_remove(obj->properties, name)) {
>          return;
>      }
>  
> -    if (prop->release) {
> -        prop->release(obj, name, prop->opaque);
> -    }
> -
> -    QTAILQ_REMOVE(&obj->properties, prop, node);
> -
> -    g_free(prop->name);
> -    g_free(prop->type);
> -    g_free(prop->description);
> -    g_free(prop);
> +    error_setg(errp, "Property '.%s' not found", name);
>  }

Overall I think this is a good improvement to make

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

      reply	other threads:[~2015-10-08 10:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-06 13:48 [Qemu-devel] [PATCH v2] qobject: Replace property list with GHashTable Pavel Fedin
2015-10-08 10:19 ` Daniel P. Berrange [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151008101954.GH31017@redhat.com \
    --to=berrange@redhat.com \
    --cc=afaerber@suse.de \
    --cc=p.fedin@samsung.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.