Add timelimit to capture with alarm
- Dominant language
- Macaulay2
- Stars
- 435
- Forks
- 297
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 11
Description
I noticed two recent Github Actions builds, one on [autotools](https://github.com/Macaulay2/M2/runs/3983374880?check_suite_focus=true#step:13:2950) and one on [cmake](https://github.com/Macaulay2/M2/runs/3967515919?check_suite_focus=true#step:12:2966), timed out, so I checked to see what was taking so long and realized they both timed out in the same place.
Autotools:
```m2
2021-10-23T11:35:52.7082987Z /home/runner/work/M2/M2/M2/BUILD/build/usr-dist/x86_64-Linux-Ubuntu-20.04/bin/M2 -q --no-preload --stop --silent -e "needsPackage(\"QthPower\",LoadDocumentation=>true,DebuggingMode=>true); check(QthPower,UserMode=>false,Verbose=>true); exit 0"
2021-10-23T11:35:53.7707867Z -- capturing check(0, "QthPower") -- 0.789007 seconds elapsed
2021-10-23T11:35:55.9064619Z -- capturing check(1, "QthPower") -- 2.13563 seconds elapsed
2021-10-23T11:35:56.4230467Z -- capturing check(2, "QthPower") -- 0.516635 seconds elapsed
2021-10-23T15:00:41.6211725Z ##[error]The operation was canceled.
```
CMake:
```m2
2021-10-21T21:19:08.6832331Z QthPower
2021-10-21T21:19:08.6832767Z ********
2021-10-21T21:19:10.2952726Z -- capturing check(0, "QthPower") -- 1.20264 seconds elapsed
2021-10-21T21:19:13.4542449Z -- capturing check(1, "QthPower") -- 3.15898 seconds elapsed
2021-10-21T21:19:14.2212433Z -- capturing check(2, "QthPower") -- 0.766953 seconds elapsed
2021-10-22T00:14:24.2923177Z ##[error]The operation was canceled.
```
Notice the time jump in both cases, indicating that for the most part nothing else is slowed down, but that this fourth test is never finished or killed. The test itself takes about 16s on my machine and doesn't seem to unusual:
```m2
i12 : code (tests("QthPower"))#3
o12 = --/home/linuxbrew/.linuxbrew/share/Macaulay2/QthPower.m2:1254: location of test code
------------------------------------------------------------------------------
--generic example over QQ with moderate coefficients to be reconstructed------
------------------------------------------------------------------------------
wtR4 = matrix{{11,6}};
R0 = QQ[y,x,MonomialOrder=>{Weights=>{11,6},Weights=>{1,0}}];
GB = {(y^2-3/4*y-15/17*x)^3-9*y*x^4*(y^2-3/4*y-15/17*x)-27*x^11};
time ic0 = rationalIntegralClosure(wtR4,R0,GB); toString(ic0)
assert(ic0#3 == matrix{{25,21,20,11,10,6}})
```
Perhaps in order to finish quickly it needs more memory than is available on Github's machines.
I don't think the solution should be to not use `capture`, but that the M2 command that runs capture should be time limited by a generous amount. It would also be good to time limit `capture`, perhaps using `alarm` and a new thread.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the implementation of capture and the M2 command that invokes it; reproduce the QthPower check shown in the GitHub Actions autotools or CMake build. Review the proposed alarm and new-thread approach for enforcing a generous timeout. Done means a hung capture is terminated while normal checks still complete within the limit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, github-actions
- Domain
- build-system, ci-cd, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100