Skip to content

Remove a failing unnecessary test#53342

Merged
danmoseley merged 1 commit intodotnet:mainfrom
jakobbotsch:jit-stack-overflow-on-deep-trees
May 27, 2021
Merged

Remove a failing unnecessary test#53342
danmoseley merged 1 commit intodotnet:mainfrom
jakobbotsch:jit-stack-overflow-on-deep-trees

Conversation

@jakobbotsch
Copy link
Member

The manually assigned 128 KiB stack here is bordering on the amount of
stack space that release JIT needs to JIT functions with deep trees.
Since the JIT already has a limit on the depth of trees it creates

/* We need to restrict the max tree depth as many of the Compiler
functions are recursive. We do this by spilling the stack */
if (verCurrentState.esStackDepth)
{
/* Has it been a while since we last saw a non-empty stack (which
guarantees that the tree depth isnt accumulating. */
if ((opcodeOffs - lastSpillOffs) > MAX_TREE_SIZE && impCanSpillNow(prevOpcode))
{
impSpillStackEnsure();
lastSpillOffs = opcodeOffs;
}
}
else
{
lastSpillOffs = opcodeOffs;
impBoxTempInUse = false; // nothing on the stack, box temp OK to use again
}

it seems unnecessary to pessimize the JIT further to allow this test to
pass. Also, the test was originally added as a
faster equivalent to the test above it that could run in inner loop
(dotnet/corefx#14444), but it was subsequently
moved to outer loop (dotnet/corefx#19563), so
now it does not seem like there's much point in retaining it.

Fix #53309

The manually assigned 128 KiB stack here is bordering on the amount of
stack space that release JIT needs to JIT functions with deep trees.
Since the JIT already has a limit on the depth of trees it creates

https://github.com/dotnet/runtime/blob/44f050acc0f7791d6cd7ac772945444912bcf299/src/coreclr/jit/importer.cpp#L11234-L11252

it seems unnecessary to pressimize the JIT further to allow this test to
pass. Also, the test was originally added as a
faster equivalent to the test above it that could run in inner loop
(dotnet/corefx#14444), but it was subsequently
moved to outer loop (dotnet/corefx#19563), so
now it does not seem like there's much point in retaining it.

Fix dotnet#53309
@jakobbotsch
Copy link
Member Author

Some more information in #53309 (comment).

@danmoseley
Copy link
Member

Is this testing something we support customers doing?

@jakobbotsch
Copy link
Member Author

Not sure, but there is already another outer loop test for this scenario above it:

[Theory]
[ClassData(typeof(CompilationTypes))]
[OuterLoop("Takes over a minute to complete")]
public static void CompileDeepTree_NoStackOverflow(bool useInterpreter)
{
var e = (Expression)Expression.Constant(0);
int n = 10000;
for (var i = 0; i < n; i++)
e = Expression.Add(e, Expression.Constant(1));
Func<int> f = Expression.Lambda<Func<int>>(e).Compile(useInterpreter);
Assert.Equal(n, f());
}

@danmoseley danmoseley merged commit 62712ec into dotnet:main May 27, 2021
@jakobbotsch jakobbotsch deleted the jit-stack-overflow-on-deep-trees branch May 27, 2021 20:22
@ghost ghost locked as resolved and limited conversation to collaborators Jun 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Linq.Expressions CompileDeepTree_NoStackOverflowFast fails with Stack Overflow

2 participants