Skip to content

Commit

Permalink
Set MELT JVM memory dynamically (#247)
Browse files Browse the repository at this point in the history
* set MELT JVM to 85% of memory available at runtime
  • Loading branch information
epiercehoffman authored Oct 29, 2021
1 parent 5cc9b1d commit f04d476
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"GatherSampleEvidenceBatch.samtools_cloud_docker": {{ dockers.samtools_cloud_docker | tojson }},
"GatherSampleEvidenceBatch.sv_base_mini_docker":{{ dockers.sv_base_mini_docker | tojson }},
"GatherSampleEvidenceBatch.sv_pipeline_docker": {{ dockers.sv_pipeline_docker | tojson }},
"GatherSampleEvidenceBatch.delly_docker": {{ dockers.delly_docker | tojson }},
"GatherSampleEvidenceBatch.manta_docker": {{ dockers.manta_docker | tojson }},
"GatherSampleEvidenceBatch.melt_docker" : {{ dockers.melt_docker | tojson }},
"GatherSampleEvidenceBatch.wham_docker": {{ dockers.wham_docker | tojson }},
Expand Down
14 changes: 14 additions & 0 deletions wdl/MELT.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ task RunMELT {
Float mem_offset = 6.833
Float mem_size_gb =
mem_offset + mem_per_pct_chimeras * pct_chimeras + mem_per_improper_pairs * pf_reads_improper_pairs
Float java_mem_fraction = 0.85
# Ensure there's sufficient disk space. Estimate using extra metrics
Expand Down Expand Up @@ -610,6 +611,19 @@ task RunMELT {
MELT_ROOT=$(find "$MELT_DIR" -name "MELT.jar" | xargs -n1 dirname)
MELT_SCRIPT=$(ls "$MELT_DIR/run_MELT"*.sh)

function getJavaMem() {
# get JVM memory in GiB by getting total memory from /proc/meminfo
# and multiplying by java_mem_fraction
cat /proc/meminfo \
| awk -v MEM_FIELD="$1" '{
f[substr($1, 1, length($1)-1)] = $2
} END {
printf "%.2fG", f[MEM_FIELD] * ~{java_mem_fraction} / 1048576
}'
}
JVM_MAX_MEM=$(getJavaMem MemTotal)
echo "JVM memory: $JVM_MAX_MEM"

# call MELT
"$MELT_SCRIPT" \
"~{sample_id}.bam" \
Expand Down

0 comments on commit f04d476

Please sign in to comment.