Skip to content

Commit 1f4552e

Browse files
committed
fix(bench): tell xmake where libc++ is, and drop to three repetitions
**1. Windows 的 `import std` 不是缺口,是没告诉 xmake 去哪找。** 日志把解法写在 脸上,而我先前把它当成平台缺口豁免了: warning: std and std.compat modules not found! maybe try to add --sdk=<PATH/TO/LLVM> or install libc++ error: <mcpp> missing std dependency for module mcpp.build.provisions 载荷里**本来就带着** `share/libc++/v1/std.cppm`。报错点名的是被测工程的模块, 所以读起来像「这个工程坏了」,而不是「引擎不知道自己的标准库在哪」—— windows/clang 格子每个场景都这么红。SDK 根目录由解析后的驱动路径推出 (`…/xim-x-llvm/<ver>/bin/clang++` → `…/<ver>`),和工具链 pin 同源,不需要手工同步。 ⚠️ **第一版补丁放在了控制流到不了的地方**:`--sdk` 加在 `own_description` 分支 **之后**,而那个分支提前 return —— 偏偏 Windows 上失败的 `bench/projects/mcpp` 正是 own_description。这是这个仓库记过的老形状(「修补放在控制流到不了的地方」), 已移到分支之前,两条路径都覆盖。 **2. 每个场景 5 轮改成 3 轮。** 真实工程上「增量」并不便宜 —— `edit-comment` 在 xlings 上要重建 45 个导入者,五轮就是五次近乎完整的重建,一个 windows/clang 格子 为此花掉半小时以上。多出来的样本买不到相称的精度:钉住的工作负载上跨轮离散度 低于 2%,而每张发布的表都取中位数。**没人愿意等的矩阵,就是没人会看的矩阵。**
1 parent 4904c33 commit 1f4552e

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

bench/src/engines/xmake.cppm

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ inline std::string payload_toolchain(std::string_view compiler) {
2626
return clang ? "mcpp-clang" : "mcpp-gcc";
2727
}
2828

29+
// The LLVM root a payload driver lives under: `…/xim-x-llvm/<ver>/bin/clang++`
30+
// → `…/xim-x-llvm/<ver>`. Empty for anything that is not a payload clang.
31+
inline std::string payload_sdk_root(std::string_view compiler) {
32+
if (compiler.find("/registry/data/xpkgs/") == std::string_view::npos &&
33+
compiler.find("\\registry\\data\\xpkgs\\") == std::string_view::npos)
34+
return {};
35+
if (compiler.find("clang") == std::string_view::npos) return {};
36+
const auto slash = compiler.find_last_of("/\\");
37+
if (slash == std::string_view::npos) return {};
38+
const auto bin = compiler.substr(0, slash); // …/<ver>/bin
39+
const auto up = bin.find_last_of("/\\");
40+
if (up == std::string_view::npos) return {};
41+
return std::string(bin.substr(0, up)); // …/<ver>
42+
}
43+
2944
class XmakeEngine : public Engine {
3045
public:
3146
std::string_view name() const override { return "xmake"; }
@@ -63,6 +78,24 @@ public:
6378
// it cannot be turned off without also discarding the toolchain.
6479
"--ccache=n",
6580
};
81+
// ── Tell xmake where libc++ lives, or `import std;` has no provider ──
82+
//
83+
// The payload SHIPS the std module (share/libc++/v1/std.cppm), but xmake
84+
// looks for it under its own notion of an LLVM SDK and otherwise says
85+
// warning: std and std.compat modules not found!
86+
// maybe try to add --sdk=<PATH/TO/LLVM> or install libc++
87+
// error: <mcpp> missing std dependency for module mcpp.build.provisions
88+
// — a message naming a module of the project under test, so it reads as
89+
// "this project is broken" rather than "the engine was not told where
90+
// its standard library is". Every scenario in the windows/clang cell
91+
// failed that way.
92+
//
93+
// Derived from the resolved driver (…/bin/clang++), which is the same
94+
// path the toolchain pin already produced, so there is nothing to keep
95+
// in step by hand.
96+
if (const auto sdk = payload_sdk_root(job.compiler); !sdk.empty())
97+
argv.push_back("--sdk=" + sdk);
98+
6699
// ── How the payload driver is pinned, and why it is not always CXX ──
67100
//
68101
// A real project's description (bench/projects/*/xmake.lua) DEFINES the

bench/src/spec.cppm

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,15 @@ struct Job {
8888
// this module stays free of any assumption about the project being measured.
8989

9090
// Cold builds are expensive and their variance is low; incremental scenarios are
91-
// cheap and noisier, so they get more repetitions. Encoded here rather than in
92-
// the runner so the policy is visible next to the scenario it applies to.
93-
constexpr int default_runs(Scenario s) { return s == Scenario::Cold ? 3 : 5; }
91+
// cheap and noisier, so they would justify more repetitions. Encoded here rather
92+
// than in the runner so the policy is visible next to the scenario it applies to.
93+
//
94+
// THREE, not five. On a real project an "incremental" scenario is not cheap —
95+
// `edit-comment` on xlings rebuilds 45 importers, so five repetitions is five
96+
// near-full rebuilds and a windows/clang cell spent over half an hour on one
97+
// engine. The extra samples were not buying accuracy worth that: the spread
98+
// across runs on the pinned workloads is under 2%, and every published table is
99+
// a median. A matrix nobody waits for is one nobody reads.
100+
constexpr int default_runs(Scenario) { return 3; }
94101

95102
} // namespace bench

0 commit comments

Comments
 (0)