|
| 1 | +/* |
| 2 | + This file is part of libhttpserver |
| 3 | + Copyright (C) 2011-2026 Sebastiano Merlino |
| 4 | +
|
| 5 | + This library is free software; you can redistribute it and/or |
| 6 | + modify it under the terms of the GNU Lesser General Public |
| 7 | + License as published by the Free Software Foundation; either |
| 8 | + version 2.1 of the License, or (at your option) any later version. |
| 9 | +
|
| 10 | + This library is distributed in the hope that it will be useful, |
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | + Lesser General Public License for more details. |
| 14 | +
|
| 15 | + You should have received a copy of the GNU Lesser General Public |
| 16 | + License along with this library; if not, write to the Free Software |
| 17 | + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 18 | + USA |
| 19 | +*/ |
| 20 | +// TASK-083: per-platform warm-path baselines for bench_warm_path.cpp. |
| 21 | +// |
| 22 | +// bench_warm_path measures six per-request hot-path operations (see the |
| 23 | +// file header in bench_warm_path.cpp). Each measurement now carries a |
| 24 | +// pass/fail gate: a median that regresses more than kAllowedRegressionRatio |
| 25 | +// over the platform baseline below fails the bench (rc=1). This is the |
| 26 | +// ">= 5% improvement vs baseline" acceptance from TASK-058, hardened by |
| 27 | +// TASK-083 into a real CI gate (the spec phrases it as fail-on-regression: |
| 28 | +// the warm path must not get >5% slower than the committed numbers). |
| 29 | +// |
| 30 | +// HOW TO REFRESH (owned by TASK-084): |
| 31 | +// These are absolute ns/call medians captured once on a quiet reference |
| 32 | +// host, NOT recomputed at build time. When the CI runner hardware |
| 33 | +// changes, re-measure with `make bench` (release build, no sanitizers, |
| 34 | +// machine otherwise idle), take the bench_warm_path medians, pad by |
| 35 | +// ~25% to absorb runner jitter, and update the matching platform arm |
| 36 | +// below. TASK-084 explicitly owns the refresh cadence; see its task |
| 37 | +// body and test/PERFORMANCE.md for the procedure. |
| 38 | +// |
| 39 | +// Reference environment for the __APPLE__ arm: |
| 40 | +// * host triple : aarch64-apple-darwin25.x (Apple silicon) |
| 41 | +// * compiler : Apple clang 21.x |
| 42 | +// * C++ stdlib : libc++ (LLVM) |
| 43 | +// * build profile : -std=c++20 -O3 (release; no sanitizers) |
| 44 | +// |
| 45 | +// The Linux/libstdc++ and MSVC arms carry conservative placeholder values |
| 46 | +// (TODO(TASK-084)) until they are re-measured on their respective CI |
| 47 | +// runners. They are set deliberately loose so the gate never produces a |
| 48 | +// false failure before TASK-084 calibrates them; they are NOT a tight |
| 49 | +// regression bound on those platforms yet. |
| 50 | + |
| 51 | +#ifndef TEST_BENCH_BASELINE_HPP_ |
| 52 | +#define TEST_BENCH_BASELINE_HPP_ |
| 53 | + |
| 54 | +namespace httpserver::bench_baseline { |
| 55 | + |
| 56 | +#if defined(__APPLE__) |
| 57 | +// Apple-silicon reference medians (padded ~25% over observed values). |
| 58 | +// Observed on the maintainer host: 12.7 / 102.7 / 1.24 / 30.2 / 517 / 505. |
| 59 | +inline constexpr double WARM_CANONICALIZE_NS = 16.0; |
| 60 | +inline constexpr double WARM_SHOULD_SKIP_AUTH_NONEMPTY_NS = 130.0; |
| 61 | +inline constexpr double WARM_SHOULD_SKIP_AUTH_EMPTY_NS = 2.0; |
| 62 | +inline constexpr double WARM_SERIALIZE_ALLOW_405_NS = 40.0; |
| 63 | +inline constexpr double WARM_BUILD_REQUEST_ARGS_PCT2F_NS = 650.0; |
| 64 | +inline constexpr double WARM_BUILD_REQUEST_ARGS_PLAIN_NS = 640.0; |
| 65 | +#elif defined(__linux__) && defined(__GLIBCXX__) |
| 66 | +// libstdc++ on Linux. TODO(TASK-084): re-measure on the verify-build.yml |
| 67 | +// runner and tighten. Placeholders are ~3x the apple-silicon medians so |
| 68 | +// the gate cannot false-fail before calibration. |
| 69 | +inline constexpr double WARM_CANONICALIZE_NS = 48.0; |
| 70 | +inline constexpr double WARM_SHOULD_SKIP_AUTH_NONEMPTY_NS = 390.0; |
| 71 | +inline constexpr double WARM_SHOULD_SKIP_AUTH_EMPTY_NS = 6.0; |
| 72 | +inline constexpr double WARM_SERIALIZE_ALLOW_405_NS = 120.0; |
| 73 | +inline constexpr double WARM_BUILD_REQUEST_ARGS_PCT2F_NS = 1950.0; |
| 74 | +inline constexpr double WARM_BUILD_REQUEST_ARGS_PLAIN_NS = 1920.0; |
| 75 | +#elif defined(_WIN32) |
| 76 | +// MSVC STL. TODO(TASK-084): re-measure on a Windows runner and tighten. |
| 77 | +// Placeholders mirror the Linux conservative arm. |
| 78 | +inline constexpr double WARM_CANONICALIZE_NS = 48.0; |
| 79 | +inline constexpr double WARM_SHOULD_SKIP_AUTH_NONEMPTY_NS = 390.0; |
| 80 | +inline constexpr double WARM_SHOULD_SKIP_AUTH_EMPTY_NS = 6.0; |
| 81 | +inline constexpr double WARM_SERIALIZE_ALLOW_405_NS = 120.0; |
| 82 | +inline constexpr double WARM_BUILD_REQUEST_ARGS_PCT2F_NS = 1950.0; |
| 83 | +inline constexpr double WARM_BUILD_REQUEST_ARGS_PLAIN_NS = 1920.0; |
| 84 | +#else |
| 85 | +#error "bench_baseline.hpp: no warm-path baseline for this platform; re-measure with `make bench` and add an arm (see TASK-084)." |
| 86 | +#endif |
| 87 | + |
| 88 | +// Allowed regression before the bench fails: a median may be up to 5% |
| 89 | +// slower than the committed baseline. The bench fails when |
| 90 | +// measured > baseline * kAllowedRegressionRatio. |
| 91 | +// 5% per TASK-058 acceptance / TASK-083 spec. |
| 92 | +inline constexpr double kAllowedRegressionRatio = 1.05; |
| 93 | + |
| 94 | +} // namespace httpserver::bench_baseline |
| 95 | + |
| 96 | +#endif // TEST_BENCH_BASELINE_HPP_ |
0 commit comments