Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(1)Output should fit inside a single term. Increase MaxTermSize? #292

Closed
jodavies opened this issue Aug 23, 2018 · 4 comments
Closed

(1)Output should fit inside a single term. Increase MaxTermSize? #292

jodavies opened this issue Aug 23, 2018 · 4 comments

Comments

@jodavies
Copy link
Collaborator

Hello,
This relates to the discussion in #289 (comment)
I have managed to extract a minimal crashing example from a larger set of codes: (rename as .frm)
test-minimal.txt

The example has two modes, inside a function argument (`#define DOINARG') or not.

Outside the function argument, everything runs OK. It also checks in each loop whether the current expression does indeed fit inside a function argument; it does.

Computing inside a function argument, however, it always crashes, however large I set MaxTermSize (10M, for eg, does not work).

For the first (commented) example input, it works for MaxTermSize values larger than 42K. With the default, (with my patches), I get the output

Sorted function argument too long: 41004 words
MaxTermSize: 40000 words
Called from execarg

which is a different error from the crashing second input term.

The code which this has been taken from has run successfully on many millions of very similar input terms. This one causes problems.

Any ideas?
Thanks,
Josh.

@jodavies
Copy link
Collaborator Author

OK, I think the issue is that if you arrive at https://github.com/vermaseren/form/blob/master/sources/sort.c#L963 the problem is not that MaxTermSize is too small, but actually you need larger SubSmallSize or SubTermsInSmall etc.

The documentation does describe subfilepatches, sublargepatches, sublargesize though, should multi-stage sorting not be working here?

Thanks,
Josh.

@vermaseren
Copy link
Owner

vermaseren commented Aug 24, 2018 via email

@jodavies
Copy link
Collaborator Author

Here is a simpler example,

#-                             
                               
#: SubTermsInSmall 12K         
#: MaxTermSize 200K              
                               
CFunction f;                   
AutoDeclare Symbol x;          
                               
Local test1 = x;               
Local test2 = f(x);            
                               
Argument f;                    
   Identify x = (x1+...+x10)^7;
EndArgument;                   
Identify x = (x1+...+x10)^7;   
                               
.end                           

which gives

Time =       0.01 sec    Generated terms =      11440
           test1         Terms in output =      11440
                         Bytes used      =     513660

Time =       0.02 sec    Generated terms =          1
           test2         Terms in output =          1
                         Bytes used      =     675000

So, test1 suggests that the result can easily fit into a single term of 200K words (800KB).

SubTermsInSmall 12K means that we never sort the sub small buffer into the sub large buffer. If this setting is commented out, (the default is 10K) then we get (1)Output should fit inside a single term. Increase MaxTermSize?

It seems something bad happens if the sub small buffer must be sorted to sub large buffer?

Thanks,
Josh.

@jodavies
Copy link
Collaborator Author

In this example, it is a par=1 EndSort with 1 (or more, if the powers in the test script are increased) large patches. We run AR.outfile = newout = AllocFileHandle(0,(char *)0); so newout->handle is -1. We go into MergePatches here:

if ( MergePatches(2) ) {

after which, newout->handle is 3, set by PutOut:
fi->handle = (WORD)RetCode;

This causes the message and termination at:

else if ( newout->handle >= 0 ) { /* output too large */

It seems that it is assumed that if PutOut created a file, then the output doesn't fit in MaxTermSize. In this example it should certainly fit, however.

jodavies added a commit to jodavies/form that referenced this issue May 9, 2024
Various buffers in AllocSort depend on the IOsize parameter. At the
main level this is >= MaxTermSize, but this was not the case when
sorting function args, dollar variables.

Fixes the examples in vermaseren#80 vermaseren#292
jodavies added a commit to jodavies/form that referenced this issue May 18, 2024
Various buffers in AllocSort depend on the IOsize parameter. At the
main level this is >= MaxTermSize, but this was not the case when
sorting function args, dollar variables.

Fixes the examples in vermaseren#80 vermaseren#292
tueda pushed a commit that referenced this issue May 21, 2024
Various buffers in AllocSort depend on the IOsize parameter. At the
main level this is >= MaxTermSize, but this was not the case when
sorting function args, dollar variables.

Fixes the examples in #80 #292
tueda pushed a commit that referenced this issue May 21, 2024
Various buffers in AllocSort depend on the IOsize parameter. At the
main level this is >= MaxTermSize, but this was not the case when
sorting function args, dollar variables.

Fixes the examples in #80 #292
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

No branches or pull requests

2 participants