Skip to content

Support CPU instruction counting - #13

Merged
paulcadman merged 7 commits into
mainfrom
cpu-instruction-count
Nov 18, 2026
Merged

paulcadman merged 7 commits into
mainfrom
cpu-instruction-count

Conversation

@paulcadman

@paulcadman paulcadman commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds support for reporting CPU instruction counts for benchmarks.

This helps when benchmarking code where heartbeats don't capture the work that the code is doing (e.g heavy GMP work). Wall-clock time also captures this, but CPU instruction count is more reliable.

Example - with the new Minstr - i.e million instruction column:

METABENCH=. example/bench-run.sh <mathlib checkout> example/Suites/Bignum.lean -Dbench.instructions=true
pow-mod/1000:
phase    kHB     min…max   ms   min…max Minstr       min…max
goal   71.30 71.15…71.41 1.27 1.18…1.33 21.274 21.201…21.299
proof   2.70   2.69…2.72 0.09 0.08…0.12  0.957   0.949…0.981
kernel  0.94   0.94…0.94 0.07 0.07…0.09  0.876   0.871…0.878
total  74.94 74.78…75.06 1.43 1.33…1.52 23.119 23.033…23.151
proof term: 71 nodes, kernel 1012 ns/node

pow-mod/10000:
phase    kHB     min…max   ms   min…max Minstr       min…max
goal   71.24 71.17…71.33 1.22 1.17…1.39 21.265 21.205…21.451
proof   2.70   2.70…2.71 0.08 0.07…0.12  1.019   1.014…1.061
kernel  0.94   0.94…0.94 0.07 0.06…0.09  0.931   0.927…0.946
total  74.89 74.83…74.98 1.38 1.31…1.60 23.215 23.147…23.409
proof term: 71 nodes, kernel 956 ns/node

pow-mod/100000:
phase    kHB     min…max   ms   min…max Minstr       min…max
goal   71.26 71.18…71.29 1.21 1.18…1.23 21.282 21.206…21.288
proof   2.70   2.69…2.71 0.15 0.15…0.17  2.658   2.652…2.670
kernel  0.94   0.94…0.94 0.14 0.14…0.15  2.575   2.569…2.585
total  74.90 74.81…74.94 1.50 1.46…1.55 26.518 26.434…26.544
proof term: 71 nodes, kernel 1977 ns/node

pow-mod/1000000:
phase    kHB     min…max   ms   min…max Minstr       min…max
goal   71.29 71.23…71.41 1.22 1.16…1.38 21.263 21.258…21.297
proof   2.72   2.71…2.74 1.48 1.42…1.54 31.944 31.941…32.094
kernel  0.94   0.94…0.94 1.47 1.42…1.62 31.863 31.848…32.645
total  74.94 74.88…75.09 4.25 4.04…4.40 85.123 85.052…85.848
proof term: 71 nodes, kernel 20723 ns/node

gcd/1000:
phase    kHB     min…max   ms   min…max Minstr       min…max
goal   91.62 91.61…91.99 1.65 1.59…1.69 28.096 28.038…28.296
proof   3.01   3.00…3.03 0.09 0.08…0.13  1.093   1.086…1.106
kernel  0.92   0.92…0.92 0.07 0.06…0.08  0.868   0.866…0.872
total  95.56 95.54…95.93 1.81 1.73…1.86 30.067 30.002…30.256
proof term: 66 nodes, kernel 1004 ns/node

gcd/10000:
phase    kHB     min…max   ms   min…max Minstr       min…max
goal   91.79 91.67…91.97 1.63 1.62…1.71 28.112 28.078…28.286
proof   3.01   3.01…3.02 0.17 0.16…0.21  2.476   2.473…2.486
kernel  0.92   0.92…0.92 0.14 0.14…0.18  2.257   2.253…2.271
total  95.72 95.60…95.89 2.01 1.92…2.08 32.870 32.816…33.021
proof term: 66 nodes, kernel 2131 ns/node

gcd/100000:
phase    kHB     min…max   ms   min…max  Minstr         min…max
goal   91.82 91.62…91.89 1.74 1.70…1.81  28.192   28.175…28.393
proof   3.03   3.01…3.03 3.02 2.99…3.09  60.777   60.771…60.826
kernel  0.92   0.92…0.92 2.96 2.94…3.06  60.569   60.555…60.580
total  95.77 95.57…95.84 7.76 7.64…7.88 149.572 149.500…149.727
proof term: 66 nodes, kernel 44855 ns/node

gcd/1000000:
phase    kHB     min…max     ms       min…max   Minstr           min…max
goal   91.66 91.60…91.70   1.91     1.88…2.05   28.225     28.125…28.567
proof   3.01   2.99…3.04  67.05   66.69…67.61 1505.298 1490.563…1523.597
kernel  0.92   0.92…0.92  66.05   65.87…66.29 1490.885 1487.030…1497.196
total  95.57 95.55…95.61 135.01 134.80…135.67 3024.322 3005.718…3044.871
proof term: 66 nodes, kernel 1000725 ns/node

@paulcadman
paulcadman force-pushed the cpu-instruction-count branch from 1c651e5 to e4931bf Compare November 17, 2026 22:53
@paulcadman
paulcadman force-pushed the cpu-instruction-count branch from ea35106 to a9a2989 Compare November 18, 2026 09:56
@paulcadman
paulcadman force-pushed the cpu-instruction-count branch from a9a2989 to 6bd075b Compare November 18, 2026 10:14
@paulcadman
paulcadman marked this pull request as ready for review November 18, 2026 10:18
@paulcadman
paulcadman merged commit 441aac6 into main Nov 18, 2026
6 checks passed
@paulcadman
paulcadman deleted the cpu-instruction-count branch November 18, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant