[GitHub] [flink-docker] Myasuka commented on a change in pull request #43: [FLINK-19125] Adopt Jemalloc as default memory allocator to avoid memory leak

2020-11-18 Thread GitBox


Myasuka commented on a change in pull request #43:
URL: https://github.com/apache/flink-docker/pull/43#discussion_r526583917



##
File path: docker-entrypoint.sh
##
@@ -93,21 +94,41 @@ prepare_job_manager_start() {
 envsubst < "${CONF_FILE}" > "${CONF_FILE}.tmp" && mv "${CONF_FILE}.tmp" 
"${CONF_FILE}"
 }
 
+disable_jemalloc_env() {
+  local -n _args=$1
+  if [ "${_args[0]}" = ${COMMAND_DISABLE_JEMALLOC} ]; then
+  echo "Disable Jemalloc as the memory allocator"
+  _args=("${_args[@]:1}")

Review comment:
   Sounds good, already added comment.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [flink-docker] Myasuka commented on a change in pull request #43: [FLINK-19125] Adopt Jemalloc as default memory allocator to avoid memory leak

2020-11-18 Thread GitBox


Myasuka commented on a change in pull request #43:
URL: https://github.com/apache/flink-docker/pull/43#discussion_r525968923



##
File path: docker-entrypoint.sh
##
@@ -93,21 +94,41 @@ prepare_job_manager_start() {
 envsubst < "${CONF_FILE}" > "${CONF_FILE}.tmp" && mv "${CONF_FILE}.tmp" 
"${CONF_FILE}"
 }
 
+disable_jemalloc_env() {
+  local -n _args=$1
+  if [ "${_args[0]}" = ${COMMAND_DISABLE_JEMALLOC} ]; then
+  echo "Disable Jemalloc as the memory allocator"
+  _args=("${_args[@]:1}")

Review comment:
   `local -n` is the same as `declare -n` which serves as a name 
[reference](https://www.gnu.org/software/bash/manual/bash.html#index-declare) 
and I got this from [this answer](https://unix.stackexchange.com/a/449537).
   This feature is introduced in 
[bash-4.3](https://github.com/bminor/bash/blob/ac50fbac377e32b98d2de396f016ea81e8ee9961/CHANGES#L761)
 and luckily our base image installed `bash-5.0.3` to include this.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [flink-docker] Myasuka commented on a change in pull request #43: [FLINK-19125] Adopt Jemalloc as default memory allocator to avoid memory leak

2020-11-17 Thread GitBox


Myasuka commented on a change in pull request #43:
URL: https://github.com/apache/flink-docker/pull/43#discussion_r525867175



##
File path: docker-entrypoint.sh
##
@@ -93,21 +94,49 @@ prepare_job_manager_start() {
 envsubst < "${CONF_FILE}" > "${CONF_FILE}.tmp" && mv "${CONF_FILE}.tmp" 
"${CONF_FILE}"
 }
 
+disable_jemalloc_env() {
+  if [ "$1" = ${COMMAND_DISABLE_JEMALLOC} ]; then
+  echo "Disable Jemalloc as the memory allocator"
+  return 0
+  else
+  echo "Enable Jemalloc as the memory allocator via appending env variable 
LD_PRELOAD with /usr/lib/x86_64-linux-gnu/libjemalloc.so"
+  export LD_PRELOAD=$LD_PRELOAD:/usr/lib/x86_64-linux-gnu/libjemalloc.so
+  return 1
+  fi
+}
+
 if [ "$1" = "help" ]; then
-echo "Usage: $(basename "$0") 
(jobmanager|${COMMAND_STANDALONE}|taskmanager|${COMMAND_NATIVE_KUBERNETES}|${COMMAND_HISTORY_SERVER}|help)"
+printf "Usage: $(basename "$0") 
(jobmanager|${COMMAND_STANDALONE}|taskmanager|${COMMAND_NATIVE_KUBERNETES}|${COMMAND_HISTORY_SERVER})
 [${COMMAND_DISABLE_JEMALLOC}]\n"
+printf "Or $(basename "$0") help\n\n"
+printf "By default, Flink image adopts jemalloc as default memory 
allocator and will disable jemalloc if option '${COMMAND_DISABLE_JEMALLOC}' 
given.\n"
 exit 0
 elif [ "$1" = "jobmanager" ]; then
 shift 1
+disable_jemalloc_env $@
+disabled_jemalloc="$?"
+if [ ${disabled_jemalloc} = 0 ]; then
+  shift 1
+fi

Review comment:
   I have refactored the function and update the array of arguments within 
the new `disable_jemalloc_env` function and then passed to next commands.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org