qemu-img is using 8 parallel coroutines by default. I tested up to 16
parallel coroutines and it seems that 8 gives good results.
nbdkit uses 16 threads by default. Testing nbdkit with qemu-img show
that 8 threads give good results.
Make nbdkit thread count configurable, and configure it to 8 threads in
the rhv upload output.
Testing rhv-upload-plugin show small improvement (~6%) in total
connection time. Compared with last version using single connection, we
are now 50% faster.
Results are not stable, we need to test this with bigger images and real
environment.
[connection 1 ops, 3.561693 s]
[dispatch 550 ops, 2.808350 s]
[write 470 ops, 2.482875 s, 316.06 MiB, 127.30 MiB/s]
[zero 78 ops, 0.178174 s, 1.26 GiB, 7.05 GiB/s]
[flush 2 ops, 0.000211 s]
[connection 1 ops, 3.561724 s]
[dispatch 543 ops, 2.836738 s]
[write 472 ops, 2.503561 s, 341.62 MiB, 136.46 MiB/s]
[zero 69 ops, 0.162465 s, 1.12 GiB, 6.89 GiB/s]
[flush 2 ops, 0.000181 s]
[connection 1 ops, 3.566931 s]
[dispatch 536 ops, 2.807226 s]
[write 462 ops, 2.508345 s, 326.12 MiB, 130.02 MiB/s]
[zero 72 ops, 0.141442 s, 1.30 GiB, 9.20 GiB/s]
[flush 2 ops, 0.000158 s]
[connection 1 ops, 3.564396 s]
[dispatch 563 ops, 2.853623 s]
[write 503 ops, 2.592482 s, 361.44 MiB, 139.42 MiB/s]
[zero 58 ops, 0.113708 s, 1.01 GiB, 8.88 GiB/s]
[flush 2 ops, 0.000149 s]
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
v2v/nbdkit.ml | 4 ++++
v2v/nbdkit.mli | 1 +
v2v/output_rhv_upload.ml | 3 +++
3 files changed, 8 insertions(+)
diff --git a/v2v/nbdkit.ml b/v2v/nbdkit.ml
index 46b20c9d..c7a92bf0 100644
--- a/v2v/nbdkit.ml
+++ b/v2v/nbdkit.ml
@@ -72,6 +72,7 @@ type cmd = {
exportname : string option;
readonly : bool;
selinux_label : string option;
+ threads : int;
verbose : bool;
}
@@ -84,6 +85,7 @@ let new_cmd = {
exportname = None;
readonly = false;
selinux_label = None;
+ threads = 16;
verbose = false;
}
@@ -93,6 +95,7 @@ let add_debug_flag cmd name value =
let set_exportname cmd v = { cmd with exportname = Some v }
let set_readonly cmd v = { cmd with readonly = v }
let set_selinux_label cmd v = { cmd with selinux_label = v }
+let set_threads cmd v = { cmd with threads = v }
let set_verbose cmd v = { cmd with verbose = v }
let set_plugin cmd v = { cmd with plugin = Some v }
let add_filter cmd v = { cmd with filters = v :: cmd.filters }
@@ -136,6 +139,7 @@ let run_unix cmd =
add_arg "--newstyle";
add_arg "--pidfile"; add_arg pidfile;
add_arg "--unix"; add_arg sock;
+ add_arg "--threads"; add_arg (string_of_int cmd.threads);
(* Reduce verbosity in nbdkit >= 1.17.4. *)
let version = version (config ()) in
diff --git a/v2v/nbdkit.mli b/v2v/nbdkit.mli
index d927fe40..85eb75b6 100644
--- a/v2v/nbdkit.mli
+++ b/v2v/nbdkit.mli
@@ -56,6 +56,7 @@ val add_debug_flag : cmd -> string -> string -> cmd
val set_exportname : cmd -> string -> cmd
val set_readonly : cmd -> bool -> cmd
val set_selinux_label : cmd -> string option -> cmd
+val set_threads : cmd -> int -> cmd
val set_verbose : cmd -> bool -> cmd
(** Set various command line flags. *)
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
index 3cf3bf4c..7d3010aa 100644
--- a/v2v/output_rhv_upload.ml
+++ b/v2v/output_rhv_upload.ml
@@ -208,6 +208,9 @@ class output_rhv_upload output_alloc output_conn
let nbdkit_cmd = Nbdkit.set_plugin nbdkit_cmd nbdkit_python_plugin in
let nbdkit_cmd = Nbdkit.add_arg nbdkit_cmd "script" (Python_script.path
plugin_script) in
+ (* Match number of parallel coroutines in qemu-img *)
+ let nbdkit_cmd = Nbdkit.set_threads nbdkit_cmd 8 in
+
let nbdkit_cmd =
if have_selinux then
(* Label the socket so qemu can open it. *)
--
2.26.2