You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split out of #146, where the profiling lives. This is the actionable piece: one clause, measured, with the open questions that stop it being a trivial diff.
The statement
executor.py::_label_frame:
INSERT INTO {table}
SELECT {collist},
{next_label} + ROW_NUMBER() OVER (ORDER BY {order_key}) -1FROM {from_clause}
WHERE t_{lead}.ord >= {lo} AND t_{lead}.ord < {hi} AND {where_clause}
The ORDER BY sorts every chunk. Isolated at 10M rows (16GB budget, best of three):
time
OVER (ORDER BY t_snapshot.ord, t_generator.ord) — current
4.03 s
OVER ()
1.66 s
ord * card + ord (arithmetic, no window)
1.62 s
no label at all — the join floor
1.41 s
What it buys, end to end
A/B interleaved in one session, best of three, memory_limit=1GB:
case
build
total
vs linopy
dispatch 10M — before
5.50 s
9.38 s
2.44x
dispatch 10M — after
3.48 s
6.97 s
1.81x
transport 9.8M — before
7.20 s
11.86 s
2.59x
transport 9.8M — after
5.44 s
10.24 s
2.24x
Peak RSS also drops (0.88 -> 0.74 GB on dispatch), which is consistent with the sort being what materialises the chunk.
Why the order is not load-bearing for correctness
Labels only have to be a dense bijection, and denseness comes from the chunk filter plus the running offset, not from the sort. What the ORDER BY fixes is which coordinate gets which index — determinism, not validity. Evidence: with the clause removed the suite is 311 passed / 1 failed, and the one failure is test_walkthrough_matches_golden, whose committed output prints primal rows in label order. Every differential and parity test against the linopy oracle passes.
Operational finding 3 already says LP section order is free.
What has to be checked before it lands
solver_direct batching.A is streamed ORDER BY row, and within a row the column indices would no longer be ascending. HiGHS's addRows does not document a sorted-index requirement, but this needs a direct test rather than an assumption — it is the shipped path.
Locality of A. Ordered labels leave the COO roughly sorted, which may help the terminal GROUP BY row, col and the solver's CSR ingestion. The measurements above are net of any such loss on the lp_file path; solver_direct is unmeasured.
The arithmetic alternative. For an unmasked frame the label is ord_lead * card_rest + ord_rest — no window at all, deterministic, and the same 1.6 s. It only works when nothing is filtered out, so it would be a fast path beside the window rather than a replacement. Worth it if determinism turns out to matter, since it keeps both properties.
The walkthrough golden would need regenerating either way; that file is asserted line for line on purpose, so the diff is the visible part of the decision.
Split out of #146, where the profiling lives. This is the actionable piece: one clause, measured, with the open questions that stop it being a trivial diff.
The statement
executor.py::_label_frame:The
ORDER BYsorts every chunk. Isolated at 10M rows (16GB budget, best of three):OVER (ORDER BY t_snapshot.ord, t_generator.ord)— currentOVER ()ord * card + ord(arithmetic, no window)What it buys, end to end
A/B interleaved in one session, best of three,
memory_limit=1GB:Peak RSS also drops (0.88 -> 0.74 GB on dispatch), which is consistent with the sort being what materialises the chunk.
Why the order is not load-bearing for correctness
Labels only have to be a dense bijection, and denseness comes from the chunk filter plus the running offset, not from the sort. What the
ORDER BYfixes is which coordinate gets which index — determinism, not validity. Evidence: with the clause removed the suite is 311 passed / 1 failed, and the one failure istest_walkthrough_matches_golden, whose committed output prints primal rows in label order. Every differential and parity test against the linopy oracle passes.Operational finding 3 already says LP section order is free.
What has to be checked before it lands
solver_directbatching.Ais streamedORDER BY row, and within a row the column indices would no longer be ascending. HiGHS'saddRowsdoes not document a sorted-index requirement, but this needs a direct test rather than an assumption — it is the shipped path.OVER ()under multiple threads gives no ordering guarantee at all.A. Ordered labels leave the COO roughly sorted, which may help the terminalGROUP BY row, coland the solver's CSR ingestion. The measurements above are net of any such loss on thelp_filepath;solver_directis unmeasured.ord_lead * card_rest + ord_rest— no window at all, deterministic, and the same 1.6 s. It only works when nothing is filtered out, so it would be a fast path beside the window rather than a replacement. Worth it if determinism turns out to matter, since it keeps both properties.The walkthrough golden would need regenerating either way; that file is asserted line for line on purpose, so the diff is the visible part of the decision.