WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] CA-45104: renice gzip so that it is nice to the other

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CA-45104: renice gzip so that it is nice to the other dom0 processes
From: Marcus Granado <marcus.granado@xxxxxxxxxx>
Date: Fri, 17 Sep 2010 11:16:43 +0100
Delivery-date: Fri, 17 Sep 2010 03:20:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
 stdext/gzip.ml |  21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)


# HG changeset patch
# User Marcus Granado <marcus.granado@xxxxxxxxxx>
# Date 1284397485 -3600
# Node ID 2095ed131b6343e0a08406246705e793aecd5ee7
# Parent  164f63521e8262f541059a13a7f1d4d5f5ed7f2b
CA-45104: renice gzip so that it is nice to the other dom0 processes

Signed-off-by: Marcus Granado <marcus.granado@xxxxxxxxxxxxx>

diff -r 164f63521e82 -r 2095ed131b63 stdext/gzip.ml
--- a/stdext/gzip.ml
+++ b/stdext/gzip.ml
@@ -28,6 +28,20 @@
   | Active  (** we provide a function which writes into the compressor and a 
fd output *)
   | Passive (** we provide an fd input and a function which reads from the 
compressor *)
 
+(* renice/ionice the pid with lowest priority so that it doesn't *)
+(* use up all cpu resources in dom0 *)
+let lower_priority pid =
+  let pid=Printf.sprintf "%d" (Forkhelpers.getpid pid) in
+  (* renice 19 -p pid *)
+  let renice="/usr/bin/renice" in
+  let renice_args = ["19";"-p";pid] in
+  let _=Forkhelpers.execute_command_get_output renice renice_args in
+  (* ionice -c 3 [idle] -p pid *)
+  let ionice="/usr/bin/ionice" in
+  let ionice_args = ["-c";"3";"-p";pid] in
+  let _=Forkhelpers.execute_command_get_output ionice ionice_args in
+  ()
+
 (** Runs a zcat process which is either:
     i) a compressor; or (ii) a decompressor
     and which has either
@@ -57,8 +71,11 @@
               zcat_out in                                 (* close this before 
waitpid *)
         let pid = Forkhelpers.safe_close_and_exec stdin stdout None [] gzip 
args in
         close close_now;
-        finally
-          (fun () -> f close_later)
+   finally
+     (fun () -> 
+       lower_priority pid;  (* lowest priority to gzip *)
+       f close_later
+     )
           (fun () ->
              let failwith_error s =
                let mode = if mode = Compress then "Compression" else 
"Decompression" in

Attachment: xen-api-libs.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>