On Fri, Jul 07, 2006 at 03:47:59PM +0100, Daniel P. Berrange wrote:
Attached is a patch to significantly increase scalability /
performance of
the xenDaemonLookupByID method. The current implementation would get a
list of all domain names from XenD, and then iterate doing a HTTP GET on
/xend/domain/[name] until the domain with match ID was found. THis had
O(n) complexity, with the result that when running on a system with 20
actives domains, 'virsh list' would have O(n^2) complexity needing ~230
HTTP calls, giving a runtime of ~9 seconds.
The patch is to make the code do a HTTP GET on /xend/domain/[id] which we
just discovered is a valid URL to access. This makes the method call O(1),
I should have guessed that earlier, especially after the report
last week about virDomainLookupByName(conn, "1") working fine ...
and 'virsh list' is now a saner O(n), and completes in ~1
second. While
still not great performance, this is certainly much better. I think it
ought to be possible to optimize the code still further so that XenD is
avoided altogether for simple commands which can be fullfilled purely
with data available from Hypervisor, but that will need further
investigation.
Please review the patch in case I missed any bugs / edge cases
just 2 small things:
in xenDaemonLookupByID, it seems (but I may have misread the patch)
that the free of name in the error code in case the rpc failed is a bit
risky and should be guarded by if (name != NULL)
and the documentation for the new function in xend_internal.h is the old
one inherited from Anthony first version, I somehow deprecated it, documenting
the function itself in the .c file, but it's just nitpicking :-)
thanks a lot for finding this ! Please apply :-)
Daniel
--
Daniel Veillard | Red Hat
http://redhat.com/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/