diff --git a/README.md b/README.md index d66285a5b..d17f1333c 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,12 @@ This feature can be controlled via the following variables: * `SCC_SIZE` (environment variable) * Description: The size of the application-specific SCC layer in the image. This value is only used if `TRIM_SCC` is set to `"false"`. * Default: `"80m"`. +* `WARM_ENDPOINT` (environment variable) + * Description: If `"true"`, curl will be used to access the WARM_ENDPOINT_URL (see below) during the population of the SCC. This will increase the amount of information in the SCC and improve first request time in subsequent starts of the image. + * Default: `"true"`. +* `WARM_ENDPOINT_URL` (enviornment variable) + * Description: The URL to access during SCC population if WARM_ENDPOINT is true. + * Default: `"localhost:9080/"`. ## Logging diff --git a/ga/23.0.0.12/kernel/helpers/build/configure.sh b/ga/23.0.0.12/kernel/helpers/build/configure.sh index a13d4d8a2..7a9f03b16 100755 --- a/ga/23.0.0.12/kernel/helpers/build/configure.sh +++ b/ga/23.0.0.12/kernel/helpers/build/configure.sh @@ -179,6 +179,12 @@ function main() { if [ ! "$SCC_SIZE" = "" ]; then cmd+=" -s $SCC_SIZE" fi + if [ "$WARM_ENDPOINT" = "false" ]; then + cmd+=" -c" + fi + if [ ! "$WARM_ENDPOINT_URL" = "" ]; then + cmd+=" -u $WARM_ENDPOINT_URL" + fi eval $cmd fi } diff --git a/ga/23.0.0.12/kernel/helpers/build/populate_scc.sh b/ga/23.0.0.12/kernel/helpers/build/populate_scc.sh index 3c07a4e92..ea255eef9 100755 --- a/ga/23.0.0.12/kernel/helpers/build/populate_scc.sh +++ b/ga/23.0.0.12/kernel/helpers/build/populate_scc.sh @@ -1,5 +1,5 @@ #!/bin/bash -# (C) Copyright IBM Corporation 2020. +# (C) Copyright IBM Corporation 2020, 2024 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ set -Eeox pipefail SCC_SIZE="80m" # Default size of the SCC layer. ITERATIONS=2 # Number of iterations to run to populate it. TRIM_SCC=yes # Trim the SCC to eliminate any wasted space. +WARM_ENDPOINT=true +WARM_ENDPOINT_URL=localhost:9080/ # If this directory exists and has at least ug=rwx permissions, assume the base image includes an SCC called 'openj9_system_scc' and build on it. # If not, build on our own SCC. @@ -48,7 +50,7 @@ CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess" DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy" PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats" -while getopts ":i:s:tdh" OPT +while getopts ":i:s:u:tdhwc" OPT do case "$OPT" in i) @@ -64,13 +66,24 @@ do d) TRIM_SCC=no ;; + w) + WARM_ENDPOINT=true + ;; + c) + WARM_ENDPOINT=false + ;; + u) + WARM_ENDPOINT_URL="${OPTARG}" + ;; h) echo \ -"Usage: $0 [-i iterations] [-s size] [-t] [-d] +"Usage: $0 [-i iterations] [-s size] [-t] [-d] [-w] [-u url] -i Number of iterations to run to populate the SCC. (Default: $ITERATIONS) -s Size of the SCC in megabytes (m suffix required). (Default: $SCC_SIZE) -t Trim the SCC to eliminate most of the free space, if any. -d Don't trim the SCC. + -w Use curl to warm an endpoint during SCC creation. (Default: $WARM_ENDPOINT) + -u The URL endpoint to warm during SCC creation. (Default: $WARM_ENDPOINT_URL) Trimming enabled=$TRIM_SCC" exit 1 @@ -98,7 +111,14 @@ then echo "Calculating SCC layer upper bound, starting with initial size $SCC_SIZE." # Populate the newly created class cache layer. /opt/ibm/wlp/bin/server start + + if [ ${WARM_ENDPOINT} == true ] + then + curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing" + fi + /opt/ibm/wlp/bin/server stop + # Find out how full it is. FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'` echo "SCC layer is $FULL% full. Destroying layer." @@ -122,6 +142,12 @@ fi for ((i=0; i<$ITERATIONS; i++)) do /opt/ibm/wlp/bin/server start + + if [ ${WARM_ENDPOINT} == true ] + then + curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing" + fi + /opt/ibm/wlp/bin/server stop done @@ -135,6 +161,7 @@ then chmod -R g+rwx /output/resources fi + # Tell the user how full the final layer is. FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'` echo "SCC layer is $FULL% full." diff --git a/ga/23.0.0.9/kernel/helpers/build/configure.sh b/ga/23.0.0.9/kernel/helpers/build/configure.sh index b2480a5cd..2f2a29cfb 100755 --- a/ga/23.0.0.9/kernel/helpers/build/configure.sh +++ b/ga/23.0.0.9/kernel/helpers/build/configure.sh @@ -176,6 +176,12 @@ function main() { if [ ! "$SCC_SIZE" = "" ]; then cmd+=" -s $SCC_SIZE" fi + if [ "$WARM_ENDPOINT" = "false" ]; then + cmd+=" -c" + fi + if [ ! "$WARM_ENDPOINT_URL" = "" ]; then + cmd+=" -u $WARM_ENDPOINT_URL" + fi eval $cmd fi } diff --git a/ga/23.0.0.9/kernel/helpers/build/populate_scc.sh b/ga/23.0.0.9/kernel/helpers/build/populate_scc.sh index 3c07a4e92..ea255eef9 100755 --- a/ga/23.0.0.9/kernel/helpers/build/populate_scc.sh +++ b/ga/23.0.0.9/kernel/helpers/build/populate_scc.sh @@ -1,5 +1,5 @@ #!/bin/bash -# (C) Copyright IBM Corporation 2020. +# (C) Copyright IBM Corporation 2020, 2024 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ set -Eeox pipefail SCC_SIZE="80m" # Default size of the SCC layer. ITERATIONS=2 # Number of iterations to run to populate it. TRIM_SCC=yes # Trim the SCC to eliminate any wasted space. +WARM_ENDPOINT=true +WARM_ENDPOINT_URL=localhost:9080/ # If this directory exists and has at least ug=rwx permissions, assume the base image includes an SCC called 'openj9_system_scc' and build on it. # If not, build on our own SCC. @@ -48,7 +50,7 @@ CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess" DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy" PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats" -while getopts ":i:s:tdh" OPT +while getopts ":i:s:u:tdhwc" OPT do case "$OPT" in i) @@ -64,13 +66,24 @@ do d) TRIM_SCC=no ;; + w) + WARM_ENDPOINT=true + ;; + c) + WARM_ENDPOINT=false + ;; + u) + WARM_ENDPOINT_URL="${OPTARG}" + ;; h) echo \ -"Usage: $0 [-i iterations] [-s size] [-t] [-d] +"Usage: $0 [-i iterations] [-s size] [-t] [-d] [-w] [-u url] -i Number of iterations to run to populate the SCC. (Default: $ITERATIONS) -s Size of the SCC in megabytes (m suffix required). (Default: $SCC_SIZE) -t Trim the SCC to eliminate most of the free space, if any. -d Don't trim the SCC. + -w Use curl to warm an endpoint during SCC creation. (Default: $WARM_ENDPOINT) + -u The URL endpoint to warm during SCC creation. (Default: $WARM_ENDPOINT_URL) Trimming enabled=$TRIM_SCC" exit 1 @@ -98,7 +111,14 @@ then echo "Calculating SCC layer upper bound, starting with initial size $SCC_SIZE." # Populate the newly created class cache layer. /opt/ibm/wlp/bin/server start + + if [ ${WARM_ENDPOINT} == true ] + then + curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing" + fi + /opt/ibm/wlp/bin/server stop + # Find out how full it is. FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'` echo "SCC layer is $FULL% full. Destroying layer." @@ -122,6 +142,12 @@ fi for ((i=0; i<$ITERATIONS; i++)) do /opt/ibm/wlp/bin/server start + + if [ ${WARM_ENDPOINT} == true ] + then + curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing" + fi + /opt/ibm/wlp/bin/server stop done @@ -135,6 +161,7 @@ then chmod -R g+rwx /output/resources fi + # Tell the user how full the final layer is. FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'` echo "SCC layer is $FULL% full." diff --git a/ga/24.0.0.2/kernel/helpers/build/configure.sh b/ga/24.0.0.2/kernel/helpers/build/configure.sh index a13d4d8a2..7a9f03b16 100755 --- a/ga/24.0.0.2/kernel/helpers/build/configure.sh +++ b/ga/24.0.0.2/kernel/helpers/build/configure.sh @@ -179,6 +179,12 @@ function main() { if [ ! "$SCC_SIZE" = "" ]; then cmd+=" -s $SCC_SIZE" fi + if [ "$WARM_ENDPOINT" = "false" ]; then + cmd+=" -c" + fi + if [ ! "$WARM_ENDPOINT_URL" = "" ]; then + cmd+=" -u $WARM_ENDPOINT_URL" + fi eval $cmd fi } diff --git a/ga/24.0.0.2/kernel/helpers/build/populate_scc.sh b/ga/24.0.0.2/kernel/helpers/build/populate_scc.sh index 675415f29..19e4974c8 100755 --- a/ga/24.0.0.2/kernel/helpers/build/populate_scc.sh +++ b/ga/24.0.0.2/kernel/helpers/build/populate_scc.sh @@ -1,5 +1,5 @@ #!/bin/bash -# (C) Copyright IBM Corporation 2020. +# (C) Copyright IBM Corporation 2020, 2024 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ set -Eeox pipefail SCC_SIZE="80m" # Default size of the SCC layer. ITERATIONS=2 # Number of iterations to run to populate it. TRIM_SCC=yes # Trim the SCC to eliminate any wasted space. +WARM_ENDPOINT=true +WARM_ENDPOINT_URL=localhost:9080/ # If this directory exists and has at least ug=rwx permissions, assume the base image includes an SCC called 'openj9_system_scc' and build on it. # If not, build on our own SCC. @@ -49,7 +51,7 @@ CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess" DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy" PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats" -while getopts ":i:s:tdh" OPT +while getopts ":i:s:u:tdhwc" OPT do case "$OPT" in i) @@ -65,13 +67,24 @@ do d) TRIM_SCC=no ;; + w) + WARM_ENDPOINT=true + ;; + c) + WARM_ENDPOINT=false + ;; + u) + WARM_ENDPOINT_URL="${OPTARG}" + ;; h) echo \ -"Usage: $0 [-i iterations] [-s size] [-t] [-d] +"Usage: $0 [-i iterations] [-s size] [-t] [-d] [-w] [-u url] -i Number of iterations to run to populate the SCC. (Default: $ITERATIONS) -s Size of the SCC in megabytes (m suffix required). (Default: $SCC_SIZE) -t Trim the SCC to eliminate most of the free space, if any. -d Don't trim the SCC. + -w Use curl to warm an endpoint during SCC creation. (Default: $WARM_ENDPOINT) + -u The URL endpoint to warm during SCC creation. (Default: $WARM_ENDPOINT_URL) Trimming enabled=$TRIM_SCC" exit 1 @@ -99,7 +112,14 @@ then echo "Calculating SCC layer upper bound, starting with initial size $SCC_SIZE." # Populate the newly created class cache layer. /opt/ibm/wlp/bin/server start + + if [ ${WARM_ENDPOINT} == true ] + then + curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing" + fi + /opt/ibm/wlp/bin/server stop + # Find out how full it is. FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'` echo "SCC layer is $FULL% full. Destroying layer." @@ -123,6 +143,12 @@ fi for ((i=0; i<$ITERATIONS; i++)) do /opt/ibm/wlp/bin/server start + + if [ ${WARM_ENDPOINT} == true ] + then + curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing" + fi + /opt/ibm/wlp/bin/server stop done @@ -136,6 +162,7 @@ then chmod -R g+rwx /output/resources fi + # Tell the user how full the final layer is. FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'` echo "SCC layer is $FULL% full." diff --git a/ga/latest/kernel/helpers/build/configure.sh b/ga/latest/kernel/helpers/build/configure.sh index a13d4d8a2..7a9f03b16 100755 --- a/ga/latest/kernel/helpers/build/configure.sh +++ b/ga/latest/kernel/helpers/build/configure.sh @@ -179,6 +179,12 @@ function main() { if [ ! "$SCC_SIZE" = "" ]; then cmd+=" -s $SCC_SIZE" fi + if [ "$WARM_ENDPOINT" = "false" ]; then + cmd+=" -c" + fi + if [ ! "$WARM_ENDPOINT_URL" = "" ]; then + cmd+=" -u $WARM_ENDPOINT_URL" + fi eval $cmd fi } diff --git a/ga/latest/kernel/helpers/build/populate_scc.sh b/ga/latest/kernel/helpers/build/populate_scc.sh index 675415f29..19e4974c8 100755 --- a/ga/latest/kernel/helpers/build/populate_scc.sh +++ b/ga/latest/kernel/helpers/build/populate_scc.sh @@ -1,5 +1,5 @@ #!/bin/bash -# (C) Copyright IBM Corporation 2020. +# (C) Copyright IBM Corporation 2020, 2024 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ set -Eeox pipefail SCC_SIZE="80m" # Default size of the SCC layer. ITERATIONS=2 # Number of iterations to run to populate it. TRIM_SCC=yes # Trim the SCC to eliminate any wasted space. +WARM_ENDPOINT=true +WARM_ENDPOINT_URL=localhost:9080/ # If this directory exists and has at least ug=rwx permissions, assume the base image includes an SCC called 'openj9_system_scc' and build on it. # If not, build on our own SCC. @@ -49,7 +51,7 @@ CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess" DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy" PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats" -while getopts ":i:s:tdh" OPT +while getopts ":i:s:u:tdhwc" OPT do case "$OPT" in i) @@ -65,13 +67,24 @@ do d) TRIM_SCC=no ;; + w) + WARM_ENDPOINT=true + ;; + c) + WARM_ENDPOINT=false + ;; + u) + WARM_ENDPOINT_URL="${OPTARG}" + ;; h) echo \ -"Usage: $0 [-i iterations] [-s size] [-t] [-d] +"Usage: $0 [-i iterations] [-s size] [-t] [-d] [-w] [-u url] -i Number of iterations to run to populate the SCC. (Default: $ITERATIONS) -s Size of the SCC in megabytes (m suffix required). (Default: $SCC_SIZE) -t Trim the SCC to eliminate most of the free space, if any. -d Don't trim the SCC. + -w Use curl to warm an endpoint during SCC creation. (Default: $WARM_ENDPOINT) + -u The URL endpoint to warm during SCC creation. (Default: $WARM_ENDPOINT_URL) Trimming enabled=$TRIM_SCC" exit 1 @@ -99,7 +112,14 @@ then echo "Calculating SCC layer upper bound, starting with initial size $SCC_SIZE." # Populate the newly created class cache layer. /opt/ibm/wlp/bin/server start + + if [ ${WARM_ENDPOINT} == true ] + then + curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing" + fi + /opt/ibm/wlp/bin/server stop + # Find out how full it is. FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'` echo "SCC layer is $FULL% full. Destroying layer." @@ -123,6 +143,12 @@ fi for ((i=0; i<$ITERATIONS; i++)) do /opt/ibm/wlp/bin/server start + + if [ ${WARM_ENDPOINT} == true ] + then + curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing" + fi + /opt/ibm/wlp/bin/server stop done @@ -136,6 +162,7 @@ then chmod -R g+rwx /output/resources fi + # Tell the user how full the final layer is. FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'` echo "SCC layer is $FULL% full."