[Libosinfo] [RFC PATCH 0/5] various optimizations
Giuseppe Scrivano
gscrivan at redhat.com
Wed Jun 4 10:18:02 UTC 2014
Christophe Fergeau <cfergeau at redhat.com> writes:
> On Tue, Jun 03, 2014 at 06:52:47PM +0200, Giuseppe Scrivano wrote:
>> Christophe Fergeau <cfergeau at redhat.com> writes:
>> > The call to osinfo_loader_get_device() can also hide a g_object_new(),
>> > which can be heavy.
>>
>> indeed, g_object_new seems to be very slow. I will try to play with
>> what Daniel suggested and see if it makes any difference.
>
> Some profiling should tell you if the expensive part is the object
> creation or the hash table insertion, and how much slower one is
> compared to the ohter. Did you get these numbers by any chance?
for my tests I've used a simple C program statically linked to
libosinfo (compiled with -O0):
#include <osinfo/osinfo.h>
int main()
{
GError *error;
OsinfoLoader *loader = osinfo_loader_new();
osinfo_loader_process_default_path(loader, &error);
OsinfoDb *db = osinfo_loader_get_db(loader);
osinfo_db_get_os_list(db);
return 0;
}
This series was applied to the libosinfo source.
function total time spent in the function
osinfo_loader_get_device 32.83%
osinfo_db_get_device 2.96%
osinfo_db_add_device 4.50%
osinfo_db_new 24.97%
so creating a new GObject is very slow. I thought about creating just a
model object and then clone it instead of going trough the gobject
constructors for every instance. Does it sound like a good idea? (I am
not still sure if g_type_create_instance will be enough to achieve this,
haven't looked into details).
Regards,
Giuseppe
More information about the Libosinfo
mailing list