Skip to content

Commit 9ec1c10

Browse files
authored
Run the build with check-test-tx-meta sequentially to get most cache hits (#4918)
We currently have a matrix scenario to run with and without the flag check-test-tx-meta. This means they run in parallel jobs and don't take advantage of caching. Running the build with check-test-tx-meta sequentially would get the most cache hits. The tradeoff is that we would have longer CI run by not putting the build with check-test-tx-meta flag in a parallel job. See the outcome in https://github.com/stellar/stellar-core/actions/runs/17438212726 where there are 4 parallel CI jobs taking between 26 to 37 minutes. This PR is making these changes, 1. Run the tests with check-test-tx-meta sequentially after the regular build and test scenario instead of parallel. This would reduce the cost of not having to build again and use local filesystem cache. (maybe 16 core runners are more expensive?) 2. Save the build to Github cache as soon as its available 3. Make ci-build.sh idempotent
2 parents 8eb4a7c + 08c8975 commit 9ec1c10

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ jobs:
6464
matrix:
6565
toolchain: [ "gcc", "clang"]
6666
protocol: ["current", "next"]
67-
scenario: ["", "--check-test-tx-meta"]
6867
steps:
6968
- name: Fix kernel mmap rnd bits
7069
# Asan in llvm provided in ubuntu 22.04 is incompatible with
@@ -141,11 +140,26 @@ jobs:
141140
export CXX='clang++'
142141
fi
143142
echo Build with $CC and $CXX
144-
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }} ${{ matrix.scenario }}
143+
echo "Running first scenario"
144+
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }}
145145
146-
# We only _save_ to the cache when we had a cache miss, are running on master, and are the non-txmeta scenario.
147-
- uses: actions/cache/save@v4
148-
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.ref_name == 'master' && matrix.scenario == ''}}
146+
# We only _save_ to the cache when we had a cache miss and are running on master.
147+
- name: Save cache after first build
148+
uses: actions/cache/save@v4
149+
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.ref_name == 'master' }}
149150
with:
150151
path: ${{ env.CACHED_PATHS }}
151-
key: ${{ steps.cache.outputs.cache-primary-key }}
152+
key: ${{ steps.cache.outputs.cache-primary-key }}
153+
154+
- name: Build for check-test-tx-meta scenario
155+
if: steps.cache.outputs.cache-hit != 'true'
156+
run: |
157+
if test "${{ matrix.toolchain }}" = "gcc" ; then
158+
export CC='gcc'
159+
export CXX='g++'
160+
else
161+
export CC='clang'
162+
export CXX='clang++'
163+
fi
164+
echo "Running second scenario with --check-test-tx-meta flag"
165+
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }} --check-test-tx-meta

ci-build.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ echo "Found $NPROCS processors"
6969
date
7070

7171
# Try to ensure we're using the real g++ and clang++ versions we want
72-
mkdir bin
72+
mkdir -p bin
7373

7474
export PATH=`pwd`/bin:$PATH
7575
echo "PATH is $PATH"
@@ -80,19 +80,19 @@ if test $CXX = 'clang++'; then
8080
# Use CLANG_VERSION environment variable if set, otherwise default to 12
8181
CLANG_VER=${CLANG_VERSION:-12}
8282
which clang-${CLANG_VER}
83-
ln -s `which clang-${CLANG_VER}` bin/clang
83+
ln -sf `which clang-${CLANG_VER}` bin/clang
8484
which clang++-${CLANG_VER}
85-
ln -s `which clang++-${CLANG_VER}` bin/clang++
85+
ln -sf `which clang++-${CLANG_VER}` bin/clang++
8686
which llvm-symbolizer-${CLANG_VER}
87-
ln -s `which llvm-symbolizer-${CLANG_VER}` bin/llvm-symbolizer
87+
ln -sf `which llvm-symbolizer-${CLANG_VER}` bin/llvm-symbolizer
8888
clang -v
8989
llvm-symbolizer --version || true
9090
elif test $CXX = 'g++'; then
9191
RUN_PARTITIONS=$(seq $NPROCS $((2*NPROCS-1)))
9292
which gcc-10
93-
ln -s `which gcc-10` bin/gcc
93+
ln -sf `which gcc-10` bin/gcc
9494
which g++-10
95-
ln -s `which g++-10` bin/g++
95+
ln -sf `which g++-10` bin/g++
9696
which g++
9797
g++ -v
9898
fi
@@ -165,13 +165,15 @@ if [ $WITH_TESTS -eq 0 ] ; then
165165
fi
166166

167167
if [ $TEMP_POSTGRES -eq 0 ] ; then
168-
# Create postgres databases
168+
# Create postgres databases (drop first if they exist to ensure clean state)
169169
export PGUSER=postgres
170+
psql -c "drop database if exists test;" 2>/dev/null || true
170171
psql -c "create database test;"
171172
# we run NPROCS jobs in parallel
172173
for j in $(seq 0 $((NPROCS-1))); do
173174
base_instance=$((j*50))
174175
for i in $(seq $base_instance $((base_instance+15))); do
176+
psql -c "drop database if exists test$i;" 2>/dev/null || true
175177
psql -c "create database test$i;"
176178
done
177179
done

0 commit comments

Comments
 (0)