Received: from eggs.gnu.org ([2001:4830:134:3::10]:48911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJjVm-0000SC-7g for qemu-devel@nongnu.org; Mon, 27 Jul 2015 10:36:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJjVh-0003Yx-70 for qemu-devel@nongnu.org; Mon, 27 Jul 2015 10:36:14 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:59745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJjVh-0003Xd-1q for qemu-devel@nongnu.org; Mon, 27 Jul 2015 10:36:09 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NS5006A8HW69H20@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Mon, 27 Jul 2015 15:36:06 +0100 (BST) From: Pavel Fedin References: <507c11db2c97eef33de0e4f7168076d5c39f0867.1436866326.git.p.fedin@samsung.com> <20150727114203.GB18731@redhat.com> In-reply-to: <20150727114203.GB18731@redhat.com> Date: Mon, 27 Jul 2015 17:36:05 +0300 Message-id: <003301d0c879$92125f60$b6371e20$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable Content-language: ru Subject: Re: [Qemu-devel] [PATCH v4 2/2] QOM: object_property_add() performance improvement List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "'Daniel P. Berrange'" Cc: 'Peter Crosthwaite' , qemu-devel@nongnu.org, =?utf-8?Q?'Andreas_F=C3=A4rber'?= Hello! > IIUC, the performance problem with object_property_add is caused by > the fact that every time we add a property we have to do a linear > search over every existing property running strcmp to see if the > new property already exists. Yes, exactly. And this linear search gets extremely slow with lots of = CPUs multipled by lots of interrupts. > This is compounded by the array expansion code which does a linear > search trying index 0, then index 1, etc, until it is able to add > the property without error. So this code becomes O(n^2) complexity. >=20 > Your change is avoiding the problemm in array expansion code by > storing the max index, but is still leaving the linear search in > check for duplicate property name. So the code is still O(n) on > the number of properties. Yes. > I seems that we should also look at changing the 'properties' > field to use a hash table instead of linked list, so that we > have O(1) access in all the methods which add/remove/lookup > properties. Absolutely. This would be different change, but i decided to postpone = it until i can upstream this one. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia