Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3721#discussion_r111975142
  
    --- Diff: flink-dist/src/main/flink-bin/bin/config.sh ---
    @@ -398,3 +428,106 @@ readSlaves() {
     useOffHeapMemory() {
         [[ "`echo ${FLINK_TM_OFFHEAP} | tr '[:upper:]' '[:lower:]'`" == "true" 
]]
     }
    +
    +HAVE_AWK=
    +# same as 
org.apache.flink.runtime.taskexecutor.TaskManagerServices.calculateNetworkBuf(long
 totalJavaMemorySize, Configuration config)
    +calculateNetworkBuf() {
    +    local network_buffers_bytes
    +    if [ "${FLINK_TM_HEAP}" -le "0" ]; then
    +        echo "Variable 'FLINK_TM_HEAP' not set (usually read from 
'${KEY_TASKM_MEM_SIZE}' in ${FLINK_CONF_FILE})."
    +        exit 1
    +    fi
    +
    +    if [[ "${FLINK_TM_NET_BUF_MIN}" = "${FLINK_TM_NET_BUF_MAX}" ]]; then
    +        # fix memory size for network buffers
    +        network_buffers_bytes=${FLINK_TM_NET_BUF_MIN}
    +    else
    +        if [[ "${FLINK_TM_NET_BUF_MIN}" -gt "${FLINK_TM_NET_BUF_MAX}" ]]; 
then
    +            echo "[ERROR] Configured TaskManager network buffer memory 
min/max '${FLINK_TM_NET_BUF_MIN}'/'${FLINK_TM_NET_BUF_MAX}' are not valid."
    +            echo "Min must be less than or equal to max."
    +            echo "Please set '${KEY_TASKM_NET_BUF_MIN}' and 
'${KEY_TASKM_NET_BUF_MAX}' in ${FLINK_CONF_FILE}."
    +            exit 1
    +        fi
    +
    +        # Bash only performs integer arithmetic so floating point 
computation is performed using awk
    +        if [[ -z "${HAVE_AWK}" ]] ; then
    +            command -v awk >/dev/null 2>&1
    +            if [[ $? -ne 0 ]]; then
    +                echo "[ERROR] Program 'awk' not found."
    +                echo "Please install 'awk' or define 
'${KEY_TASKM_NET_BUF_MIN}' and '${KEY_TASKM_NET_BUF_MAX}' instead of 
'${KEY_TASKM_NET_BUF_FRACTION}' in ${FLINK_CONF_FILE}."
    +                exit 1
    +            fi
    +            HAVE_AWK=true
    +        fi
    +
    +        # We calculate the memory using a fraction of the total memory
    +        if [[ `awk '{ if ($1 > 0.0 && $1 < 1.0) print "1"; }' <<< 
"${FLINK_TM_NET_BUF_FRACTION}"` != "1" ]]; then
    +            echo "[ERROR] Configured TaskManager network buffer memory 
fraction '${FLINK_TM_NET_BUF_FRACTION}' is not a valid value."
    +            echo "It must be between 0.0 and 1.0."
    +            echo "Please set '${KEY_TASKM_NET_BUF_FRACTION}' in 
${FLINK_CONF_FILE}."
    +            exit 1
    +        fi
    +
    +        network_buffers_bytes=`awk "BEGIN { x = 
lshift(${FLINK_TM_HEAP},20) * ${FLINK_TM_NET_BUF_FRACTION}; netbuf = x > 
${FLINK_TM_NET_BUF_MAX} ? ${FLINK_TM_NET_BUF_MAX} : x < ${FLINK_TM_NET_BUF_MIN} 
? ${FLINK_TM_NET_BUF_MIN} : x; printf \"%.0f\n\", netbuf }"`
    +    fi
    +
    +    # recalculate the JVM heap memory by taking the network buffers into 
account
    --- End diff --
    
    This is more of a verification isn't it?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to