gatk icon indicating copy to clipboard operation
gatk copied to clipboard

Build a max memory estimation shell function into the Docker

Open mwalker174 opened this issue 1 year ago • 0 comments

Feature request

Tool(s) or class(es) involved

Docker image

Description

We've been using this function in the GATK-SV WDLs to estimate the appropriate -XmX Java parameter for GATK tools:

        function getJavaMem() {
            # get JVM memory in MiB 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 "%dM", f[MEM_FIELD] * ~{default="0.85" java_mem_fraction} / 1024
                }'
        }
        JVM_MAX_MEM=$(getJavaMem MemTotal)
        echo "JVM memory: $JVM_MAX_MEM"
        gatk --java-options "-Xmx${JVM_MAX_MEM}"  …

We've found this to be a reliable method because it uses the VM's actual memory rather than what was requested, which can be less than what is actually provided. This would be a generally useful utility function to build into the Docker for use across GATK WDLs.

mwalker174 avatar Jul 13 '22 16:07 mwalker174