Skip to content

Commit

Permalink
v2v/v2v.ml: Choose nbdcopy max requests for implicit buffer of 64M
Browse files Browse the repository at this point in the history
Pick the nbdcopy --requests parameter to target an implicit buffer
size of 64M inside nbdcopy.  However don't set requests < 64.

If request_size == 256K (the default) => requests = 256
If request_size == 8M => requests = 64 (buffer size 512M)
  • Loading branch information
rwmjones committed Feb 15, 2022
1 parent e533556 commit c943420
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions v2v/v2v.ml
Expand Up @@ -641,14 +641,27 @@ and nbdcopy ?request_size output_alloc input_uri output_uri =
*)
let cmd = ref [] in
List.push_back_list cmd [ "nbdcopy"; input_uri; output_uri ];

(match request_size with
| None -> ()
| Some size -> List.push_back cmd (sprintf "--request-size=%d" size)
);
(* Choose max requests to target an implicit buffer size of 64M. *)
let requests =
let target_buffer_size = 64 * 1024 * 1024 in
let request_size =
match request_size with
| None -> 256 * 1024 (* default in nbdcopy 1.10+ *)
| Some size -> size in
min 64 (target_buffer_size / request_size) in
List.push_back cmd (sprintf "--requests=%d" requests);

List.push_back cmd "--flush";
(*List.push_back cmd "--verbose";*)

if not (quiet ()) then List.push_back cmd "--progress";
if output_alloc = Types.Preallocated then List.push_back cmd "--allocated";

let cmd = !cmd in

if run_command cmd <> 0 then
Expand Down

0 comments on commit c943420

Please sign in to comment.