Skip to content

A budget stops an expansion and a linear solve over polynomials - #1746

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
an-expansion-stops-when-the-computation-is-cancelled
Oct 4, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
an-expansion-stops-when-the-computation-is-cancelled

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Part of #718.

A computation under a cancellation token -- the corpus harness's budget, or a caller's timeout -- ran on past the cancellation inside an expansion and inside the linear solve over polynomials that partial fractions makes, since neither looked at the token. On sixty of the problems that ran past the 5-second budget in the corpus run on master cb8e133d, the first sixty of families 1, 3, 4 and 6, run one after another in one process per build at that budget, each on a thread of its own and a problem that does not stop left running beside the next, under a 2 GB heap:

master 7075a747 this
stopped more than half a second after the budget 16 2
more than five seconds after it 8 0
still running a minute after it 7 0
out of memory 1 0
the whole run 733 s 282 s

The latest any of this column stopped is 6.7 s. Sampled past the cancellation on master, four of the seven that ran on for a minute were in the linear solve over polynomials, two of them, in an expansion, one, and evaluating at pinned symbols what partial fractions had built, one.

What changes. MultithreadingFunctional.ExitIfCancelled, which forty other places in the library call -- the simplifier, the polynomial GCD and factorisation, the solvers, the limits -- is called once per expansion of a product or a power, TreeAnalyzer.SmartExpandOver, and once per row of the elimination in PartialFractions.TrySolveOverPolynomials. MaxExpansionTermCount bounds the terms of one expansion, not the time the expansions of a computation take between them. With no token set the call does nothing, and no answer differs, so there is no entry in BREAKING-CHANGES.md, as there was none for #870; a caller whose token is cancelled gets the cancellation from an expansion now, as from the other steps.

Tests: ExpansionCancelTest: an expansion of (a + b + c)^5 (d + e)^3 under a token cancelled before it starts throws OperationCanceledException, and on master it completes; one that is not cancelled completes.

The suite passes on the commit measured, 93dcd0ac, 14,782 tests with 13 skipped. On the merge with master 3f744439, 14f4da3d, the multithreading tests, #1743's and the corpus gate pass, 115 of them. The allocation gate was not run here; the check is one read of an AsyncLocal per call and allocates nothing, and CI runs the gate.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Rafael-SOWNet and others added 2 commits October 4, 2026 12:23
Expand's recursion and the fraction-free elimination behind the
partial-fraction and ansatz solves check for cancellation, once a call and
once a row: a search under a budget ran on inside an elimination for nine
seconds past it, building rows nothing would read.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet Rafael-SOWNet added this to the 2.6.0 milestone Oct 4, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit f136324 into master Oct 4, 2026
34 checks passed
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