Skip to content

Benchmarks

Time and memory to build each model and hand it to the solver, in specsolve and four other libraries. Nothing is solved, and CI checks that every library builds the same model (bench/models/).

Solver Show As Axes
Libraries
click to hide
drag on a chart to zoom every chart

Reading the charts

One panel per model, one line per library. The x axis counts columns: the variables that reach the solver. Solver picks the solver for every panel and the table.

  • specsolve is the thick violet line.
  • The grey line is the matrix floor: a finished matrix handed to the solver in one call, passModel for HiGHS and loadModel for Gurobi. Its gap to specsolve is everything specsolve does before the solver holds the model. Its memory includes its own copy of the arrays.
  • A point is a median, and its whisker is the middle half of the rounds. Overlapping whiskers are a tie (why the median).
  • A shaded funnel is a projection past the 30 s or 16 GB budget. A wide funnel is a guess.
  • ÷ specsolve puts specsolve at 1×, so a line at 3× is three times slower or larger. A point outside the window is named at the edge it crosses.
  • Drag a box on any chart to zoom them all, and the table with them. A drag along one side zooms one axis. Double-click or Reset zoom to see everything.
  • The table divides by specsolve. Purple is where specsolve is faster, orange where the other library is, and grey within 10%. >30 s and >16 GB are sizes the budget refused.

The models

Columns and rows count the variables and the constraints that reach the solver, one per value that exists. Every variable and constraint also runs over snapshot, and a model grows by its snapshots alone.

dispatch network nodal sector
for bounds and one balance: the shape an array library suits best a small PyPSA model: lines, stores, solar and wind, and pooled caps dispatch at nodes, where a technology exists only where it is installed each technology delivers one of five carriers, such as heat or hydrogen
variables p[generator] p[bus, tech], f[line], charge[store], discharge[store], soc[store] p[node, tech] p[node, tech]
constraints power_balance balance[bus], soc_balance[store], pool_cap[pool] balance[node] balance[node, carrier]
grouped sums — line → bus, store → bus, bus × tech → pool — —
dimensions generator 100 bus 50, tech 12, line 100, store 50 node 50, tech 12 node 50, tech 12, carrier 5
density 100% 25% 25% 25%
snapshots 2–100k 2–25k 2–20k 2–20k
columns per snapshot 100 400 150 150
rows per snapshot 1 150 50 125
nonzeros per snapshot 100 800 150 150

From 100k columns up, linopy's peak memory stays within 1.4× of specsolve's on HiGHS, except on network, the one model that sums through a grouping. There it is 2.6× at 1M columns, 1.80 GB against 0.69 GB, and the memory budget stops linopy at that size (#2242).

A script that builds one model

The charts leave out what a script pays to start: the interpreter, the import and the first build. This table times a new process from launch to exit. The process builds the model, hands it to HiGHS and exits, without a solve.

launch to exitdispatch
10k columns
network
10k columns
nodal
3k columns
sector
3k columns
specsolve0.47 s0.53 s0.42 s0.41 s
specsolve-in-memory0.52 s · 1.1x0.55 s · 1.0x0.43 s · 1.0x0.43 s · 1.1x
linopy1.05 s · 2.3x1.26 s · 2.4x0.91 s · 2.2x0.89 s · 2.2x
pyomo0.74 s · 1.6x0.98 s · 1.9x0.61 s · 1.5x0.68 s · 1.7x

A script that builds one small model with specsolve and hands it to the solver finishes in about half a second, about half of linopy's time (#2031).

Where specsolve's build spends its time

Each table follows one model up its size ladder and splits specsolve's time into the phases its engine clocks. A phase that grows faster than the model is where a build slows down first. A phase a run did not clock reads —.

dispatch — specsolve's phases on the highs sink
phase 200 columns 1k columns 5k columns 10k columns 50k columns 100k columns 500k columns 1M columns 5M columns 10M columns
load 0.941 ms 1.11 ms 0.956 ms 0.97 ms 0.951 ms 0.923 ms 0.987 ms 1 ms 1.04 ms 0.986 ms
tidy 4.09 ms 5.14 ms 4.09 ms 4.41 ms 4.08 ms 4.15 ms 4.28 ms 4.57 ms 10.1 ms 15.5 ms
attach 0.738 ms 0.806 ms 0.723 ms 0.732 ms 0.719 ms 0.72 ms 0.805 ms 0.728 ms 0.907 ms 0.984 ms
build 6.81 ms 6.54 ms 6.59 ms 6.58 ms 8.56 ms 11.9 ms 27.6 ms 40.6 ms 153 ms 307 ms
network — specsolve's phases on the highs sink
phase 800 columns 4k columns 10k columns 50k columns 100k columns 500k columns 1M columns 5M columns 10M columns
load 1.81 ms 1.85 ms 1.76 ms 2.02 ms 2.03 ms 1.97 ms 2.01 ms 2 ms 2.02 ms
tidy 12.5 ms 12.3 ms 12.4 ms 13.6 ms 15.8 ms 32.1 ms 63.9 ms 485 ms 947 ms
attach 2.57 ms 2.3 ms 2.06 ms 2.72 ms 2.84 ms 5.67 ms 10 ms 27.9 ms 38.8 ms
build 18.9 ms 19.5 ms 20 ms 26.4 ms 34 ms 88.2 ms 152 ms 636 ms 1.3 s
nodal — specsolve's phases on the highs sink
phase 300 columns 1.5k columns 3k columns 15k columns 30k columns 150k columns 300k columns 1.5M columns 3M columns
load 0.847 ms 0.874 ms 0.911 ms 0.865 ms 1.05 ms 0.912 ms 0.897 ms 0.968 ms 0.947 ms
tidy 4.28 ms 4.15 ms 4.28 ms 4.52 ms 4.53 ms 7.28 ms 11.4 ms 59.4 ms 115 ms
attach 0.879 ms 0.88 ms 0.822 ms 0.801 ms 0.981 ms 1.44 ms 1.97 ms 6.25 ms 12 ms
build 5.93 ms 8.77 ms 7.5 ms 7.2 ms 8.36 ms 18.9 ms 21.3 ms 71.4 ms 144 ms
sector — specsolve's phases on the highs sink
phase 300 columns 1.5k columns 3k columns 15k columns 30k columns 150k columns 300k columns 1.5M columns 3M columns
load 0.994 ms 1.04 ms 1.03 ms 1.15 ms 1.08 ms 0.958 ms 0.978 ms 0.983 ms 0.986 ms
tidy 6.36 ms 5.38 ms 5.9 ms 7.01 ms 6.65 ms 18.7 ms 31.1 ms 164 ms 397 ms
attach 1.13 ms 1.22 ms 1.01 ms 1.74 ms 1.38 ms 2.76 ms 3.72 ms 19.8 ms 20.5 ms
build 8.29 ms 9.29 ms 9.84 ms 14.8 ms 18.2 ms 42.2 ms 62.2 ms 262 ms 612 ms

Not measured yet

  • Sparsity other than a quarter. nodal, network and sector are sparse at one density, a quarter of the node and technology pairs. pixi run density sweeps nodal from dense to one pair in twelve, and no published run has taken that sweep.
  • Solve time. Every number stops when the model reaches the solver.

Method

Each measurement runs in its own process, with import excluded and teardown included, on an idle machine. A point is the median of nine rounds, or of five where a round takes over a second. Peak memory is ru_maxrss. A projection's two edges carry the last measured step forward, one at its cost per column and one at its growth rate. uv run --locked bench/reproduce.py runs it again with every version pinned, and the harness has every flag and caveat, such as the allocator cost on polars' peak (#896).