Skip to content

Commit 95b765f

Browse files
authored
Optimize xapi<->xenopsd communication (#6549)
Some refactoring, but the most important commit is this one-line change that greatly improves things on its own: --- xenopsd: Remove `data/updated` from the list of watched paths "data/updated" is not read or used anywhere in xenopsd or xapi: * xapi_guest_agent's last_updated field is just Unix.gettimeofday (). * xapi_xenops removes "data/updated" from the guest agent state altogether before checking if it's changed: ``` let ignored_keys = ["data/meminfo_free"; "data/updated"; "data/update_cnt"] ``` So there is no need to watch this path at all. This greatly reduces unnecessary traffic between xapi and xenopsd, since any VM with a guest agent would write to data/updated once every 60 seconds, which would generate a Dynamic.Vm event, making xapi call xenopsd's VM.stat to rescan the domain's xenstore tree and perform several hypercalls. Almost always, this would be completely unnecessary as nothing else about the VM would change, but a lot of work would be done anyhow.
2 parents a7e874d + 5d0fb87 commit 95b765f

File tree

7 files changed

+330
-331
lines changed

7 files changed

+330
-331
lines changed

ocaml/xapi-idl/lib/updates.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ functor
6666
)
6767

6868
let inject_barrier id filterfn t =
69+
let filterfn key _ = filterfn key in
6970
( {
7071
map= t.map
7172
; barriers=

ocaml/xapi-idl/lib/updates.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module Updates : functor (Interface : INTERFACE) -> sig
6464
(* [inject_barrier n p t] Inject a barrier identified by [n] into [t]. The
6565
barrier will contain a snapshot of all current updates that match the
6666
predicate [p]. *)
67-
val inject_barrier : int -> (Interface.Dynamic.id -> int -> bool) -> t -> unit
67+
val inject_barrier : int -> (Interface.Dynamic.id -> bool) -> t -> unit
6868

6969
(* Removes a barrier *)
7070
val remove_barrier : int -> t -> unit

ocaml/xapi-idl/lib_test/updates_test.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ let test_inject_barrier () =
8484
let u = M.empty scheduler in
8585
M.add update_a u ;
8686
M.add update_b u ;
87-
M.inject_barrier 1 (fun _ _ -> true) u ;
87+
M.inject_barrier 1 (fun _ -> true) u ;
8888
M.add update_a u ;
8989
M.add update_c u ;
9090
let barriers, updates, _id = M.get "dbg" None (Some 1) u in
@@ -107,7 +107,7 @@ let test_remove_barrier () =
107107
let u = M.empty scheduler in
108108
M.add update_a u ;
109109
M.add update_b u ;
110-
M.inject_barrier 1 (fun _ _ -> true) u ;
110+
M.inject_barrier 1 (fun _ -> true) u ;
111111
M.add update_a u ;
112112
M.add update_c u ;
113113
M.remove_barrier 1 u ;
@@ -125,7 +125,7 @@ let test_inject_barrier_rpc () =
125125
let u = M.empty scheduler in
126126
M.add update_a u ;
127127
M.add update_b u ;
128-
M.inject_barrier 1 (fun _ _ -> true) u ;
128+
M.inject_barrier 1 (fun _ -> true) u ;
129129
M.add update_a u ;
130130
M.add update_c u ;
131131
let barriers, updates, _id = M.get "dbg" None (Some 1) u in
@@ -175,7 +175,7 @@ let test_filter () =
175175
let test_dump () =
176176
let u = M.empty scheduler in
177177
M.add update_a u ;
178-
M.inject_barrier 1 (fun _ _ -> true) u ;
178+
M.inject_barrier 1 (fun _ -> true) u ;
179179
let dump = M.Dump.make u in
180180
let dumped_rpc = M.Dump.rpc_of_dump dump in
181181
let expected_rpc =

0 commit comments

Comments
 (0)