[Libosinfo] [RFC PATCH 0/5] various optimizations

Daniel P. Berrange berrange at redhat.com
Wed Jun 4 10:30:44 UTC 2014


On Wed, Jun 04, 2014 at 12:18:02PM +0200, Giuseppe Scrivano wrote:
> 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).

What's the actual wallclock time this demo takes to run for you ?

For me it is a fraction of a second, which seems pretty fast and shouldn't
be noticable by the user.

$ time ./demo 

real	0m0.238s
user	0m0.218s
sys	0m0.014s

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 :|




More information about the Libosinfo mailing list