k4bench.analysis.trend¶
k4bench.analysis.trend ¶
Pure, Streamlit-free trend aggregation over benchmark run directories.
Each build_*_trend function takes the already date-windowed set of cached
run directories (see :func:k4bench.remote.fetch_runs_windowed) and returns a
long-form DataFrame keyed by run_id / x_date (nightly tag), or None
when no data could be loaded. The dashboard wraps these in @st.cache_data
(see dashboard/data.py); the nightly regression report calls them directly
from CI, which is why they must not import Streamlit.
upper_trimmed_mean ¶
Mean of times with the slowest fraction of events dropped.
A run total is a sum of per-event costs, and where that distribution is heavy-tailed a handful of events carry a disproportionate share of it. That makes the plain mean a statistic about the tail as much as about the software. Dropping the slow tail leaves a statistic about the typical event, which moves when the typical event's cost moves and not otherwise.
Deliberately a complement to the untrimmed mean, never a replacement: the same tail that destabilises the mean is where a tail-confined regression would show up first, so a detector that only watched this would be blind to exactly the most interesting kind of change.
Returns None for fewer than :data:MIN_TRIM_EVENTS events, where the
trim would drop nothing and the value would merely duplicate the mean.
Source code in k4bench/analysis/trend.py
theil_sen_slope ¶
Median of the pairwise slopes (y_j - y_i) / (x_j - x_i) over i < j.
The Theil–Sen estimator: robust to roughly 29% outlying points, where
least squares or last - first follow a single noisy sample. Pairs with
equal x carry no slope and are skipped; non-finite points are dropped.
Above :data:MAX_SLOPE_EVENTS points, the estimate is taken over
:data:MAX_SLOPE_EVENTS evenly spaced points (first and last included) in
x order, each keeping its own x. The cost is then bounded for any
input size and the result stays deterministic.
Returns None below :data:MIN_SLOPE_EVENTS finite points or when no
pair has distinct x.
Source code in k4bench/analysis/trend.py
parse_run_dir ¶
Extract run metadata from a date-level run directory.
Expected path structure::
{detector}/{platform}/{stack}/{sample}/{YYYY-MM-DD}/
Prefers run_info.json when present; falls back to inferring fields
from the directory path.
Source code in k4bench/analysis/trend.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
load_machine_info ¶
Load machine_info.json from a run directory, or return None if absent.
Source code in k4bench/analysis/trend.py
build_results_trend ¶
Load per-config results across run_dirs into one combined DataFrame.
Each row gets run_id, run_date, platform, k4h_release,
k4h_release_date, github_run_url, random_seed and x_date
columns.
Source code in k4bench/analysis/trend.py
build_region_timing_trend ¶
Load per-region timing summary across run_dirs.
For each run directory, region timing is loaded for all available configs. Per detector per config per run, the median and mean event-level time are computed (event 0 excluded as warmup).
Returns a long-form DataFrame with columns:
run_id, run_date, k4h_release_date, label, attribution, detector,
median_time_s, mean_time_s
or None if no data could be loaded. run_id lets callers join each row
with its run's reliability verdict (see k4bench.results.reliability_evidence).
Source code in k4bench/analysis/trend.py
build_event_timing_trend ¶
Load per-event timing and memory summary across run_dirs.
For each run directory, event timing is loaded for all available configs. Per config per run, summary statistics are computed (event 0 excluded): mean_time_s, median_time_s, p95_time_s, trimmed_mean_time_s, mean_rss_mb, median_rss_mb, p95_rss_mb, max_rss_mb
trimmed_mean_time_s (:func:upper_trimmed_mean) is a view of the
typical event, unmoved by how heavy this run's slow tail happened to be. It
is absent (NaN) for a config with too few events to support it.
Where the event file records anonymous RSS, rss_anon_slope_mb_per_event
is the :func:theil_sen_slope of the valid (non-negative) post-warm-up
rss_anon_end_mb samples against their event numbers, in MB/event. It
indicates memory growth across the run, which a leak or other accumulating
state can cause; it is not proof of either. It is absent (NaN) below
:data:MIN_SLOPE_EVENTS valid samples.
Returns a long-form DataFrame with those columns plus
run_id, run_date, k4h_release_date, k4h_release, label
or None if no data could be loaded. run_id lets callers join each row
with its run's reliability verdict (see k4bench.results.reliability_evidence).
Source code in k4bench/analysis/trend.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
build_machine_info_trend ¶
Load per-run machine load / memory metrics across run_dirs.
Unlike the other trend builders there is no per-config dimension: each run
directory has a single machine_info.json describing the physical machine
that executed the benchmark. One row per run captures the load average,
available RAM, swap, frequency and throttle counters, so callers can see how
the host's condition varied across nightly releases (e.g. a day where the
machine was under unusually high load).
Returns a DataFrame with one row per run plus run_id, run_date,
k4h_release_date, k4h_release and x_date columns, or None
if no machine info could be loaded. run_id lets callers join the
machine condition of a run with its per-config results (e.g. to attach a
reliability verdict to each run).