Skip to content

Commit a185855

Browse files
authored
CI performance tweaks (#4989)
This adds a new tool to CI described over here https://github.com/ClementTsang/mtime-travel -- TL;DR it keeps a json file listing hashes of source files and mtimes and _resets the mtimes_ if the hashes don't change. This makes the thing CI does where it checks out files with git every time (and clobbers their mtimes) not cause spuriouos rebuilds. It should speed things up. I also threw in a small optimization to the second-run testing (tx-meta checking) to skip running all soroban summodule tests a second time -- we run them in the first pass. Also an optimization to avoid testing the same rev back-to-back (eg. on master immediately after testing in a merge queue). This should cut out a third of all runs since we (pessimistically) run on all 3 of PR, merge queue and final master integration.
2 parents de9c193 + 202c80b commit a185855

File tree

5 files changed

+49
-12
lines changed

5 files changed

+49
-12
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*.sln text -merge eol=crlf
22
*.vcxproj text -merge eol=crlf
33
*.vcxproj.filters text -merge eol=crlf
4-
*.sh text -merge eol=lf
4+
*.sh text merge eol=lf

.github/workflows/build.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ jobs:
107107
- name: install rustup components
108108
run: rustup component add rustfmt
109109

110-
- name: install cargo-cache
111-
run: cargo install --locked cargo-cache --version 0.8.3
112-
113-
- name: install cargo-sweep
114-
run: cargo install --locked cargo-sweep --version 0.7.0
110+
- name: cargo install tools
111+
run: |
112+
cargo install --locked cargo-cache --version 0.8.3
113+
cargo install --locked cargo-sweep --version 0.7.0
114+
cargo install --locked mtime-travel --version 0.1.0
115115
116116
- name: Build
117117
run: |
@@ -154,13 +154,11 @@ jobs:
154154
rustup-init -y
155155
rustup component add rustfmt rustc cargo clippy rust-src rust-std
156156
157-
- name: install cargo-cache
157+
- name: cargo install tools
158158
run: |
159159
cargo install --locked cargo-cache --version 0.8.3
160-
161-
- name: install cargo-sweep
162-
run: |
163160
cargo install --locked cargo-sweep --version 0.7.0
161+
cargo install --locked mtime-travel --version 0.1.0
164162
165163
- name: Build
166164
run: |

ci-build.sh

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,35 @@ SRC_DIR=$(pwd)
6767
mkdir -p "build-${CC}-${PROTOCOL}"
6868
cd "build-${CC}-${PROTOCOL}"
6969

70+
# Check to see if we _just_ tested this rev in
71+
# a merge queue, and if so don't bother doing
72+
# it again. Wastes billable CPU time.
73+
if [ -e prev-pass-rev ]
74+
then
75+
PREV_REV=$(cat prev-pass-rev)
76+
CURR_REV=$(git -C "${SRC_DIR}" rev-parse HEAD)
77+
if [ "${PREV_REV}" = "${CURR_REV}" ]
78+
then
79+
exit 0
80+
fi
81+
rm -f prev-pass-rev
82+
fi
83+
84+
85+
# restore source file mtimes based on content hashes
86+
if which mtime-travel >/dev/null 2>&1
87+
then
88+
for DIR in src lib
89+
do
90+
if [ -e mtimes-${DIR}.json ]
91+
then
92+
mtime-travel restore -f mtimes-${DIR}.json ${SRC_DIR}/${DIR}
93+
fi
94+
rm -f mtimes-${DIR}.json
95+
mtime-travel save -f mtimes-${DIR}.json ${SRC_DIR}/${DIR}
96+
done
97+
fi
98+
7099
# Try to ensure we're using the real g++ and clang++ versions we want
71100
mkdir -p bin
72101

@@ -135,11 +164,11 @@ time (cd "${SRC_DIR}" && ./autogen.sh)
135164
time "${SRC_DIR}/configure" $config_flags
136165
if [ -z "${SKIP_FORMAT_CHECK}" ]; then
137166
make format
138-
d=`git diff | wc -l`
167+
d=`git -C "${SRC_DIR}" diff | wc -l`
139168
if [ $d -ne 0 ]
140169
then
141170
echo "clang format must be run as part of the pull request, current diff:"
142-
git diff
171+
git -C "${SRC_DIR}" diff
143172
exit 1
144173
fi
145174
fi
@@ -190,8 +219,11 @@ time make check
190219
echo Running fixed check-test-tx-meta tests
191220
export TEST_SPEC='[tx]'
192221
export STELLAR_CORE_TEST_PARAMS="--ll fatal -r simple --all-versions --rng-seed 12345 --check-test-tx-meta ${SRC_DIR}/test-tx-meta-baseline-${PROTOCOL}"
222+
export SKIP_SOROBAN_TESTS=true
193223
time make check
194224

195225
echo All done
196226
date
227+
228+
git -C "${SRC_DIR}" rev-parse HEAD >prev-pass-rev
197229
exit 0

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ CARGO=cargo +$(RUST_TOOLCHAIN_CHANNEL)
128128
# we pass some configuration by environment variable
129129
# to tests since they can't take command-line arguments.
130130
export RUST_TOOLCHAIN_CHANNEL
131+
export SKIP_SOROBAN_TESTS
131132
export top_srcdir
132133
export top_builddir
133134

src/test/check-sorobans

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ then
1717
exit 1
1818
fi
1919

20+
if [ -n "${SKIP_SOROBAN_TESTS}" ];
21+
then
22+
echo "skipping soroban tests"
23+
exit 0
24+
fi
25+
2026
# Define tests to skip
2127
# `test_expected_size` tests the actual memory sizes of types used in memory metering.
2228
# This test is skipped because memory sizes vary based on Rust compiler version and

0 commit comments

Comments
 (0)