Permalink
Browse files

Add timing stats to Cancel_tasks.update_all_allowed_operations

Signed-off-by: John Else <john.else@citrix.com>
  • Loading branch information...
1 parent 3569d51 commit ef7819c4b08fee94a48c2dc1485aaef5e8381645 @johnelse johnelse committed with jonludlam Sep 20, 2012
Showing with 30 additions and 24 deletions.
  1. +30 −24 ocaml/xapi/cancel_tasks.ml
View
@@ -24,37 +24,43 @@ let safe_wrapper n f x =
log_backtrace ()
let update_all_allowed_operations ~__context =
+ let open Stats in
let all_vms = Db.VM.get_all ~__context
and all_vbds = Db.VBD.get_all ~__context
and all_vifs = Db.VIF.get_all ~__context
and all_vdis = Db.VDI.get_all ~__context
and all_srs = Db.SR.get_all ~__context
and all_pbds = Db.PBD.get_all ~__context
and all_hosts = Db.Host.get_all ~__context in
- debug "Updating allowed operations: VM";
- List.iter (safe_wrapper "allowed_ops - VMs" (fun self -> Xapi_vm_lifecycle.update_allowed_operations ~__context ~self)) all_vms;
- debug "Finished updating allowed operations: VM";
- debug "Updating allowed operations: VBD";
- List.iter (safe_wrapper "allowed_ops - VBDs" (fun self -> Xapi_vbd_helpers.update_allowed_operations ~__context ~self)) all_vbds;
- debug "Finished updating allowed operations: VBD";
- debug "Updating allowed operations: VIF";
- List.iter (safe_wrapper "allowed_ops - VIFs" (fun self -> Xapi_vif_helpers.update_allowed_operations ~__context ~self)) all_vifs;
- debug "Finished updating allowed operations: VIF";
- debug "Updating allowed operations: VDI";
- let sr_records = List.map (fun sr -> (sr, Db.SR.get_record_internal ~__context ~self:sr)) all_srs in
- let pbd_records = List.map (fun pbd -> (pbd, Db.PBD.get_record ~__context ~self:pbd)) all_pbds in
- let vbd_records = List.map (fun vbd -> (vbd, Db.VBD.get_record_internal ~__context ~self:vbd)) all_vbds in
- List.iter (safe_wrapper "allowed_ops - VDIs"
- (fun self -> Xapi_vdi.update_allowed_operations_internal ~__context ~self ~sr_records ~pbd_records ~vbd_records)) all_vdis;
- debug "Finished updating allowed operations: VDI";
- debug "Updating allowed operations: SR";
- List.iter (safe_wrapper "allowed_ops" (fun self ->
- Db.SR.set_current_operations ~__context ~self ~value:[];
- Xapi_sr.update_allowed_operations ~__context ~self)) all_srs;
- debug "Finished updating allowed operations: SR";
- debug "Updating allowed operations: host";
- List.iter (safe_wrapper "allowed_ops - host" (fun self -> Xapi_host_helpers.update_allowed_operations ~__context ~self)) all_hosts;
- debug "Finished updating allowed operations: host"
+ time_this "Cancel_tasks.update_all_allowed_operations: VM" (fun () ->
+ debug "Updating allowed operations: VM";
+ List.iter (safe_wrapper "allowed_ops - VMs" (fun self -> Xapi_vm_lifecycle.update_allowed_operations ~__context ~self)) all_vms;
+ debug "Finished updating allowed operations: VM");
+ time_this "Cancel_tasks.update_all_allowed_operations: VBD" (fun () ->
+ debug "Updating allowed operations: VBD";
+ List.iter (safe_wrapper "allowed_ops - VBDs" (fun self -> Xapi_vbd_helpers.update_allowed_operations ~__context ~self)) all_vbds;
+ debug "Finished updating allowed operations: VBD");
+ time_this "Cancel_tasks.update_all_allowed_operations: VIF" (fun () ->
+ debug "Updating allowed operations: VIF";
+ List.iter (safe_wrapper "allowed_ops - VIFs" (fun self -> Xapi_vif_helpers.update_allowed_operations ~__context ~self)) all_vifs;
+ debug "Finished updating allowed operations: VIF");
+ time_this "Cancel_tasks.update_all_allowed_operations: VDI" (fun () ->
+ debug "Updating allowed operations: VDI";
+ let sr_records = List.map (fun sr -> (sr, Db.SR.get_record_internal ~__context ~self:sr)) all_srs in
+ let pbd_records = List.map (fun pbd -> (pbd, Db.PBD.get_record ~__context ~self:pbd)) all_pbds in
+ let vbd_records = List.map (fun vbd -> (vbd, Db.VBD.get_record_internal ~__context ~self:vbd)) all_vbds in
+ List.iter (safe_wrapper "allowed_ops - VDIs"
+ (fun self -> Xapi_vdi.update_allowed_operations_internal ~__context ~self ~sr_records ~pbd_records ~vbd_records)) all_vdis;
+ debug "Finished updating allowed operations: VDI");
+ time_this "Cancel_tasks.update_all_allowed_operations: SR" (fun () ->
+ debug "Updating allowed operations: SR";
+ List.iter (safe_wrapper "allowed_ops" (fun self ->
+ Db.SR.set_current_operations ~__context ~self ~value:[];
+ Xapi_sr.update_allowed_operations ~__context ~self)) all_srs;
+ debug "Finished updating allowed operations: SR";
+ debug "Updating allowed operations: host";
+ List.iter (safe_wrapper "allowed_ops - host" (fun self -> Xapi_host_helpers.update_allowed_operations ~__context ~self)) all_hosts;
+ debug "Finished updating allowed operations: host")
(* !!! This code was written in a world when tasks, current_operations and allowed_operations were persistent.
This is no longer the case (we changed this to reduce writes to flash for OEM case + to simplify xapi logic elsewhere).

0 comments on commit ef7819c

Please sign in to comment.