From e1795b9a2b603a28d2bb62160b57697e69ea18a8 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Thu, 29 Oct 2015 10:27:47 +0100
Subject: [PATCH] No memory increase on first retry

---
 .../sasc/biopet/core/CommandLineResources.scala  | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/CommandLineResources.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/CommandLineResources.scala
index 2eb25691a..6334b3cbf 100644
--- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/CommandLineResources.scala
+++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/CommandLineResources.scala
@@ -6,18 +6,17 @@ import nl.lumc.sasc.biopet.utils.config.Configurable
 import org.broadinstitute.gatk.queue.function.CommandLineFunction
 
 /**
- * Created by pjvanthof on 01/10/15.
+ * This trait will control resources given to a CommandlineFunction
  */
 trait CommandLineResources extends CommandLineFunction with Configurable {
 
   def defaultThreads = 1
   final def threads = nCoresRequest match {
     case Some(i) => i
-    case _ => {
+    case _ =>
       val t = getThreads
       nCoresRequest = Some(t)
       t
-    }
   }
 
   var vmem: Option[String] = config("vmem")
@@ -64,23 +63,26 @@ trait CommandLineResources extends CommandLineFunction with Configurable {
 
     nCoresRequest = Option(threads)
 
+    /** The 1e retry does not yet upgrade the memory */
+    val retryMultipler = if (retry > 1) retry - 1 else 0
+
     _coreMemory = config("core_memory", default = defaultCoreMemory).asDouble +
-      (0.5 * retry)
+      (0.5 * retryMultipler)
 
     if (config.contains("memory_limit")) memoryLimit = config("memory_limit")
     else memoryLimit = Some(_coreMemory * threads)
 
     if (config.contains("resident_limit")) residentLimit = config("resident_limit")
-    else residentLimit = Some((_coreMemory + (0.5 * retry)) * residentFactor)
+    else residentLimit = Some((_coreMemory + (0.5 * retryMultipler)) * residentFactor)
 
-    if (!config.contains("vmem")) vmem = Some((_coreMemory * (vmemFactor + (0.5 * retry))) + "G")
+    if (!config.contains("vmem")) vmem = Some((_coreMemory * (vmemFactor + (0.5 * retryMultipler))) + "G")
     jobName = configName + ":" + (if (firstOutput != null) firstOutput.getName else jobOutputFile)
   }
 
   override def setupRetry(): Unit = {
     super.setupRetry()
     if (vmem.isDefined) jobResourceRequests = jobResourceRequests.filterNot(_.contains("h_vmem="))
-    logger.info("Auto raise memory on retry")
+    if (retry > 0) logger.info("Auto raise memory on retry")
     retry += 1
     this.freeze()
   }
-- 
GitLab