Repository navigation
Conversation
At -O0 the uninlined expression templates make each test object about 5x larger; a gate build directory drops from 8.2 GB to 2.7 GB. NUMSIM_MATERIALS_TEST_OPT_FLAGS overrides it, an explicit CMAKE_BUILD_TYPE turns it off.
…e CI leg The cache value is now 'auto' and is resolved at each configure: -O1 only without a build type, with a single-config generator and without an -O option in CMAKE_CXX_FLAGS. Other values are used verbatim (split into arguments), empty turns it off. CI gains a clang++-19 leg without a build type so the -O1 warnings under -Werror are covered.
Member
Author
|
Review findings addressed in b1f5e6b.
Configure-only check on cmake228.sh#!/bin/bash
# Configure-only check of the test optimisation flags in compile_commands.json (no build).
SRC=${1:-$HOME/devel/nm-o1}
W=${2:-/tmp/cmake228}
DEPS=$HOME/devel/nm-o1-build/_deps
TU=test_core_utilities.cpp
rm -rf "$W"; mkdir -p "$W"
cfg() { # dir args...
local d=$W/$1; shift
CXX=/usr/bin/g++-14 cmake -S "$SRC" -B "$d" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DNUMSIM_PREFER_SIBLINGS=OFF \
-DFETCHCONTENT_SOURCE_DIR_TMECH=$DEPS/tmech-src -DFETCHCONTENT_SOURCE_DIR_NUMSIM-CORE=$DEPS/numsim-core-src \
-DNUMSIM_MATERIALS_BUILD_EXAMPLES=OFF "$@" > "$d.log" 2>&1 || { echo "configure failed: $d"; tail -5 "$d.log"; }
}
# prints the compile flags of every entry of $TU as one token per line, entries separated by ---
flags() {
python3 -I - "$W/$1/compile_commands.json" "$TU" <<'PY'
import json, shlex, sys
for e in json.load(open(sys.argv[1])):
if e["file"].endswith("/" + sys.argv[2]):
print(" ".join("[" + t + "]" for t in shlex.split(e["command"]) if t.startswith(("-O", "-g"))) or "(none)")
PY
}
fail=0
check() { # label dir want-regex-present want-regex-absent
local out; out=$(flags "$2")
local ok=1
[ -n "$out" ] || ok=0
while IFS= read -r line; do
[ -n "$3" ] && ! grep -qE -- "$3" <<<"$line" && ok=0
[ -n "$4" ] && grep -qE -- "$4" <<<"$line" && ok=0
done <<<"$out"
echo "$1: $([ $ok = 1 ] && echo PASS || echo FAIL)"; sed 's/^/ /' <<<"$out"; [ $ok = 1 ] || fail=1
}
cfg a
check "A fresh, no build type: -O1 present" a '\[-O1\]' ''
cfg a -DCMAKE_BUILD_TYPE=Release
check "B same dir reconfigured with Release: -O1 absent" a '\[-O3\]' '\[-O1\]'
cfg c -DCMAKE_CXX_FLAGS=-O0
check "C CMAKE_CXX_FLAGS=-O0: no -O1" c '\[-O0\]' '\[-O1\]'
cfg d "-DNUMSIM_MATERIALS_TEST_OPT_FLAGS=-O1 -g"
check "D OPT_FLAGS=\"-O1 -g\": two separate args" d '\[-O1\].*\[-g\]' '\[-O1 -g\]'
cfg e -DNUMSIM_MATERIALS_TEST_OPT_FLAGS=
check "E OPT_FLAGS empty: off" e '' '\[-O'
exit $failBefore the fix (cases B, C, D fail; E passes because the empty value was already honoured): After the fix: Gate (GCC 14, |
# Conflicts: # .github/workflows/ci.yml # tests/CMakeLists.txt
Member
Author
|
Merged main (#238, batched tests and split CI jobs) into this branch. Two conflicts:
The configure check from the PR description passes all five cases (fresh, Release on the same dir, Gate: g++-14 -O1, 1486 tests, 0 warnings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A local gate build directory (GCC 14, plain + ASan tests, reports) was 8.2 GB, and a dozen of them filled the disk. 8.1 GB of that is
tests/.CMAKE_BUILD_TYPEis empty by default, so every test compiles at-O0. Each of the 75 test files then instantiates tmech's expression templates and the materials without any inlining, and the ASan copy is about 4× larger again.What
tests/CMakeLists.txtaddsNUMSIM_MATERIALS_TEST_OPT_FLAGSto every test target: plain,_asanand_tsan.auto, resolved on every configure:-O1only when no build type is set, the generator is single-config andCMAKE_CXX_FLAGShas no-Ooption. Any other value is used as given.CMAKE_BUILD_TYPE(for exampleDebug) leaves the flags alone.-DNUMSIM_MATERIALS_TEST_OPT_FLAGS=turns it off.-O1is also what the ASan documentation recommends.The library itself is header-only and unaffected.
examples/and thematerial_reporttool are unchanged.Measured
-O0(main)-O1test_report_case.cpp.o-O2: 6.1 MB)-j4ctest -j4, 1440 tests* The wall time of the measured run was 182 min, but no object was written for two stretches of 125 and 32 minutes, while the machine lost its network connection. The active compile time is the span minus those gaps.
One test file (
test_report_case.cpp, compiled alone, same machine):-O0-O1-O0ASan-O1ASanSo
-O1is nearly free for the plain tests and costs about 60% more compile time on the ASan copy for a 30% smaller object; overall about +25% build time for a third of the disk.Test time barely changes, because most of it is process start-up and test discovery across 150 executables.
Not here
Merging the 75 test executables into a few per area would shrink objects and link time further. That is a larger change to
tests/CMakeLists.txt.Gate
GCC 14, reports on,
-DNUMSIM_PREFER_SIBLINGS=OFF: 1440/1440 tests pass, 0 warnings.