Skip to content

​Performance: Slow startup and incremental build latency compared to CMake​​ #6767

@simonkimi

Description

@simonkimi

Xmake Version

xmake v3.0.2+HEAD.993b5c30d Qt5.14.2 mingw730_64

Operating System Version and Architecture

Windows 11 专业版 24H2 26100.3194

Describe Bug

When running xmake, even if no files have been changed, it takes approximately 10 seconds to complete and output [100%]: build ok. In contrast, under the same conditions, CMake instantly outputs "ninja: no work to do."

When a small number of files need to be compiled, if CMake takes 10 seconds to complete the build, xmake requires about 20 seconds. This suggests that xmake incurs a significant fixed startup overhead with each build.

Output:

bts_windows_003 on  xmake via △ v4.0.3 via 🌙 via 🐍 v3.13.3 
❯ xmake
[100%]: build ok, spent 11.328s

bts_windows_003 on  xmake via △ v4.0.3 via 🌙 via 🐍 v3.13.3 took 12s 
❯ xmake
[100%]: build ok, spent 11.157s

bts_windows_003 on  xmake via △ v4.0.3 via 🌙 via 🐍 v3.13.3 took 12s 

❯ D:\CMake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=F:/ide/Jetbrains/CLion/bin/ninja/win/x64/ninja.exe -G Ninja -S F:\Projects\monitor\battery_detect_pc\bts_windows_003 -B F:\Projects\monitor\battery_detect_pc\bts_windows_003\cmake-build-debug-qtmingw
-- The CXX compiler identification is GNU 7.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: G:/Sdks/Qt/Qt5.14.2/Tools/mingw730_64/bin/x86_64-w64-mingw32-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (1.3s)
-- Generating done (0.1s)
-- Build files have been written to: F:/Projects/monitor/battery_detect_pc/bts_windows_003/cmake-build-debug-qtmingw


bts_windows_003 on  xmake via △ v4.0.3 via 🌙 via 🐍 v3.13.3 
❯ D:\CMake\bin\cmake.exe --build F:\Projects\monitor\battery_detect_pc\bts_windows_003\cmake-build-debug-qtmingw --target battery_detect -j 10
ninja: no work to do.

XMAKE_PROFILE=perf:process Output:

❯ cross-env XMAKE_PROFILE=perf:process xmake                                
[100%]: build ok, spent 11.235s
139505.000,  99.87%,     854, G:\Sdks\Qt\Qt5.14.2\Tools\mingw730_64\bin\x86_64-w64-mingw32-g++ --version

bts_windows_003 on  xmake via △ v4.0.3 via 🌙 via 🐍 v3.13.3 took 12s 
❯ G:\Sdks\Qt\Qt5.14.2\Tools\mingw730_64\bin\x86_64-w64-mingw32-g++ --version
x86_64-w64-mingw32-g++.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

It seems that calling x86_64-w64-mingw32-g++ --version took a significant amount of time, but when I manually executed the command, the version number was output instantly.

Expected Behavior

  1. In scenarios involving incremental builds with no changes, xmake should be able to complete almost instantaneously and report (or indicate) "no work to do," similar to CMake.
  2. In scenarios involving incremental builds with minor changes, xmake's build time should be close to the actual time required to compile those few files, without incurring a fixed additional overhead of approximately 10 seconds.

Project Configuration

As this is an internal company project, I am not at liberty to share the entire source code. Additionally, I have been unable to reproduce the issue in other projects using the same toolchain. However, I would be more than happy to provide logs if needed for further investigation.

xmake.exe f -y -m debug -p windows -a x64 --toolchain=mingw --sdk=G:\Sdks\Qt\Qt5.14.2\Tools\mingw730_64
set_project("BatteryDetectSystem")
set_version("1.0.0")

set_xmakever("2.7.0")

set_defaultmode("debug")
set_languages("c++11")

if is_plat("windows") then
    add_defines(
        "PLATFORM_PC",
        "OPTION_NOAUX",
        "OPTION_NODBC",
        "OPTION_NODC",
        "UNICODE",
        "_UNICODE"
    )
    
    if is_mode("debug") then
        set_symbols("debug")
        add_cxflags("-g", "-O0")
    elseif is_mode("release") then
        add_cxflags("-O2", "-g")
    end
    
    add_cxflags("-fpermissive", "-Wno-unused-parameter", "-Wno-unused-result", "-Wno-error", "-w")
end

set_targetdir("$(builddir)/bin")
set_objectdir("$(builddir)/obj")

if not os.getenv("JAVA_HOME") then
    raise("JAVA_HOME 环境变量未设置")
end

add_includedirs(
    "$(env JAVA_HOME)/include",
    "$(env JAVA_HOME)/include/win32"
)

if is_plat("windows") then
    add_syslinks("m", "pthread", "winmm", "ws2_32", "User32", "Kernel32", "iconv")
end

includes("AuxLib")
includes("CanLib")
includes("pcslib")
includes("t30lib")
includes("DbcLib")
includes("modbus")
includes("NetworkLib")
includes("extension")
includes("LedNode")
includes("comlib")
includes("relay")
includes("Ripple")
includes("battery_detect")

Additional Information and Error Logs

❯ xmake -vD                                                                                                                                   

build cache stats:
cache directory: build\.build_cache
cache hit rate: 0%
cache hit: 0
cache hit total time: 0.000s
cache miss: 0
cache miss total time: 0.000s
new cached files: 0
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0
compile total time: 0.000s

[100%]: build ok, spent 11.343s

bts_windows_003 on  xmake via △ v4.0.3 via 🌙 via 🐍 v3.13.3 took 12s 
❯ 
❯ cross-env XMAKE_PROFILE=perf:call xmake                     
[100%]: build ok, spent 25.625s
29.107,  99.99%,       1, cotask                        : @programdir\core\main.lua: 326
25.621,  88.01%,       1, build_targets                 : @programdir\actions\build\main.lua: 114
25.621,  88.01%,       1, anonymous                     : @programdir\actions\build\main.lua: 118
25.442,  87.40%,       1, _do_build                     : @programdir\actions\build\main.lua: 104
25.426,  87.34%,       2, run_targetjobs                : @programdir\modules\private\action\build\target.lua: 768
24.813,  85.24%,       1, _build                        : @programdir\actions\build\build.lua: 38
16.778,  57.63%,     203, jobfunc                       : @programdir\modules\private\action\build\object.lua: 169
16.770,  57.61%,     203, build_object                  : @programdir\modules\private\action\build\object.lua: 128
16.762,  57.58%,     203, script                        : @programdir\modules\private\action\build\object.lua: 32
16.149,  55.47%,     333, cotask                        : @programdir\modules\async\runjobs.lua: 228
16.095,  55.29%,     333, anonymous                     : @programdir\modules\async\runjobs.lua: 231
16.064,  55.18%,      65, co_group_wait                 : ...mdir\core\sandbox\modules\import\core\base\scheduler.lua: 117
16.063,  55.18%,      65, co_group_wait                 : @programdir\core\base\scheduler.lua: 638
15.416,  52.96%,     854, _find_tool                    : @programdir\modules\lib\detect\find_tool.lua: 40
15.408,  52.93%,     854, _find_from_modules            : @programdir\modules\lib\detect\find_tool.lua: 29
15.063,  51.74%,     216, _add_flags_from_target        : @programdir\core\tool\builder.lua: 245
14.423,  49.54%,     797, _add_flags_from_flagkind      : @programdir\core\tool\builder.lua: 159
14.319,  49.19%,     854, iorunv                        : @programdir\core\sandbox\modules\os.lua: 312
14.155,  48.62%,     854, iorunv                        : @programdir\core\base\os.lua: 1031
12.236,  42.03%,     854, execv                         : @programdir\core\base\os.lua: 855
 9.043,  31.06%,     854, _openv                        : [C]: -1
 6.505,  22.35%,      63, co_group_begin                : ...mdir\core\sandbox\modules\import\core\base\scheduler.lua: 109
 6.504,  22.34%,      63, co_group_begin                : @programdir\core\base\scheduler.lua: 613
 6.495,  22.31%,      63, anonymous                     : @programdir\modules\async\runjobs.lua: 186
 6.439,  22.12%,     333, co_start_withopt              : ...mdir\core\sandbox\modules\import\core\base\scheduler.lua: 53
 6.437,  22.11%,     333, co_start_withopt              : @programdir\core\base\scheduler.lua: 388
 6.339,  21.78%,     333, co_resume                     : @programdir\core\base\scheduler.lua: 438
 6.329,  21.74%,     333, resume                        : @programdir\core\base\coroutine.lua: 33
 6.326,  21.73%,     333, _resume                       : [C]: -1
 3.949,  13.57%,    1214, getenvs                       : @programdir\core\base\os.lua: 1294
 2.972,  10.21%,       1, run                           : @programdir\core\sandbox\modules\import\core\base\task.lua: 35
 2.852,   9.80%,       2, get_targetjobs                : @programdir\modules\private\action\build\target.lua: 377
 2.830,   9.72%,       2, run                           : @programdir\core\base\task.lua: 492
 2.527,   8.68%,      26, add_targetjobs                : @programdir\modules\private\action\build\target.lua: 279
 2.398,   8.24%,    1133, xpcall                        : [C]: -1
 1.990,   6.84%,    1633, import                        : ...mdir\core\sandbox\modules\import\core\sandbox\module.lua: 488
 1.654,   5.68%,     113, add_orders                    : @programdir\modules\async\jobgraph.lua: 142
 1.587,   5.45%,    1128, add_edge                      : @programdir\core\base\graph.lua: 377
 1.560,   5.36%,      46, add_targetjobs_and_deps       : @programdir\modules\private\action\build\target.lua: 357
 1.538,   5.28%, 1033138, for iterator                  : [C]: -1
 1.520,   5.22%,     334, _co_curenvs_update            : @programdir\core\base\scheduler.lua: 291
 1.513,   5.20%,       1, _check_targets                : @programdir\actions\config\main.lua: 117
 1.437,   4.94%,    1640, _find_and_load                : ...mdir\core\sandbox\modules\import\core\sandbox\module.lua: 368
 1.386,   4.76%,    5125, _find                         : ...mdir\core\sandbox\modules\import\core\sandbox\module.lua: 106
 1.382,   4.75%,       1, _load_targets                 : @programdir\core\project\project.lua: 380
 1.103,   3.79%,     669, trycall                       : @programdir\core\base\utils.lua: 245
 1.041,   3.58%,  196256, trim                          : @programdir\core\base\string.lua: 120
 1.022,   3.51%,     129, _add_flags_from_language      : @programdir\core\tool\builder.lua: 426
 0.955,   3.28%,    3588, inherit                       : @programdir\core\base\table.lua: 192
 0.945,   3.25%,    1709, readfile                      : @programdir\core\base\io.lua: 487
 0.941,   3.23%,    2115, _add_items_from_target        : @programdir\core\tool\builder.lua: 402
 0.940,   3.23%,    2644, get_from                      : @programdir\core\project\target.lua: 702
 0.939,   3.23%,       1, _config_targets               : ...dir\core\sandbox\modules\import\core\project\project.lua: 176
 0.939,   3.23%,      13, _config_target                : ...dir\core\sandbox\modules\import\core\project\project.lua: 130
 0.939,   3.23%,       1, load_targets                  : ...dir\core\sandbox\modules\import\core\project\project.lua: 225
 0.842,   2.89%,    1708, rm                            : @programdir\core\base\os.lua: 551
 0.833,   2.86%,    3692, group                         : @programdir\modules\async\jobgraph.lua: 126
 0.819,   2.81%,   11208, _get_from_source              : @programdir\core\project\target.lua: 403
 0.802,   2.75%,      14, rules                         : @programdir\core\project\rule.lua: 434
 0.802,   2.75%,      13, rule                          : @programdir\core\project\rule.lua: 429
 0.796,   2.73%,    1708, _rm                           : @programdir\core\base\os.lua: 146
 0.766,   2.63%,     216, load                          : @programdir\modules\core\project\depend.lua: 54
 0.765,   2.63%,     117, add_targetjobs_with_stage     : @programdir\modules\private\action\build\target.lua: 218
 0.724,   2.49%,     103, _load                         : @programdir\core\project\rule.lua: 260
 0.718,   2.47%,     854, wait                          : @programdir\core\base\process.lua: 82
 0.697,   2.39%,     117, callback                      : @programdir\modules\private\action\build\target.lua: 241
 0.687,   2.36%,     854, poller_waitproc               : @programdir\core\base\scheduler.lua: 847
 0.661,   2.27%,    1708, rmfile                        : [C]: -1
 0.643,   2.21%,   56975, gsub                          : [C]: -1
 0.640,   2.20%,      13, contains_modules              : @programdir\rules\c++\modules\support.lua: 170
 0.639,   2.20%,     139, sourcebatches                 : @programdir\core\project\target.lua: 2335
 0.632,   2.17%,     129, make                          : @programdir\core\base\interpreter.lua: 794
 0.615,   2.11%,       1, _prepare                      : @programdir\actions\build\build.lua: 30
 0.610,   2.10%,   24518, get                           : @programdir\core\project\target.lua: 579
 0.605,   2.08%,     129, anonymous                     : @programdir\core\base\interpreter.lua: 532
 0.596,   2.05%,     123, load                          : @programdir\core\base\interpreter.lua: 759
 0.588,   2.02%,  374701, type                          : [C]: -1
 0.570,   1.96%,    5303, _modulepath                   : ...mdir\core\sandbox\modules\import\core\sandbox\module.lua: 45
 0.554,   1.90%,    3544, instance                      : @programdir\core\sandbox\sandbox.lua: 249
 0.505,   1.73%,       1, anonymous                     : @programdir\actions\build\main.lua: 0
 0.504,   1.73%,     145, module                        : @programdir\core\sandbox\sandbox.lua: 195
 0.475,   1.63%,    2141, _get_from_deps                : @programdir\core\project\target.lua: 277
 0.464,   1.59%,    1882, vformat                       : @programdir\core\sandbox\modules\string.lua: 37
 0.456,   1.57%,     203, _load_depfiles                : @programdir\modules\core\project\depend.lua: 26
 0.453,   1.56%,     215, _handle                       : @programdir\core\base\interpreter.lua: 498
 0.445,   1.53%,    9256, script                        : @programdir\core\project\rule.lua: 175
 0.442,   1.52%,    3159, callback                      : @programdir\modules\private\action\build\target.lua: 251
 0.441,   1.51%,    9340, isfile                        : [C]: -1
 0.434,   1.49%,    3159, add_targetjobs_for_script     : @programdir\modules\private\action\build\target.lua: 147
 0.432,   1.48%,    9254, join                          : @programdir\core\base\table.lua: 93
 0.431,   1.48%,     178, _load                         : ...mdir\core\sandbox\modules\import\core\sandbox\module.lua: 336
 0.417,   1.43%,      13, callback                      : @programdir\modules\private\action\build\build_binary.lua: 36
 0.416,   1.43%,      13, add_linkjobs                  : @programdir\modules\private\action\build\target.lua: 682
 0.393,   1.35%,      26, add_filejobs                  : @programdir\modules\private\action\build\target.lua: 628
 0.391,   1.34%,      78, add_filejobs_with_stage       : @programdir\modules\private\action\build\target.lua: 534
 0.377,   1.30%,   13771, pcall                         : [C]: -1
 0.371,   1.27%,     550, try                           : @programdir\core\sandbox\modules\try.lua: 107
 0.370,   1.27%,     452, _new                          : @programdir\core\sandbox\sandbox.lua: 94
 0.353,   1.21%,       1, anonymous                     : @programdir\actions\config\main.lua: 0
 0.351,   1.21%,  206400, sub                           : [C]: -1
 0.350,   1.20%,      78, callback                      : @programdir\modules\private\action\build\target.lua: 586
 0.342,   1.17%,     312, callback                      : @programdir\modules\private\action\build\target.lua: 598
 0.339,   1.16%,     390, add_filejobs_for_script       : @programdir\modules\private\action\build\target.lua: 387
 0.321,   1.10%,    7497, join2                         : @programdir\core\base\table.lua: 109
 0.316,   1.09%,       9, _load_scope                   : @programdir\core\project\project.lua: 274
 0.313,   1.08%,      44, _add_targetjobs_plain_orders  : @programdir\modules\private\action\build\target.lua: 96
 0.308,   1.06%,      13, jobfunc                       : @programdir\modules\private\action\build\link_objects.lua: 67
 0.308,   1.06%,      13, _do_link_target               : @programdir\modules\private\action\build\link_objects.lua: 31
 0.304,   1.04%,   13182, anonymous                     : @programdir\core\base\compat\env.lua: 81
 0.294,   1.01%,    8862, handle                        : @programdir\core\base\filter.lua: 165
 0.293,   1.01%,  196459, _trim                         : [C]: -1
full log written to C:\Users\ms\AppData\Local\Temp\.xmake\250905\perf-call-05-09-25-13-55-09.log

bts_windows_003 on  xmake via △ v4.0.3 via 🌙 via 🐍 v3.13.3 took 29s 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions