Improve luxid QueryInstances performance for large clusters
Improve luxid QueryInstances performance for large clusters

Do this by implementing and using getInstanceByName on hot paths.

This is much faster than the more generic but extremely inefficient
getInstance which can match by UUID, exact name, or name prefixes.
instances are stored in a Map keyed by UUID, and if that lookup fails,
getInstance creates a temporary Map of names to instances, and
does a linear scan of it.

On a large test cluster (80 nodes, 1000 instances), getInstance used
~65% of the total CPU time and 80% of the heap allocations for a luxid
that started, handled 2 QueryInstance calls, and shut down.

This patch reduces the time to respond to the client for each of these
calls from ~18s to ~2.5s, and the total luxid heap allocations from
~11.5GB to ~2.4GB.

Signed-off-by: Brian Foley <a00e555871a6a538e97f8c44307104c884f8e869@google.com>
Reviewed-by: Klaus Aehlig <4ce51de36d9068cd7db2eec1151e0f3f95419008@google.com>

ganeti/ganeti,onponomarev/ganeti,mbakke/ganeti,leshchevds/ganeti,yiannist/ganeti,mbakke/ganeti,leshchevds/ganeti,leshchevds/ganeti,mbakke/ganeti,ganeti/ganeti,ganeti/ganeti,andir/ganeti,onponomarev/ganeti,yiannist/ganeti,andir/ganeti,yiannist/ganeti,andir/ganeti