Team Ai
Modelpublic

Felipe97/llama-cpp-compiled

sourceHugging Faceupdated 21d agoView on Hugging Face
0likes1.2kdownloads
build-profiling.md123 linesDownload Raw Back to docs
1## Build profiling2This page is a working document for analyzing the current build and try to3identify ways to improve the build time.4 5### Requirements6The profiling script requires clang to be used as the compiler tool chain and7also requires that ClangBuildAnalyzer is installed.8 9Mac:10```console11brew install clang-build-analyzer12```13 14Linux:15```console16git clone https://github.com/aras-p/ClangBuildAnalyzer.git17cd ClangBuildAnalyzer18cmake -B build -DCMAKE_BUILD_TYPE=Release19cmake --build build -j$(nproc)20sudo cp build/ClangBuildAnalyzer /usr/local/bin/21```22 23Windows: install LLVM/clang and Ninja (e.g. via the24[LLVM releases page](https://github.com/llvm/llvm-project/releases) and25`winget install Ninja-build.Ninja`), then build ClangBuildAnalyzer the same26way as on Linux:27```console28git clone https://github.com/aras-p/ClangBuildAnalyzer.git29cd ClangBuildAnalyzer30cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release31cmake --build build --config Release32```33Then add `ClangBuildAnalyzer\build` to `PATH`.34 35### Usage36Mac/Linux:37```console38$ ./scripts/build-profile.sh39```40 41Windows:42```console43> .\scripts\build-profile.ps144```45 46Both accept `--full`/`-Full` (include Server, Tools, and Tests) and a jobs47override (`-jN` / `-Jobs N`).48 49Note: on Windows, `cmake` defaults to the Visual Studio generator, which50ignores `CMAKE_C_COMPILER`/`CMAKE_CXX_COMPILER` and silently falls back to51MSVC. `build-profile.ps1` passes `-G Ninja` so clang is actually used, this52is required on ARM64.53 54### Linux (Ubuntu 24.04)55 56Environment:57- Clang:     18.1.3 (Ubuntu clang version 18.1.3 (1ubuntu1))58- libstdc++: GCC 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04.1)59- Target:    x86_64-pc-linux-gnu60 61```console62+------------------------+-----+------------+------------+------------+63| Build                  | TUs | Frontend   | Backend    | Total      |64+------------------------+-----+------------+------------+------------+65| Minimal, master        | 249 |   468.2 s  |   270.3 s  |   738.5 s  |66| Minimal, with PCH      | 253 |   177.1 s  |   265.8 s  |   442.9 s  |67| Full,    master        | 396 |   811.0 s  |   692.2 s  | 1,503.2 s  |68| Full,    with PCH      | 405 |   380.0 s  |   664.7 s  | 1,044.7 s  |69| Full,    with PCH + UB | 264 |   357.7 s  |   635.7 s  |   993.4 s  |70+------------------------+-----+------------+------------+------------+71 72PCH  = precompiled header.73Full = includes building Server, Tools, and Tests.74UB   = unity build for models75```76Note that the number of translation units (TUs) increases when using precompiled77headers — each PCH target adds one extra TU for the precompilation step itself.78 79### Mac (Apple M3)80 81Environment:82- Clang:  Apple clang version 17.0.0 (clang-1700.3.19.1)83- libc++: ships with Apple clang 17.0.0 (Xcode toolchain)84- Target: arm64-apple-macosx15.685 86```console87+------------------------+-----+------------+------------+------------+88| Build                  | TUs | Frontend   | Backend    | Total      |89+------------------------+-----+------------+------------+------------+90| Minimal, master        | 256 |   154.5 s  |    94.8 s  |   249.3 s  |91| Minimal, with PCH      | 261 |    65.9 s  |    90.0 s  |   155.9 s  |92| Full,    master        | 407 |   265.7 s  |   209.7 s  |   475.4 s  |93| Full,    with PCH      | 414 |   154.6 s  |   197.5 s  |   352.1 s  |94| Full,    with PCH + UB | 274 |   143.0 s  |   192.2 s  |   335.2 s  |95+------------------------+-----+------------+------------+------------+96 97PCH = precompiled header.98Full = includes building Server, Tools, and Tests.99UB   = unity build for models100```101 102### Windows (ARM64)103 104Environment:105- Clang:  clang version 22.1.8 (LLVM, `C:\Program Files\LLVM`)106- STL:    MSVC STL (Visual Studio 2022 Build Tools 14.44.35207)107- Target: aarch64-pc-windows-msvc108 109```console110+------------------------+-----+------------+------------+------------+111| Build                  | TUs | Frontend   | Backend    | Total      |112+------------------------+-----+------------+------------+------------+113| Minimal, master        | 249 |   159.4 s  |    82.2 s  |   241.6 s  |114| Full,    master        | 373 |   337.2 s  |   167.4 s  |   504.6 s  |115| Minimal, with PCH + UB | 113 |    62.3 s  |    82.4 s  |   144.7 s  |116| Full,    with PCH + UB | 240 |   233.0 s  |   185.1 s  |   418.1 s  |117+------------------------+-----+------------+------------+------------+118 119PCH = precompiled header.120Full = includes building Server, Tools, and Tests.121UB   = unity build for models122```123