added logging for over provisioning model
authorpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 26 Apr 2016 14:44:34 +0000 (16:44 +0200)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Tue, 26 Apr 2016 14:44:34 +0000 (16:44 +0200)
src/emuvim/dcemulator/resourcemodel/upb/simple.py

index 08b3cf3..f4ec9ad 100644 (file)
@@ -37,6 +37,8 @@ class UpbSimpleCloudDcRM(BaseResourceModel):
         self.deactivate_mem_limit = deactivate_mem_limit
         self.single_cu = 0
         self.single_mu = 0
+        self.cpu_op_factor = 1.0  # over provisioning factor
+        self.mem_op_factor = 1.0
         self.raise_no_cpu_resources_left = True
         self.raise_no_mem_resources_left = True
         super(UpbSimpleCloudDcRM, self).__init__()
@@ -136,8 +138,8 @@ class UpbSimpleCloudDcRM(BaseResourceModel):
         cpu_period, cpu_quota = self._calculate_cpu_cfs_values(cpu_time_percentage)
         # apply limits to container if changed
         if d.cpu_period != cpu_period or d.cpu_quota != cpu_quota:
-            LOG.debug("Setting CPU limit for %r: cpu_quota = cpu_period * limit = %f * %f = %f" % (
-                      d.name, cpu_period, cpu_time_percentage, cpu_quota))
+            LOG.debug("Setting CPU limit for %r: cpu_quota = cpu_period * limit = %f * %f = %f (op_factor=%f)" % (
+                      d.name, cpu_period, cpu_time_percentage, cpu_quota, self.cpu_op_factor))
             d.updateCpuLimit(cpu_period=int(cpu_period), cpu_quota=int(cpu_quota))
 
     def _compute_single_cu(self):
@@ -182,7 +184,8 @@ class UpbSimpleCloudDcRM(BaseResourceModel):
         mem_limit = self._calculate_mem_limit_value(mem_limit)
         # apply to container if changed
         if d.mem_limit != mem_limit:
-            LOG.debug("Setting MEM limit for %r: mem_limit = %f MB" % (d.name, mem_limit/1024/1024))
+            LOG.debug("Setting MEM limit for %r: mem_limit = %f MB (op_factor=%f)" %
+                      (d.name, mem_limit/1024/1024, self.mem_op_factor))
             d.updateMemoryLimit(mem_limit=mem_limit)
 
     def _calculate_mem_limit_value(self, mem_limit):
@@ -224,6 +227,8 @@ class UpbSimpleCloudDcRM(BaseResourceModel):
         r["dc_alloc_mu"] = self.dc_alloc_mu
         r["single_cu_percentage"] = self.single_cu
         r["single_mu_percentage"] = self.single_mu
+        r["cpu_op_factor"] = self.cpu_op_factor
+        r["mem_op_factor"] = self.mem_op_factor
         r["allocation_state"] = allocation_state
         return r
 
@@ -279,9 +284,7 @@ class UpbOverprovisioningCloudDcRM(UpbSimpleCloudDcRM):
         # get cpu time fraction for entire emulation
         e_cpu = self.registrar.e_cpu
         # calculate over provisioning scale factor
-        self.op_factor = float(self.dc_max_cu) / (max(self.dc_max_cu, self.dc_alloc_cu))
-        LOG.info("========== op_factor=%r ===========" % self.op_factor)
+        self.cpu_op_factor = float(self.dc_max_cu) / (max(self.dc_max_cu, self.dc_alloc_cu))
         # calculate
-        return float(e_cpu) / sum([rm.dc_max_cu for rm in list(self.registrar.resource_models)]) * self.op_factor
+        return float(e_cpu) / sum([rm.dc_max_cu for rm in list(self.registrar.resource_models)]) * self.cpu_op_factor
 
-    # TODO log op_factor