You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JitInfoIsPopulated failed with after is not greater than before #55712
System.Runtime.Tests.JitInfoTests.JitInfoIsPopulated [Details] [History] [Helix Test Artifacts]
Exception Message
CompilationTime: after not greater than before! (after: 00:00:00.0257376, before: 00:00:00.0257376)
Expected: True
Actual: False
CallStack
at System.Runtime.Tests.JitInfoTests.JitInfoIsPopulated()
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
Pass Rate
Test has failed 40 out of 958 runs (4.18%)
Failing Configuration
net6.0-iOSSimulator-Release-x64-Mono_Release-OSX.1015.Amd64.Open
Did the code run in less than 100ns? Seems unlikely that would pop up on the iOS simulator which is not our fastest configuration. So maybe a real bug?
I would expect iOS to not run this test due to the IsNotMonoAot conditional fact attribute. Is there a reason that isn't the case? Based on the behavior it looks like the same as the interpreter. Is the simulator running under the interpreter perhaps?
@steveisok What sets the MONO_AOT_MODE environment variable? I see in wasm it's set by the driver.c. I would have expected that something in eng/testing/tests.mobile.targets sets is for other configurations.
I took a look at the code. And this is my understanding. The failed check in the test is checking System.Runtime.JitInfo.GetCompilationTime(). The mono definition lives at
Function mono_jit_compile_method_inner will only be executed during JIT. It won't be executed when it is interpreter mode. Thus, for interpreter mode, the test was actually getting the original garbage value of jit_time field. That's why it doesn't change before and after compile.
Based on the error message, it seems that afterCompilationTime equals to beforeCompilationTime, which means the check PlatformDetection.IsMonoInterpreter failed. (I thought net6.0-iOSSimulator-Release-x64-Mono_Release was running with interpreter mode, too. It may running with JIT right now. @steveisok Could you please check this?)
For JIT, it seems that the jit_time was tracking compile time for the last compiled method. In that case, it seems that it took almost the same amount of time compiling the dynamic method and whatever function before that. (or the difference is at nano second level).
The MONO_ENV_OPTIONS check for --interpreter is wrong. (first it should probably just check for --interp, second I don't think we use the environment variable for the AppleAppBuilder - we set the execution mode in the host app directly)
Just to make sure I am grokking the full situation, so I don't duplicate efforts:
The iOSSimulator leg is running under the interpreter but with some jitting, hence the value we see in mono_jit_stats.jit_time.
GetIsRunningMonoInterpreter is currently implemented wrong causing this test to check with > instead of >=, hence the failure. <-- This requires a PR to fix the interp check
Steve's change will make iOSSimulator show up as an AOT mode which won't run this test at all bypassing the fialure.
The only thing left to do besides #55577 (which should close this GH issue) is to fix PlatformDetection.IsMonoInterpreter, correct?
Activity
danmoseley commentedon Jul 15, 2021
@josalem this is a new test you added. I see you special case the mono interpreter. Should the simulator also have this special case?
danmoseley commentedon Jul 15, 2021
src/libraries/System.Runtime/tests/System/Runtime/JitInfoTests.cs
21a7632#diff-b05d7e9d113484fa5e220a32499d986f133738f27ef161a664e93783e59a3afc
danmoseley commentedon Jul 15, 2021
https://github.com/dotnet/runtime/runs/3071937514
#55673
josalem commentedon Jul 15, 2021
I would expect iOS to not run this test due to the
IsNotMonoAotconditional fact attribute. Is there a reason that isn't the case? Based on the behavior it looks like the same as the interpreter. Is the simulator running under the interpreter perhaps?danmoseley commentedon Jul 15, 2021
@steveisok can answer that.
steveisok commentedon Jul 15, 2021
@fanyang-mono what are your thoughts?
lambdageek commentedon Jul 15, 2021
@steveisok What sets the
MONO_AOT_MODEenvironment variable? I see in wasm it's set by the driver.c. I would have expected that something in eng/testing/tests.mobile.targets sets is for other configurations.fanyang-mono commentedon Jul 15, 2021
I took a look at the code. And this is my understanding. The failed check in the test is checking
System.Runtime.JitInfo.GetCompilationTime(). The mono definition lives atruntime/src/mono/System.Private.CoreLib/src/System/Runtime/JitInfo.Mono.cs
Lines 33 to 36 in 21a7632
It eventually queries the
jit_timefield of structMonoJitStats, which only gets updated during JIT insidemono_jit_compile_method_innerruntime/src/mono/mono/mini/mini.c
Lines 4112 to 4116 in 41e6601
Function
mono_jit_compile_method_innerwill only be executed during JIT. It won't be executed when it is interpreter mode. Thus, for interpreter mode, the test was actually getting the original garbage value ofjit_timefield. That's why it doesn't change before and after compile.Based on the error message, it seems that
afterCompilationTimeequals tobeforeCompilationTime, which means the checkPlatformDetection.IsMonoInterpreterfailed. (I thoughtnet6.0-iOSSimulator-Release-x64-Mono_Releasewas running with interpreter mode, too. It may running with JIT right now. @steveisok Could you please check this?)For JIT, it seems that the
jit_timewas tracking compile time for the last compiled method. In that case, it seems that it took almost the same amount of time compiling the dynamic method and whatever function before that. (or the difference is at nano second level).@BrzVlad Please correct me, if I were wrong.
steveisok commentedon Jul 15, 2021
We are using interp for iOSSimulator, but with a mode that has some JIT elements to it.
runtime/eng/pipelines/runtime-staging.yml
Line 78 in 7aaffcb
I have a PR up to change iOS/tvOSSimulator to be like Catalyst, which uses AOT JustInterp.
#55577
lambdageek commentedon Jul 15, 2021
Ah ok. So
PlatformDetection.IsMonoInterpreterneeds to be changed.runtime/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
Lines 436 to 446 in 7aaffcb
This should probably just be
The
MONO_ENV_OPTIONScheck for--interpreteris wrong. (first it should probably just check for--interp, second I don't think we use the environment variable for the AppleAppBuilder - we set the execution mode in the host app directly)josalem commentedon Jul 15, 2021
Just to make sure I am grokking the full situation, so I don't duplicate efforts:
mono_jit_stats.jit_time.GetIsRunningMonoInterpreteris currently implemented wrong causing this test to check with>instead of>=, hence the failure. <-- This requires a PR to fix the interp checkThe only thing left to do besides #55577 (which should close this GH issue) is to fix
PlatformDetection.IsMonoInterpreter, correct?fanyang-mono commentedon Jul 15, 2021
I think that mono interpreter mode should be excluded from this test as well, since the fields only matter to JIT.
2 remaining items
[iOS/tvOS/MacCatalyst] Disable some of the library tests due to failu…