mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 11:46:49 +00:00
perf(computes): the create page reads the host's capabilities once
Measured on the create page: 751 ms and 72 libvirt calls, now 123 ms and 13. Its getters parsed the host's capabilities some 60 times, each read from libvirt. A connection object (one per request) now reads them once, and the domain capabilities once per emulator, arch, machine and domain type. The VM page's cached_reads block no longer needs its own copy.
This commit is contained in:
parent
a87fbf739f
commit
9adc808d26
4 changed files with 103 additions and 34 deletions
|
|
@ -491,11 +491,12 @@ class wvmInstance(wvmConnect):
|
|||
def cached_reads(self):
|
||||
"""
|
||||
Within the block the domain XML (per flags value), the VM's state,
|
||||
the host's capabilities and info, and each disk's volume are read
|
||||
from libvirt once, for pages that only read: a VM page reads the XML
|
||||
in some 30 getters and each disk in two lists. Code that changes the VM
|
||||
must not run inside: most changes (devices, QoS, memory) do not go
|
||||
through _defineXML, the only call that drops the cache.
|
||||
the host's info and each disk's volume are read from libvirt once
|
||||
(the host's capabilities are read once per object anyway), for pages
|
||||
that only read: a VM page reads the XML in some 30 getters and each
|
||||
disk in two lists. Code that changes the VM must not run inside: most
|
||||
changes (devices, QoS, memory) do not go through _defineXML, the only
|
||||
call that drops the cache.
|
||||
"""
|
||||
if self._read_cache is not None:
|
||||
raise RuntimeError("cached_reads blocks do not nest")
|
||||
|
|
@ -521,13 +522,6 @@ class wvmInstance(wvmConnect):
|
|||
self._read_cache.clear()
|
||||
return self.wvm.defineXML(xml)
|
||||
|
||||
def get_cap_xml(self):
|
||||
return self._cached("capabilities", super().get_cap_xml)
|
||||
|
||||
def get_dom_cap_xml(self, arch, machine):
|
||||
read = super().get_dom_cap_xml
|
||||
return self._cached(("domain capabilities", arch, machine), lambda: read(arch, machine))
|
||||
|
||||
def _host_info(self):
|
||||
return self._cached("host info", self.wvm.getInfo)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue