-
Notifications
You must be signed in to change notification settings - Fork 1
Description
On my laptop with Ubuntu 24.04 and 16GB of RAM I have noticed that compiling gambit with gcc/g++ will sometimes max out my available memory and the compilation gets killed. This is already known issue but even compiling a very minimal set of gambit, i.e. ditching many modules it already gets quite close to the memory limit.
I have started to have a look into using clang/clang++ as an alternative and I have found that compiling gambit with clang is way faster and much more efficient when it comes to RAM usage. Hence, it might be worth to adapt clang instead of using gcc. Moreover, it might be worth to include clang in our CI pipeline.
I have run some test by using the following cmake build definitions:
"CMAKE_BUILD_TYPE": "None",
"CMAKE_Fortran_COMPILER": "gfortran-13",
"PYTHON_EXECUTABLE": "./gambit_venv/bin/python3",
"PYTHON_LIBRARY": "/usr/lib/x86_64-linux-gnu/libpython3.12.so",
"PYTHON_INCLUDE_DIR": "/usr/include/python3.12",
"(D)itch": "Collider;Decay;Flav;Spec;Precision;Objectives",
"WITH_MPI": "0",
"WITH_ROOT": "0",
"WITH_HEPMC": "0",
"WITH_RESTFRAMES": "0",
"SUPPRESS_LIBRARY_WARNINGS": "1"
once for gcc/g++ (version 13.3.0) as compilers and once with clang/clang++ (version 18.1.3).
Furthermore, I have build diver, multinest and polychord as scanners which are included in the build. After that I built the "gambit"
To compare the performance and memory of either compiler preset, I have ran the build up to the point when only gambit.cpp is left as the last compilation unit and then re-run it such that I only benchmark the compilation of the main and the subsequent linking step
I have found when running /usr/bin/time -v cmake --build --preset gcc --target gambit (Using a preset file, attached below)
Command being timed: "cmake --build --preset gcc --target gambit"
User time (seconds): 452.87
System time (seconds): 14.74
Percent of CPU this job got: 101%
Elapsed (wall clock) time (h:mm:ss or m:ss): 7:42.67
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 12533640
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 1645
Minor (reclaiming a frame) page faults: 4205931
Voluntary context switches: 11694
Involuntary context switches: 4889
Swaps: 0
File system inputs: 1072776
File system outputs: 316528
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
and for clang (with /usr/bin/time -v cmake --build --preset clang --target gambit) the timing results are
Command being timed: "cmake --build --preset clang --target gambit"
User time (seconds): 61.76
System time (seconds): 7.04
Percent of CPU this job got: 109%
Elapsed (wall clock) time (h:mm:ss or m:ss): 1:03.06
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 2692160
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 6
Minor (reclaiming a frame) page faults: 1251000
Voluntary context switches: 2630
Involuntary context switches: 692
Swaps: 0
File system inputs: 111856
File system outputs: 307256
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
Whereas gcc almost uses 12.6 GB of RAM and takes about 15 minutes to compile gambit.cpp, clang does the job in just a minute and only uses 2.7 GB
For reference my CMakePresets.json can be found here: CMakePresets.json