forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CP-51692: use Event.from instead of Event.next (xapi-project#6125)
Event.next can lose events, and we try to encourage our API users to always use Event.from instead. My understanding (which could be wrong) is that Event.from will give you the events since a given point in time (token), whereas Event.next only gives you even from when you called the API (missing events between API calls). This PR introduces a feature flag that we can use to switch the interal users of Event.next to Event.from. Doing so I've discovered a bug in ocaml-rpc, where `int32_of_rpc` doesn't accept Int32 as input, just Int. There is a workaround here for now, but I intend to fix this upstream instead, hence the draft PR.
- Loading branch information
Showing
8 changed files
with
245 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
open Bechamel | ||
|
||
let () = | ||
Suite_init.harness_init () ; | ||
Debug.set_level Syslog.Warning | ||
|
||
let __context, _ = Test_event_common.event_setup_common () | ||
|
||
let allocate_tasks n = | ||
( __context | ||
, Array.init n @@ fun i -> | ||
let label = Printf.sprintf "task %d" i in | ||
Xapi_task.create ~__context ~label ~description:"test task" | ||
) | ||
|
||
let free_tasks (__context, tasks) = | ||
let () = | ||
tasks |> Array.iter @@ fun self -> Xapi_task.destroy ~__context ~self | ||
in | ||
() | ||
|
||
let set_pending tasks = | ||
tasks | ||
|> Array.iter @@ fun self -> | ||
Xapi_task.set_status ~__context ~self ~value:`pending | ||
|
||
let run_tasks _n (__context, tasks) = | ||
set_pending tasks ; | ||
let () = | ||
tasks | ||
|> Array.iter @@ fun self -> | ||
Xapi_task.set_status ~__context ~self ~value:`success | ||
in | ||
tasks |> Array.iter @@ fun t -> Helpers.Task.wait_for ~__context ~tasks:[t] | ||
|
||
let run_tasks' _n (__context, tasks) = | ||
set_pending tasks ; | ||
let () = | ||
tasks | ||
|> Array.iter @@ fun self -> | ||
Xapi_task.set_status ~__context ~self ~value:`success | ||
in | ||
Helpers.Task.wait_for ~__context ~tasks:(Array.to_list tasks) | ||
|
||
module D = Debug.Make (struct let name = __MODULE__ end) | ||
|
||
let run_tasks'' n (__context, tasks) = | ||
set_pending tasks ; | ||
let finished = Atomic.make 0 in | ||
let (t : Thread.t) = | ||
Thread.create | ||
(fun () -> | ||
for _ = 1 to 10 do | ||
Thread.yield () | ||
done ; | ||
tasks | ||
|> Array.iter @@ fun self -> | ||
Xapi_task.set_status ~__context ~self ~value:`success ; | ||
Atomic.incr finished | ||
) | ||
() | ||
in | ||
Helpers.Task.wait_for ~__context ~tasks:(Array.to_list tasks) ; | ||
let f = Atomic.get finished in | ||
assert (f = n || f = n - 1) ; | ||
Thread.join t | ||
|
||
let benchmarks = | ||
Test.make_grouped ~name:"Task latency" | ||
[ | ||
Test.make_indexed_with_resource ~name:"task complete+wait latency" | ||
~args:[1; 10; 100] Test.multiple ~allocate:allocate_tasks | ||
~free:free_tasks (fun n -> Staged.stage (run_tasks n) | ||
) | ||
; Test.make_indexed_with_resource ~name:"task complete+wait all latency" | ||
~args:[1; 10; 100] Test.multiple ~allocate:allocate_tasks | ||
~free:free_tasks (fun n -> Staged.stage (run_tasks' n) | ||
) | ||
; Test.make_indexed_with_resource | ||
~name:"task complete+wait all latency (thread)" ~args:[1; 10; 100] | ||
Test.multiple ~allocate:allocate_tasks ~free:free_tasks (fun n -> | ||
Staged.stage (run_tasks'' n) | ||
) | ||
] | ||
|
||
let () = Bechamel_simple_cli.cli benchmarks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(executables | ||
(names bench_tracing bench_uuid) | ||
(libraries tracing bechamel bechamel-notty notty.unix tracing_export threads.posix fmt notty uuid) | ||
(names bench_tracing bench_uuid bench_throttle2) | ||
(libraries tracing bechamel bechamel-notty notty.unix tracing_export threads.posix fmt notty uuid xapi_aux tests_common log xapi_internal) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.