]> xenbits.xensource.com Git - xen.git/commit
tools/ocaml/xenctrl: Make domain_getinfolist tail recursive
authorEdwin Török <edvin.torok@citrix.com>
Tue, 1 Nov 2022 17:59:16 +0000 (17:59 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 1 Dec 2022 16:07:17 +0000 (16:07 +0000)
commitc3b6be714c64aa62b56d0bce96f4b6a10b5c2078
tree7acda9777b01224ad8abf757ebd91fbe47d8c94c
parent25b55688e1f20ebb1bb15d0e82079e91cd787e5b
tools/ocaml/xenctrl: Make domain_getinfolist tail recursive

domain_getinfolist() is quadratic with the number of domains, because of the
behaviour of the underlying hypercall.  xenopsd was further observed to be
wasting excessive quantites of time manipulating the list of already-obtained
domains.

Implement a tail recursive `rev_concat` equivalent to `concat |> rev`, and use
it instead of calling `@` multiple times.

An incidental benefit is that the list of domains will now be in domid order,
instead of having pairs of 2 domains changing direction every time.

In a scalability testing scenario with ~1000 VMs, a combination of this and
the subsequent change takes xenopsd's wallclock time in domain_getinfolist()
down from 88% to 0.02%

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Tested-by: Pau Ruiz Safont <pau.safont@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/libs/xc/xenctrl.ml