1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 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
|
<!-- Copyright (c) 2025 Meta Platforms, Inc. and affiliates. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>bpfilter benchmarks</title>
<link rel="icon" type="image/x-icon" href="../../_static/favicon.ico">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script>
window.addEventListener('load', function () {
render();
})
function formatTimeDuration(value, fixed = 2, unit = null) {
const coeff = {
"ns": 1,
"μs": 1000,
"ms": 1000 * 1000,
"s": 1000 * 1000 * 1000
};
// Specific unit requested, use it
if (unit !== null) {
return {
value: value / coeff[unit],
str: parseFloat(value / coeff[unit]).toFixed(2),
unit: unit,
raw: value
};
}
// No unit requested, find the best one
if (value < 1000) {
return {
value: value,
str: parseFloat(value).toFixed(2),
unit: "ns",
raw: value
};
} else if (value < 1000000) {
return {
value: value / coeff["μs"],
str: parseFloat(value / coeff["μs"]).toFixed(2),
unit: "μs",
raw: value
};
} else if (value < 1000000000) {
return {
value: value / coeff["ms"],
str: parseFloat(value / coeff["ms"]).toFixed(2),
unit: "ms",
raw: value
};
} else {
return {
value: value / coeff["s"],
str: parseFloat(value / coeff["s"]).toFixed(2),
unit: "s",
raw: value
};
}
}
// Determine if a result is statistically significant
function isSignificant(stat) {
return Math.abs(stat.zscore) > 3;
}
function calculateBenchmarkStats(values, windowSize = 10) {
if (!values || values.length <= 2) return null;
const lastResult = values[values.length - 1]
const last10Results = values.slice(-windowSize - 1, -1);
const sum = values.reduce((a, b) => a + b, 0);
const mean = sum / values.length;
const variance = values.reduce((a, b) => a + Math.pow(b - mean, 2), 0) / values.length;
const stdDev = Math.sqrt(variance);
const min = Math.min(...values);
const max = Math.max(...values);
const zscore = (lastResult - mean) / stdDev;
return { min, max, mean, stdDev, zscore };
}
function formatData(data) {
/* Format commits as { sha, date, subject } with subject being only
* the subject of the commit, not the whole body. Store the
* formatted commits information in a map with the commit SHA as key. */
const commitsInfo = data.commits.reduce((acc, { sha, message, ...otherFields }) => {
const parts = message.split('\n\n');
const subject = parts[0].replace(/\n/g, ' ');
acc[sha] = {
sha,
subject,
...otherFields
};
return acc;
}, {});
// Use a map to preserve tests order
const benchmarks = new Map(
data.benchNames.map(name => {
return [name.replace(/\/iterations:[0-9]+$/, ''), {}];
})
);
var benchmarksResults = [];
for (var [benchmarkName, rawResults] of Object.entries(data.results)) {
benchmarkName = benchmarkName.replace(/\/iterations:[0-9]+$/, '');
const lastTime = formatTimeDuration(2);
var processedResults = [];
for (const [commitSha, commitResults] of Object.entries(rawResults)) {
processedResults.push(
{
commit: commitsInfo[commitSha],
time: commitResults.time,
nInsn: commitResults.nInsn ? commitResults.nInsn : null,
}
);
}
processedResults = processedResults.sort((a, b) => a.commit.date - b.commit.date);
benchmarksResults.push({
name: benchmarkName,
results: processedResults,
stats: {
time: calculateBenchmarkStats(processedResults.map(item => item.time)),
nInsn: calculateBenchmarkStats(processedResults.map(item => item.nInsn).filter((item) => item != null)),
},
unit: formatTimeDuration(processedResults.at(-1).time).unit,
});
}
return benchmarksResults;
}
const data = {{ DATA }};
function render() {
const formattedData = formatData(data);
for (const benchmarkResults of formattedData) {
makeTable(benchmarkResults);
makeChart(benchmarkResults);
}
}
function makeTable(benchmarkResults, name, commits, results) {
const nResults = benchmarkResults.results.length;
const lastResult = benchmarkResults.results[nResults - 1];
const lastTime = formatTimeDuration(lastResult.time);
const lastNInsn = lastResult.nInsn;
let newHtml = `<td class="text-end font-monospace">${lastTime.str} ${lastTime.unit}</td>`;
newHtml += `<td class="text-end font-monospace">${lastNInsn ? lastNInsn : "n/a"}</td>`;
let diffTimeHtml = '<td class="text-end font-monospace">n/a</td>';
let baselineTimeHtml = '<td class="text-end font-monospace">n/a</td>';
if (benchmarkResults.stats.time) {
const baselineStats = benchmarkResults.stats.time;
const baseline = formatTimeDuration(baselineStats.mean, 2, lastTime.unit);
const abs = formatTimeDuration(lastTime.raw - baseline.raw, 2, lastTime.unit);
const diff = (lastTime.raw / baseline.raw - 1) * 100;
const significant = Math.abs(baselineStats.zscore) >= 2;
const diffClass = significant ? (baselineStats.zscore > 0 ? "text-danger" : "text-success") : "text-muted";
const symbol = significant ? (baselineStats.zscore > 0 ? "⚠️" : "🥳") : false;
diffTimeHtml = `<td class="text-end font-monospace ${diffClass}">
${(diff < 0 ? "" : "+") + parseFloat(diff).toFixed(2)}%
(${abs.raw < 0 ? "" : "+"}${abs.str} ${abs.unit})
${symbol ? symbol : ""}
</td>`;
baselineTimeHtml = `<td class="text-end font-monospace">
${baseline.str} ${baseline.unit}
<small class="text-muted">(±${(baselineStats.stdDev / baselineStats.mean * 100).toFixed(1)}%)</small>
</td>`;
}
let diffInsnHtml = '<td class="text-end font-monospace">n/a</td>';
let baselineInsnHtml = '<td class="text-end font-monospace">n/a</td>';
if (benchmarkResults.stats.nInsn) {
const baselineStats = benchmarkResults.stats.nInsn;
const baseline = baselineStats.mean;
const abs = lastNInsn - baseline;
const diff = (abs / baseline) * 100;
const significant = Math.abs(baselineStats.zscore) >= 2;
const diffClass = significant ? (baselineStats.zscore > 0 ? "text-danger" : "text-success") : "text-muted";
const symbol = significant ? (baselineStats.zscore > 0 ? "⚠️" : "🥳") : false;
diffInsnHtml = `<td class="text-end font-monospace ${diffClass}">
${(diff < 0 ? "" : "+") + parseFloat(diff).toFixed(2)}%
(${(abs < 0 ? "" : "+") + parseFloat(abs).toFixed(2)})
${symbol ? symbol : ""}
</td>`;
baselineInsnHtml = `<td class="text-end font-monospace">
${baseline ? baseline.toFixed(0) : "n/a"}
${baseline ? `<small class="text-muted">(±${(baselineStats.stdDev / baselineStats.mean * 100).toFixed(1)}%)</small>` : ""}
</td>`;
}
var data = `<td><a href="#${benchmarkResults.name}" class="link-primary link-underline-opacity-0">${benchmarkResults.name}</a></td>`;
data += diffTimeHtml + diffInsnHtml;
data += newHtml;
data += baselineTimeHtml + baselineInsnHtml;
data += '</tr>';
const table = document.getElementById('table-body');
table.insertAdjacentHTML("beforeend", data);
}
function makeChart(benchmarkResults) {
const ctx = document.getElementById('charts');
const name = benchmarkResults.name;
const unit = benchmarkResults.unit;
ctx.insertAdjacentHTML("beforeend",
`<div class="col container-fluid my-3" id="${name}"><h5>${name}</h5></div>`
);
const chartCtx = document.getElementById(name);
chartCtx.insertAdjacentHTML("beforeend",
`<canvas id="${name}Chart"></canvas>`
);
var durations = []
var nInsns = []
var labels = []
for (result of benchmarkResults.results) {
durations.push(result.time);
labels.push(result.commit.sha);
if (result.nInsn)
nInsns.push(result.nInsn);
}
new Chart(document.getElementById(name + "Chart"), {
type: 'line',
data: {
labels: labels,
datasets: [
{
label: 'Duration',
data: durations,
yAxisID: 'duration',
tension: 0.1,
order: 1,
pointRadius: 0,
},
{
label: '# of instructions',
data: nInsns,
yAxisID: 'instructions',
tension: 0.1,
order: 2,
pointRadius: 0,
}
].filter(ds => ds.data.length !== 0)
},
options: {
interaction: {
intersect: false,
mode: 'index',
},
plugins: {
tooltip: {
position: "nearest",
yAlign: "top",
callbacks: {
afterTitle: (tooltipItems) => {
const result = benchmarkResults.results.find((e) => e.commit.sha == tooltipItems[0].label);
return result.commit.subject;
},
label: function (context) {
if (context.dataset.yAxisID == "duration") {
duration = formatTimeDuration(context.parsed.y, 2, unit);
return `${duration.str} ${duration.unit}`;
} else if (context.dataset.yAxisID == "instructions") {
return parseInt(context.parsed.y) + " instructions";
} else {
return context.parsed.y;
}
}
}
}
},
scales: {
duration: {
id: 't (ns)',
type: 'linear',
position: 'left',
suggestedMin: 0,
suggestedMax: Math.max(...durations) * 1.1,
title: {
display: true,
text: "Duration"
},
ticks: {
callback: function (value) {
duration = formatTimeDuration(value, 2, unit);
return `${duration.str} ${duration.unit}`;
}
}
},
instructions: {
id: '# insn',
type: 'linear',
position: 'right',
suggestedMin: 0,
suggestedMax: Math.max(...nInsns) * 1.1,
title: {
display: true,
text: '# insn'
},
// Only display the nInsns axis if we have values
display: nInsns.length != 0,
grid: {
drawOnChartArea: false, // only want the grid lines for one axis to show up
}
},
x: {
title: {
display: true,
text: 'Commit'
},
}
},
onClick: function (e) {
const sha = e.chart.tooltip.dataPoints[0].label
if (sha.endsWith("+"))
return;
window.open("https://github.com/facebook/bpfilter/commit/" + sha, "_blank");
}
}
});
}
</script>
</head>
<body>
<nav class="navbar bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<picture>
<source loading="lazy" srcset="../../_static/logo-dark-mode.png"
media="(prefers-color-scheme: dark)">
<img loading="lazy" src="../../_static/logo-light-mode.png" height="30"
class="d-inline-block align-top" alt="">
</picture>
bpfilter benchmark
</a>
</div>
</nav>
<div class="jumbotron m-5 p-5 bg-light">
<div class="container">
<h2>Summary</h2>
<p class="lead">Latest benchmark results compared to a statistical baseline from the previous 10 commits.
</p>
</div>
<table class="table">
<thead>
<tr>
<th scope="col" rowspan="2">Benchmark</th>
<th scope="col" colspan="2" class="text-end">Diff vs baseline</th>
<th scope="col" colspan="2" class="text-end">Latest result</th>
<th scope="col" colspan="2" class="text-end">10-commits baseline</th>
</tr>
<tr>
<th scope="col" class="text-end">Runtime</th>
<th scope="col" class="text-end">Instructions</th>
<th scope="col" class="text-end">Runtime</th>
<th scope="col" class="text-end">Instructions</th>
<th scope="col" class="text-end">Runtime</th>
<th scope="col" class="text-end">Instructions</th>
</tr>
</thead>
<tbody id="table-body">
</tbody>
</table>
<div class="alert alert-info mt-4">
<h5>Understanding the results:</h5>
<ul>
<li><strong>Baseline:</strong> average of the 10 previous commits (with standard deviation)</li>
<li><strong>Significant changes:</strong> if the last commit's benchmark has a standard score (zscore) above 3, compared
to the 10 previous commit average baseline, it is considered a significant change. Hence, the last commit introduced
a genuine performance shift rather than noise.</li>
<li><strong>Color coding:</strong>
<span class="text-success">Green</span> = significant improvement,
<span class="text-danger">Red</span> = significant regression,
<span class="text-muted">Gray</span> = no significant change
</li>
</ul>
</div>
</div>
<div class="jumbotron m-5 p-5 bg-light">
<div class="container">
<h2>History</h2>
<p class="lead">Benchmark results evolution over time.</p>
</div>
<div class="container-fluid">
<div class="row row-cols-2" id="charts">
</div>
</div>
</div>
</body>
</html>
|