Comment 1 for bug 928910

Revision history for this message
Jay Pipes (jaypipes) wrote :

The existing method in _check_instance_not_already_created() of looking for a supplied instance name by looping over the return from driver.list_instances() is horribly inefficient.

Run the attached script to show how inefficient it is...

On a host with just 10 tiny instances running, doing a simple libvirt.connection.lookupByName(XXX) is an order of magnitude faster than looping through the results of listDomainsID() and looking up the name of the instance using lookupByID():

jpipes@librebox:~/repos/junk$ python test_check_instance_name.py
Num running domains: 10

name in [conn.lookupByID(i).name()
for i in conn.listDomainsID()]
Found: False
 took 0.00712 seconds

try: conn.lookupByName(x)
    found = True
except libvirt.libvirtError:
    found = False

libvir: QEMU error : Domain not found: no domain with matching name 'instance-1234567'
Found: False
 took 0.00083 seconds