From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zk8Ir-0006F4-T2 for qemu-devel@nongnu.org; Thu, 08 Oct 2015 06:20:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zk8Iq-0006MD-Ci for qemu-devel@nongnu.org; Thu, 08 Oct 2015 06:20:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zk8Iq-0006Ll-5O for qemu-devel@nongnu.org; Thu, 08 Oct 2015 06:20:00 -0400 Date: Thu, 8 Oct 2015 11:19:54 +0100 From: "Daniel P. Berrange" Message-ID: <20151008101954.GH31017@redhat.com> References: <018801d1003d$bd86fb00$3894f100$@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <018801d1003d$bd86fb00$3894f100$@samsung.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] qobject: Replace property list with GHashTable Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Fedin Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, Andreas =?utf-8?Q?F=C3=A4rber?= Nit-pick on subject line - s/qobject/qom/ and also copy Andreas F=C3=A4rber 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. Si= nce > every pin is represented as a property, number of these properties beco= mes > very large. Every property add first makes sure there's no duplicates. > Traversing the list becomes very slow, therefore qemu initialization ta= kes > significant time (several seconds for e. g. 16 CPUs). >=20 > This patch replaces list with GHashTable, making lookup very fast. The = only > drawback is that object_child_foreach() and object_child_foreach_recurs= ive() > 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. >=20 > Signed-off-by: Pavel Fedin > --- > v1 =3D> 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(-) >=20 > 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; > =20 > - 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) > } > } > =20 > +static void property_destroy(gpointer data) > +{ > + ObjectProperty *prop =3D 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 =3D data; > TypeImpl *ti =3D obj->class->type; > =20 > - object_property_del_all(obj); > + g_hash_table_unref(obj->properties); > object_deinit(obj, ti); > =20 > g_assert(obj->ref =3D=3D 0); > void object_property_del(Object *obj, const char *name, Error **errp) > { > - ObjectProperty *prop =3D object_property_find(obj, name, errp); > - if (prop =3D=3D NULL) { > + if (g_hash_table_remove(obj->properties, name)) { > return; > } > =20 > - 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 --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|