@@ -26,8 +26,24 @@ public:
2626 // `program` may be a bare name resolved through PATH or an absolute path to
2727 // a specific build. `label` is what appears in results; empty means "ask the
2828 // binary", which is what makes a two-version comparison self-describing.
29- explicit McppEngine (std::string program = " mcpp" , std::string label = {})
30- : program_(std::move(program)), label_(std::move(label)) {}
29+ //
30+ // `env` is how an OPT-IN BEHAVIOUR becomes a measurable engine.
31+ //
32+ // mcpp's split build schedule is `[build] bmi_schedule = "on"` in the measured
33+ // project's manifest, and it is opt-in until it has been verified on every
34+ // platform. That put the benchmark in an impossible position: the manifests
35+ // belong to the pinned workloads (one of them is someone else's project), so
36+ // the suite could not reach the single largest cold-build optimisation in
37+ // the release it was supposed to be measuring — and the table read "no
38+ // improvement on cold builds" for a change worth 2.29x.
39+ //
40+ // mcpp already exposes it as `MCPP_BMI_SCHEDULE`, so no flag had to be
41+ // invented; the harness only had to set it. Setting it per ENGINE rather
42+ // than per run is the point: both arms appear in the same report, against
43+ // the same baseline, on the same machine, in the same minute.
44+ explicit McppEngine (std::string program = " mcpp" , std::string label = {},
45+ std::map<std::string, std::string> env = {})
46+ : program_(std::move(program)), label_(std::move(label)), env_(std::move(env)) {}
3147
3248 std::string_view name () const override {
3349 if (label_.empty ()) label_ = discover_label ();
@@ -53,6 +69,13 @@ public:
5369 platform::RunResult build (const Job& job) const override {
5470 const std::vector<std::string> argv{
5571 program_, " build" , job.profile == " debug" ? " --dev" : " --release" };
72+ // Scoped, so the setting reaches THIS engine's child and is restored
73+ // before the next engine runs. A run that leaked it would silently
74+ // measure every later arm with the option on.
75+ std::vector<std::unique_ptr<platform::ScopedEnv>> scoped;
76+ scoped.reserve (env_.size ());
77+ for (const auto & [k, v] : env_)
78+ scoped.push_back (std::make_unique<platform::ScopedEnv>(k, v));
5679 return platform::run (argv, job.project_dir , job.log_path , job.timeout_s );
5780 }
5881
@@ -65,8 +88,9 @@ public:
6588 }
6689
6790private:
68- std::string program_;
69- mutable std::string label_;
91+ std::string program_;
92+ mutable std::string label_;
93+ std::map<std::string, std::string> env_;
7094
7195 // `mcpp --version` prints "mcpp <version>". Empty means the binary could not
7296 // be run at all — which probe() reports as unavailable rather than failed.
@@ -84,15 +108,30 @@ private:
84108 if (v.empty ()) return " mcpp" ;
85109 const auto sp = v.rfind (' ' );
86110 if (sp == std::string::npos) return " mcpp" ;
87- // "mcpp@2026.8.12 .1" — distinct per version, so two binaries never
111+ // "mcpp@2026.8.13 .1" — distinct per version, so two binaries never
88112 // collapse into one row of the result table.
89- return std::format (" mcpp@{}" , v.substr (sp + 1 ));
113+ //
114+ // The env suffix is part of the identity for the same reason: the SAME
115+ // binary with `schedule=on` is a different engine to measure, and two
116+ // rows called `mcpp@2026.8.13.1` would be unreadable.
117+ std::string out = std::format (" mcpp@{}" , v.substr (sp + 1 ));
118+ for (const auto & [k, val] : env_) {
119+ std::string key = k;
120+ // `MCPP_BMI_SCHEDULE` -> `schedule`: the label is read by people.
121+ if (key.starts_with (" MCPP_" )) key.erase (0 , 5 );
122+ if (key.ends_with (" _SCHEDULE" ) || key == " BMI_SCHEDULE" ) key = " schedule" ;
123+ for (char & c : key) c = static_cast <char >(std::tolower (c));
124+ out += std::format (" +{}={}" , key, val);
125+ }
126+ return out;
90127 }
91128};
92129
93130export std::unique_ptr<Engine> make_mcpp (std::string program = " mcpp" ,
94- std::string label = {}) {
95- return std::make_unique<McppEngine>(std::move (program), std::move (label));
131+ std::string label = {},
132+ std::map<std::string, std::string> env = {}) {
133+ return std::make_unique<McppEngine>(std::move (program), std::move (label),
134+ std::move (env));
96135}
97136
98137} // namespace bench::engines
0 commit comments