Skip to content

Commit 89f4197

Browse files
authored
Add WARM endpoint option (#586)
* Add WARM_ENDPOINT option * fix logic * fix path
1 parent bdbc740 commit 89f4197

9 files changed

Lines changed: 150 additions & 12 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ This feature can be controlled via the following variables:
135135
* `SCC_SIZE` (environment variable)
136136
* Description: The size of the application-specific SCC layer in the image. This value is only used if `TRIM_SCC` is set to `"false"`.
137137
* Default: `"80m"`.
138+
* `WARM_ENDPOINT` (environment variable)
139+
* 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.
140+
* Default: `"true"`.
141+
* `WARM_ENDPOINT_URL` (enviornment variable)
142+
* Description: The URL to access during SCC population if WARM_ENDPOINT is true.
143+
* Default: `"localhost:9080/"`.
138144

139145
## Logging
140146

ga/23.0.0.12/kernel/helpers/build/configure.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ function main() {
179179
if [ ! "$SCC_SIZE" = "" ]; then
180180
cmd+=" -s $SCC_SIZE"
181181
fi
182+
if [ "$WARM_ENDPOINT" = "false" ]; then
183+
cmd+=" -c"
184+
fi
185+
if [ ! "$WARM_ENDPOINT_URL" = "" ]; then
186+
cmd+=" -u $WARM_ENDPOINT_URL"
187+
fi
182188
eval $cmd
183189
fi
184190
}

ga/23.0.0.12/kernel/helpers/build/populate_scc.sh

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# (C) Copyright IBM Corporation 2020.
2+
# (C) Copyright IBM Corporation 2020, 2024
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@ set -Eeox pipefail
2424
SCC_SIZE="80m" # Default size of the SCC layer.
2525
ITERATIONS=2 # Number of iterations to run to populate it.
2626
TRIM_SCC=yes # Trim the SCC to eliminate any wasted space.
27+
WARM_ENDPOINT=true
28+
WARM_ENDPOINT_URL=localhost:9080/
2729

2830
# 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.
2931
# If not, build on our own SCC.
@@ -48,7 +50,7 @@ CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess"
4850
DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy"
4951
PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats"
5052

51-
while getopts ":i:s:tdh" OPT
53+
while getopts ":i:s:u:tdhwc" OPT
5254
do
5355
case "$OPT" in
5456
i)
@@ -64,13 +66,24 @@ do
6466
d)
6567
TRIM_SCC=no
6668
;;
69+
w)
70+
WARM_ENDPOINT=true
71+
;;
72+
c)
73+
WARM_ENDPOINT=false
74+
;;
75+
u)
76+
WARM_ENDPOINT_URL="${OPTARG}"
77+
;;
6778
h)
6879
echo \
69-
"Usage: $0 [-i iterations] [-s size] [-t] [-d]
80+
"Usage: $0 [-i iterations] [-s size] [-t] [-d] [-w] [-u url]
7081
-i <iterations> Number of iterations to run to populate the SCC. (Default: $ITERATIONS)
7182
-s <size> Size of the SCC in megabytes (m suffix required). (Default: $SCC_SIZE)
7283
-t Trim the SCC to eliminate most of the free space, if any.
7384
-d Don't trim the SCC.
85+
-w Use curl to warm an endpoint during SCC creation. (Default: $WARM_ENDPOINT)
86+
-u The URL endpoint to warm during SCC creation. (Default: $WARM_ENDPOINT_URL)
7487
7588
Trimming enabled=$TRIM_SCC"
7689
exit 1
@@ -98,7 +111,14 @@ then
98111
echo "Calculating SCC layer upper bound, starting with initial size $SCC_SIZE."
99112
# Populate the newly created class cache layer.
100113
/opt/ibm/wlp/bin/server start
114+
115+
if [ ${WARM_ENDPOINT} == true ]
116+
then
117+
curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing"
118+
fi
119+
101120
/opt/ibm/wlp/bin/server stop
121+
102122
# Find out how full it is.
103123
FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'`
104124
echo "SCC layer is $FULL% full. Destroying layer."
@@ -122,6 +142,12 @@ fi
122142
for ((i=0; i<$ITERATIONS; i++))
123143
do
124144
/opt/ibm/wlp/bin/server start
145+
146+
if [ ${WARM_ENDPOINT} == true ]
147+
then
148+
curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing"
149+
fi
150+
125151
/opt/ibm/wlp/bin/server stop
126152
done
127153

@@ -135,6 +161,7 @@ then
135161
chmod -R g+rwx /output/resources
136162
fi
137163

164+
138165
# Tell the user how full the final layer is.
139166
FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'`
140167
echo "SCC layer is $FULL% full."

ga/23.0.0.9/kernel/helpers/build/configure.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ function main() {
176176
if [ ! "$SCC_SIZE" = "" ]; then
177177
cmd+=" -s $SCC_SIZE"
178178
fi
179+
if [ "$WARM_ENDPOINT" = "false" ]; then
180+
cmd+=" -c"
181+
fi
182+
if [ ! "$WARM_ENDPOINT_URL" = "" ]; then
183+
cmd+=" -u $WARM_ENDPOINT_URL"
184+
fi
179185
eval $cmd
180186
fi
181187
}

ga/23.0.0.9/kernel/helpers/build/populate_scc.sh

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# (C) Copyright IBM Corporation 2020.
2+
# (C) Copyright IBM Corporation 2020, 2024
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@ set -Eeox pipefail
2424
SCC_SIZE="80m" # Default size of the SCC layer.
2525
ITERATIONS=2 # Number of iterations to run to populate it.
2626
TRIM_SCC=yes # Trim the SCC to eliminate any wasted space.
27+
WARM_ENDPOINT=true
28+
WARM_ENDPOINT_URL=localhost:9080/
2729

2830
# 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.
2931
# If not, build on our own SCC.
@@ -48,7 +50,7 @@ CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess"
4850
DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy"
4951
PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats"
5052

51-
while getopts ":i:s:tdh" OPT
53+
while getopts ":i:s:u:tdhwc" OPT
5254
do
5355
case "$OPT" in
5456
i)
@@ -64,13 +66,24 @@ do
6466
d)
6567
TRIM_SCC=no
6668
;;
69+
w)
70+
WARM_ENDPOINT=true
71+
;;
72+
c)
73+
WARM_ENDPOINT=false
74+
;;
75+
u)
76+
WARM_ENDPOINT_URL="${OPTARG}"
77+
;;
6778
h)
6879
echo \
69-
"Usage: $0 [-i iterations] [-s size] [-t] [-d]
80+
"Usage: $0 [-i iterations] [-s size] [-t] [-d] [-w] [-u url]
7081
-i <iterations> Number of iterations to run to populate the SCC. (Default: $ITERATIONS)
7182
-s <size> Size of the SCC in megabytes (m suffix required). (Default: $SCC_SIZE)
7283
-t Trim the SCC to eliminate most of the free space, if any.
7384
-d Don't trim the SCC.
85+
-w Use curl to warm an endpoint during SCC creation. (Default: $WARM_ENDPOINT)
86+
-u The URL endpoint to warm during SCC creation. (Default: $WARM_ENDPOINT_URL)
7487
7588
Trimming enabled=$TRIM_SCC"
7689
exit 1
@@ -98,7 +111,14 @@ then
98111
echo "Calculating SCC layer upper bound, starting with initial size $SCC_SIZE."
99112
# Populate the newly created class cache layer.
100113
/opt/ibm/wlp/bin/server start
114+
115+
if [ ${WARM_ENDPOINT} == true ]
116+
then
117+
curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing"
118+
fi
119+
101120
/opt/ibm/wlp/bin/server stop
121+
102122
# Find out how full it is.
103123
FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'`
104124
echo "SCC layer is $FULL% full. Destroying layer."
@@ -122,6 +142,12 @@ fi
122142
for ((i=0; i<$ITERATIONS; i++))
123143
do
124144
/opt/ibm/wlp/bin/server start
145+
146+
if [ ${WARM_ENDPOINT} == true ]
147+
then
148+
curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing"
149+
fi
150+
125151
/opt/ibm/wlp/bin/server stop
126152
done
127153

@@ -135,6 +161,7 @@ then
135161
chmod -R g+rwx /output/resources
136162
fi
137163

164+
138165
# Tell the user how full the final layer is.
139166
FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'`
140167
echo "SCC layer is $FULL% full."

ga/24.0.0.2/kernel/helpers/build/configure.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ function main() {
179179
if [ ! "$SCC_SIZE" = "" ]; then
180180
cmd+=" -s $SCC_SIZE"
181181
fi
182+
if [ "$WARM_ENDPOINT" = "false" ]; then
183+
cmd+=" -c"
184+
fi
185+
if [ ! "$WARM_ENDPOINT_URL" = "" ]; then
186+
cmd+=" -u $WARM_ENDPOINT_URL"
187+
fi
182188
eval $cmd
183189
fi
184190
}

ga/24.0.0.2/kernel/helpers/build/populate_scc.sh

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# (C) Copyright IBM Corporation 2020.
2+
# (C) Copyright IBM Corporation 2020, 2024
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@ set -Eeox pipefail
2424
SCC_SIZE="80m" # Default size of the SCC layer.
2525
ITERATIONS=2 # Number of iterations to run to populate it.
2626
TRIM_SCC=yes # Trim the SCC to eliminate any wasted space.
27+
WARM_ENDPOINT=true
28+
WARM_ENDPOINT_URL=localhost:9080/
2729

2830
# 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.
2931
# If not, build on our own SCC.
@@ -49,7 +51,7 @@ CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess"
4951
DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy"
5052
PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats"
5153

52-
while getopts ":i:s:tdh" OPT
54+
while getopts ":i:s:u:tdhwc" OPT
5355
do
5456
case "$OPT" in
5557
i)
@@ -65,13 +67,24 @@ do
6567
d)
6668
TRIM_SCC=no
6769
;;
70+
w)
71+
WARM_ENDPOINT=true
72+
;;
73+
c)
74+
WARM_ENDPOINT=false
75+
;;
76+
u)
77+
WARM_ENDPOINT_URL="${OPTARG}"
78+
;;
6879
h)
6980
echo \
70-
"Usage: $0 [-i iterations] [-s size] [-t] [-d]
81+
"Usage: $0 [-i iterations] [-s size] [-t] [-d] [-w] [-u url]
7182
-i <iterations> Number of iterations to run to populate the SCC. (Default: $ITERATIONS)
7283
-s <size> Size of the SCC in megabytes (m suffix required). (Default: $SCC_SIZE)
7384
-t Trim the SCC to eliminate most of the free space, if any.
7485
-d Don't trim the SCC.
86+
-w Use curl to warm an endpoint during SCC creation. (Default: $WARM_ENDPOINT)
87+
-u The URL endpoint to warm during SCC creation. (Default: $WARM_ENDPOINT_URL)
7588
7689
Trimming enabled=$TRIM_SCC"
7790
exit 1
@@ -99,7 +112,14 @@ then
99112
echo "Calculating SCC layer upper bound, starting with initial size $SCC_SIZE."
100113
# Populate the newly created class cache layer.
101114
/opt/ibm/wlp/bin/server start
115+
116+
if [ ${WARM_ENDPOINT} == true ]
117+
then
118+
curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing"
119+
fi
120+
102121
/opt/ibm/wlp/bin/server stop
122+
103123
# Find out how full it is.
104124
FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'`
105125
echo "SCC layer is $FULL% full. Destroying layer."
@@ -123,6 +143,12 @@ fi
123143
for ((i=0; i<$ITERATIONS; i++))
124144
do
125145
/opt/ibm/wlp/bin/server start
146+
147+
if [ ${WARM_ENDPOINT} == true ]
148+
then
149+
curl --silent --output /dev/null --show-error --fail --max-time 5 ${WARM_ENDPOINT_URL} 2>&1 || echo "WARM_ENDPOINT call failed, continuing"
150+
fi
151+
126152
/opt/ibm/wlp/bin/server stop
127153
done
128154

@@ -136,6 +162,7 @@ then
136162
chmod -R g+rwx /output/resources
137163
fi
138164

165+
139166
# Tell the user how full the final layer is.
140167
FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'`
141168
echo "SCC layer is $FULL% full."

ga/latest/kernel/helpers/build/configure.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ function main() {
179179
if [ ! "$SCC_SIZE" = "" ]; then
180180
cmd+=" -s $SCC_SIZE"
181181
fi
182+
if [ "$WARM_ENDPOINT" = "false" ]; then
183+
cmd+=" -c"
184+
fi
185+
if [ ! "$WARM_ENDPOINT_URL" = "" ]; then
186+
cmd+=" -u $WARM_ENDPOINT_URL"
187+
fi
182188
eval $cmd
183189
fi
184190
}

0 commit comments

Comments
 (0)