Skip to content

Commit

Permalink
tweak auto-tuning messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dzuelke committed Feb 10, 2015
1 parent 2744594 commit 62bddfe
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 60 deletions.
25 changes: 10 additions & 15 deletions bin/heroku-hhvm-apache2
Original file line number Diff line number Diff line change
Expand Up @@ -244,31 +244,26 @@ httpd_config=$(php_passthrough "$httpd_config")
if [[ -z ${WEB_CONCURRENCY:-} ]]; then
maxprocs=$(ulimit -u)
ram="512M"
if [[ -z ${DYNO:-} ]]; then
# not on a dyno
[[ $verbose ]] && echo "Assuming settings for 1X dyno..." >&2
elif [[ "$maxprocs" == "32768" ]]; then
echo "Optimizing settings for PX dyno..." >&2
if [[ -n ${DYNO:-} && "$maxprocs" == "32768" ]]; then
echo "Optimizing defaults for PX dyno...." >&2
ram="6G"
elif [[ "$maxprocs" == "512" ]]; then
echo "Optimizing settings for 2X dyno..." >&2
elif [[ -n ${DYNO:-} && "$maxprocs" == "512" ]]; then
echo "Optimizing defaults for 2X dyno..." >&2
ram="1G"
else
if [[ "$maxprocs" == "256" ]]; then
echo "Optimizing settings for 1X dyno..." >&2
else
echo "Falling back to settings for 1X dyno..." >&2
fi
elif [[ -n ${DYNO:-} && "$maxprocs" == "256" ]]; then
echo "Optimzing defaults for 1X dyno..." >&2
elif [[ -n ${DYNO:-} || $verbose ]]; then
echo "No dyno detected; using defaults for 1X..." >&2
fi

# determine number of HHVM threads to run
read WEB_CONCURRENCY php_memory_limit <<<$(hhvm "${php_configs[@]}" $(composer config vendor-dir 2> /dev/null | tail -n 1)/heroku/heroku-buildpack-php/bin/util/autotune.php "$ram") # tail, as composer echos outdated version warnings to STDOUT
[[ $WEB_CONCURRENCY -lt 1 ]] && WEB_CONCURRENCY=1
export WEB_CONCURRENCY

echo "Running ${WEB_CONCURRENCY} threads at ${php_memory_limit}B memory limit." >&2
echo "${WEB_CONCURRENCY} threads at ${php_memory_limit}B memory limit." >&2
else
echo "Running ${WEB_CONCURRENCY} threads as per \$WEB_CONCURRENCY" >&2
echo "Using WEB_CONCURRENCY=${WEB_CONCURRENCY} threads." >&2
fi

# we changed WEB_CONCURRENCY; now we need to re-evaluate the configs as HHVM doesn't support ${...} syntax, so the configs contain PHP getenv() calls and are templated; we pass an argument to it to avoid it echoing "using HHVM config ..." messages again because that already happened
Expand Down
25 changes: 10 additions & 15 deletions bin/heroku-hhvm-nginx
Original file line number Diff line number Diff line change
Expand Up @@ -244,31 +244,26 @@ nginx_config=$(php_passthrough "$nginx_config")
if [[ -z ${WEB_CONCURRENCY:-} ]]; then
maxprocs=$(ulimit -u)
ram="512M"
if [[ -z ${DYNO:-} ]]; then
# not on a dyno
[[ $verbose ]] && echo "Assuming settings for 1X dyno..." >&2
elif [[ "$maxprocs" == "32768" ]]; then
echo "Optimizing settings for PX dyno..." >&2
if [[ -n ${DYNO:-} && "$maxprocs" == "32768" ]]; then
echo "Optimizing defaults for PX dyno...." >&2
ram="6G"
elif [[ "$maxprocs" == "512" ]]; then
echo "Optimizing settings for 2X dyno..." >&2
elif [[ -n ${DYNO:-} && "$maxprocs" == "512" ]]; then
echo "Optimizing defaults for 2X dyno..." >&2
ram="1G"
else
if [[ "$maxprocs" == "256" ]]; then
echo "Optimizing settings for 1X dyno..." >&2
else
echo "Falling back to settings for 1X dyno..." >&2
fi
elif [[ -n ${DYNO:-} && "$maxprocs" == "256" ]]; then
echo "Optimzing defaults for 1X dyno..." >&2
elif [[ -n ${DYNO:-} || $verbose ]]; then
echo "No dyno detected; using defaults for 1X..." >&2
fi

# determine number of HHVM threads to run
read WEB_CONCURRENCY php_memory_limit <<<$(hhvm "${php_configs[@]}" $(composer config vendor-dir 2> /dev/null | tail -n 1)/heroku/heroku-buildpack-php/bin/util/autotune.php "$ram") # tail, as composer echos outdated version warnings to STDOUT
[[ $WEB_CONCURRENCY -lt 1 ]] && WEB_CONCURRENCY=1
export WEB_CONCURRENCY

echo "Running ${WEB_CONCURRENCY} threads at ${php_memory_limit}B memory limit." >&2
echo "${WEB_CONCURRENCY} threads at ${php_memory_limit}B memory limit." >&2
else
echo "Running ${WEB_CONCURRENCY} threads as per \$WEB_CONCURRENCY" >&2
echo "Using WEB_CONCURRENCY=${WEB_CONCURRENCY} threads." >&2
fi

# we changed WEB_CONCURRENCY; now we need to re-evaluate the configs as HHVM doesn't support ${...} syntax, so the configs contain PHP getenv() calls and are templated; we pass an argument to it to avoid it echoing "using HHVM config ..." messages again because that already happened
Expand Down
25 changes: 10 additions & 15 deletions bin/heroku-php-apache2
Original file line number Diff line number Diff line change
Expand Up @@ -264,31 +264,26 @@ httpd_config=$(php_passthrough "$httpd_config")
if [[ -z ${WEB_CONCURRENCY:-} ]]; then
maxprocs=$(ulimit -u)
ram="512M"
if [[ -z ${DYNO:-} ]]; then
# not on a dyno
[[ $verbose ]] && echo "Assuming settings for 1X dyno..." >&2
elif [[ "$maxprocs" == "32768" ]]; then
echo "Optimizing settings for PX dyno..." >&2
if [[ -n ${DYNO:-} && "$maxprocs" == "32768" ]]; then
echo "Optimizing defaults for PX dyno...." >&2
ram="6G"
elif [[ "$maxprocs" == "512" ]]; then
echo "Optimizing settings for 2X dyno..." >&2
elif [[ -n ${DYNO:-} && "$maxprocs" == "512" ]]; then
echo "Optimizing defaults for 2X dyno..." >&2
ram="1G"
else
if [[ "$maxprocs" == "256" ]]; then
echo "Optimizing settings for 1X dyno..." >&2
else
echo "Falling back to settings for 1X dyno..." >&2
fi
elif [[ -n ${DYNO:-} && "$maxprocs" == "256" ]]; then
echo "Optimzing defaults for 1X dyno..." >&2
elif [[ -n ${DYNO:-} || $verbose ]]; then
echo "No dyno detected; using defaults for 1X..." >&2
fi

# determine number of FPM processes to run
read WEB_CONCURRENCY php_memory_limit <<<$(php -c "$php_config" $(composer config vendor-dir 2> /dev/null | tail -n 1)/heroku/heroku-buildpack-php/bin/util/autotune.php -y "$fpm_config" -t "$DOCUMENT_ROOT" "$ram") # tail, as composer echos outdated version warnings to STDOUT
[[ $WEB_CONCURRENCY -lt 1 ]] && WEB_CONCURRENCY=1
export WEB_CONCURRENCY

echo "Running ${WEB_CONCURRENCY} workers at ${php_memory_limit}B memory limit." >&2
echo "${WEB_CONCURRENCY} processes at ${php_memory_limit}B memory limit." >&2
else
echo "Running ${WEB_CONCURRENCY} workers as per \$WEB_CONCURRENCY" >&2
echo "Using WEB_CONCURRENCY=${WEB_CONCURRENCY} processes." >&2
fi

# make a shared pipe; we'll write the name of the process that exits to it once that happens, and wait for that event below
Expand Down
25 changes: 10 additions & 15 deletions bin/heroku-php-nginx
Original file line number Diff line number Diff line change
Expand Up @@ -264,31 +264,26 @@ nginx_config=$(php_passthrough "$nginx_config")
if [[ -z ${WEB_CONCURRENCY:-} ]]; then
maxprocs=$(ulimit -u)
ram="512M"
if [[ -z ${DYNO:-} ]]; then
# not on a dyno
[[ $verbose ]] && echo "Assuming settings for 1X dyno..." >&2
elif [[ "$maxprocs" == "32768" ]]; then
echo "Optimizing settings for PX dyno..." >&2
if [[ -n ${DYNO:-} && "$maxprocs" == "32768" ]]; then
echo "Optimizing defaults for PX dyno...." >&2
ram="6G"
elif [[ "$maxprocs" == "512" ]]; then
echo "Optimizing settings for 2X dyno..." >&2
elif [[ -n ${DYNO:-} && "$maxprocs" == "512" ]]; then
echo "Optimizing defaults for 2X dyno..." >&2
ram="1G"
else
if [[ "$maxprocs" == "256" ]]; then
echo "Optimizing settings for 1X dyno..." >&2
else
echo "Falling back to settings for 1X dyno..." >&2
fi
elif [[ -n ${DYNO:-} && "$maxprocs" == "256" ]]; then
echo "Optimzing defaults for 1X dyno..." >&2
elif [[ -n ${DYNO:-} || $verbose ]]; then
echo "No dyno detected; using defaults for 1X..." >&2
fi

# determine number of FPM processes to run
read WEB_CONCURRENCY php_memory_limit <<<$(php -c "$php_config" $(composer config vendor-dir 2> /dev/null | tail -n 1)/heroku/heroku-buildpack-php/bin/util/autotune.php -y "$fpm_config" -t "$DOCUMENT_ROOT" "$ram") # tail, as composer echos outdated version warnings to STDOUT
[[ $WEB_CONCURRENCY -lt 1 ]] && WEB_CONCURRENCY=1
export WEB_CONCURRENCY

echo "Running ${WEB_CONCURRENCY} workers at ${php_memory_limit}B memory limit." >&2
echo "${WEB_CONCURRENCY} processes at ${php_memory_limit}B memory limit." >&2
else
echo "Running ${WEB_CONCURRENCY} workers as per \$WEB_CONCURRENCY" >&2
echo "Using WEB_CONCURRENCY=${WEB_CONCURRENCY} processes." >&2
fi

# make a shared pipe; we'll write the name of the process that exits to it once that happens, and wait for that event below
Expand Down

0 comments on commit 62bddfe

Please sign in to comment.