fix: function and arg size book-keeping for TestSub recursion#874
fix: function and arg size book-keeping for TestSub recursion#874jodavies wants to merge 2 commits into
Conversation
|
Tentatively, this is also a 1% performance improvement in forcer, forcer-exp and maybe hyperform. |
When TestSub is called recursively, correctly update the nested sizes. Rely on the recursion to fix the sizes at each level, except when an argument term disappears completely; then we fix up the whole nesting stack and continue processing further argument terms. This fix was prepared with the help of an LLM report: https://gist.github.com/tueda/9d71a87e04dcc1f51fbbb432ae1af903 Its findings are in line with previous debugging efforts by me, but I did not figure out a proper fix at the time. In addition: - add a check that we do not exceed the FunctionLevels setup parameter, and give an error message for the user if so. - check RecFlag has the same value on entry and when returning from TestSub
|
While this fixes many examples, I think it the code is still not correct, but for slightly independent reasons. @cbmarini has been also looking at an issue with this same code: Here the issue is the in-place call of Line 1660 in b143fc2 In this case, Normalize makes the term larger after raising 100000 to the fifth power: thus Normalize blindly over-writes the trailing term information. We need to either, copy the term to the workspace and normalize there, and then copy back taking care of the size changes, or not Normalize at all at let the later Normalize during sorting deal with the terms. Then one has to instead make sure that terms which go to 0 are still handled correctly in the Nest stack book-keeping (which was why the Normalize was introduced in the first place). |
If Normalize produces a larger result, trailing term data is overwritten.
|
The second commit resolves the problem by not calling Normalize at all, during the recursion, but relying on the Normalization just before the following sort. The Nest stack is updated entirely by the recursive calls. I am not sure if it is guaranteed that TestSub never increases the size of the term, this does not happen in the test suite at least. The commit adds a Terminate in this case. As far as I can tell, the code has now come "full circle" back to 2003, except that "subsubveto" is still there? Any thoughts on this? |
When TestSub is called recursively, correctly update the nested sizes. Rely on the recursion to fix the sizes at each level, except when an argument term disappears completely; then we fix up the whole nesting stack and continue processing further argument terms.
This fix was prepared with the help of an LLM report: https://gist.github.com/tueda/9d71a87e04dcc1f51fbbb432ae1af903
Its findings are in line with previous debugging efforts by me, but I did not figure out a proper fix at the time.
In addition:
This fixes #367 and #741