@@ -419,10 +419,10 @@ public String getPostProcessCommands() {
419419
420420 }
421421
422- private static int getRoundedMemoryLimit (long memPerTaskMB ) {
423- int rawLimit = ( int )( memPerTaskMB * 0.9 );
424- // Round down to nearest 100 MB
425- return (rawLimit / 100 ) * 100 ;
422+ private static int roundUpToBlock (long memPerTaskMB , int blockSizeMB ) {
423+ long block = blockSizeMB ; // promote to long for safe math
424+ long rounded = (( memPerTaskMB + block - 1 ) / block ) * block ;
425+ return (int ) rounded ;
426426 }
427427 private static String extractUser (ExecutableCommand .Container commandSet ) {
428428 for (ExecutableCommand ec : commandSet .getExecCommands ()) {
@@ -661,9 +661,14 @@ String generateLangevinBatchScript(String jobName, ExecutableCommand.Container
661661 SolverDescription solverDescription = std .getSolverDescription ();
662662 MemLimitResults memoryMBAllowed = HtcProxy .getMemoryLimit (vcellUserid , simID , solverDescription , memSizeMB , simTask .isPowerUser ());
663663
664- int timeoutPerTaskSeconds = 28800 ; // 8 hours TODO: do we hardcode this? Should it be part of LangevinSimulationOptions?
664+ // TODO: do we hardcode these? Should it be part of LangevinSimulationOptions? Or, even better, properties?
665+ int timeoutPerTaskSeconds = 86400 ; // seconds. 24 hours
666+ long hardbBtchMemoryLimitPerTask = 1024 ; // MB. we hard limit mem to 1G for langevin batch jobs
667+ int blockSizeMB = 256 ; // MB. SLURM memory allocation granularity
665668 String slurmJobTimeout = computeSlurmTimeLimit (totalNumberOfJobs , numberOfConcurrentTasks , timeoutPerTaskSeconds );
666- int javaMemXmx = getRoundedMemoryLimit (memoryMBAllowed .getMemLimit ());
669+ long batchMemoryLimitPerTask = memoryMBAllowed .getMemLimit ();
670+ batchMemoryLimitPerTask = Math .min (batchMemoryLimitPerTask , hardbBtchMemoryLimitPerTask );
671+ int javaMemXmx = roundUpToBlock (batchMemoryLimitPerTask , blockSizeMB ) + blockSizeMB ; // add extra block for overhead
667672
668673 // -------------------------------------------------------------
669674
0 commit comments