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

JIL benchmark fails due to AmbiguousMatchException #4422

Open
adamsitnik opened this issue Aug 28, 2024 · 3 comments
Open

JIL benchmark fails due to AmbiguousMatchException #4422

adamsitnik opened this issue Aug 28, 2024 · 3 comments

Comments

@adamsitnik
Copy link
Member

adamsitnik commented Aug 28, 2024

Repro:

py .\scripts\benchmarks_ci.py -f net9.0 --filter *Json_FromString<Location>.Jil*

Error msg:

 // Benchmark Process Environment Information:
 // BenchmarkDotNet v0.13.13-nightly.20240311.145
 // Runtime=.NET 9.0.0 (9.0.24.42603), X64 RyuJIT AVX2
 // GC=Concurrent Workstation
 // HardwareIntrinsics=AVX2,AES,BMI1,BMI2,FMA,LZCNT,PCLMUL,POPCNT VectorSize=256
 // Job: Job-XUBORB(PowerPlanMode=00000000-0000-0000-0000-000000000000, IterationTime=250ms, MaxIterationCount=20, MinIterationCount=15, WarmupCount=1)

 OverheadJitting  1: 1 op, 216300.00 ns, 216.3000 us/op

 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
  ---> Jil.DeserializationException: The type initializer for 'Jil.Deserialize.InlineDeserializer`1' threw an exception.
  ---> System.TypeInitializationException: The type initializer for 'Jil.Deserialize.InlineDeserializer`1' threw an exception.
  ---> System.Reflection.AmbiguousMatchException: Ambiguous match found for 'System.TimeSpan System.TimeSpan FromSeconds(Int64)'.
    at System.RuntimeType.GetMethodImplCommon(String name, Int32 genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
    at System.Type.GetMethod(String name, BindingFlags bindingAttr)
    at Jil.Deserialize.InlineDeserializer`1..cctor()
    --- End of inner exception stack trace ---
    at Jil.Deserialize.InlineDeserializer`1.AddGlobalVariables()
    at Jil.Deserialize.InlineDeserializer`1.BuildWithNew(Type forType)
    at Jil.Deserialize.InlineDeserializer`1.BuildFromStringWithNewDelegate(Int32& approximateILCount)
    at Jil.Deserialize.InlineDeserializerHelper.BuildFromString[ReturnType](Type optionsType, DateTimeFormat dateFormat, SerializationNameFormat serializationNameFormat, Exception& exceptionDuringBuild)
    at Jil.Deserialize.TypeCache`2.LoadFromString()
    at Jil.Deserialize.TypeCache`2.GetFromString()
    at Jil.JSON.GetDeserializeStringThunkDelegate[T](Options options)
    at Jil.JSON.Deserialize[T](ReadOnlySequence`1 sequence, Options options)
    --- End of inner exception stack trace ---
    at Jil.JSON.Deserialize[T](ReadOnlySequence`1 sequence, Options options)
    at Jil.JSON.Deserialize[T](String text, Options options)
    at MicroBenchmarks.Serializers.Json_FromString`1.Jil_() in D:\projects\performance\src\benchmarks\micro\Serializers\Json_FromString.cs:line 29
    at BenchmarkDotNet.Autogenerated.Runnable_0.WorkloadActionNoUnroll(Int64 invokeCount) in D:\projects\performance\artifacts\bin\MicroBenchmarks\Release\net9.0\89a12b0c-b350-4b60-b2dd-62bbe20fd793\89a12b0c-b350-4b60-b2dd-62bbe20fd793.notcs:line 317
    at BenchmarkDotNet.Engines.Engine.RunIteration(IterationData data)
    at BenchmarkDotNet.Engines.EngineFactory.Jit(Engine engine, Int32 jitIndex, Int32 invokeCount, Int32 unrollFactor)
    at BenchmarkDotNet.Engines.EngineFactory.CreateReadyToRun(EngineParameters engineParameters)
    at BenchmarkDotNet.Autogenerated.Runnable_0.Run(IHost host, String benchmarkName) in D:\projects\performance\artifacts\bin\MicroBenchmarks\Release\net9.0\89a12b0c-b350-4b60-b2dd-62bbe20fd793\89a12b0c-b350-4b60-b2dd-62bbe20fd793.notcs:line 180
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
    at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
    --- End of inner exception stack trace ---
    at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
    at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
    at BenchmarkDotNet.Autogenerated.UniqueProgramName.AfterAssemblyLoadingAttached(String[] args) in D:\projects\performance\artifacts\bin\MicroBenchmarks\Release\net9.0\89a12b0c-b350-4b60-b2dd-62bbe20fd793\89a12b0c-b350-4b60-b2dd-62bbe20fd793.notcs:line 57

@tarekgh this may be a product issue, not benchmark issue (the NuGet package got updated 3 years ago in #1891)

@tarekgh
Copy link
Member

tarekgh commented Aug 28, 2024

@adamsitnik I have no idea what you are talking about :-) do you expect any action from my side? or is it related to anything I changed in the runtime?

@adamsitnik
Copy link
Member Author

I have no idea what you are talking about

One of the benchmarks from performance repo started failing without changes in the benchmark themselves:

System.Reflection.AmbiguousMatchException: Ambiguous match found for 'System.TimeSpan System.TimeSpan FromSeconds(Int64)'.

I was wondering whether we have made any breaking change in dotnet/runtime or it's just a bug in the JIL serializer. I just wanted to get your confirmation that it's not a product (TimeSpan) bug.

@tarekgh
Copy link
Member

tarekgh commented Aug 29, 2024

@adamsitnik yes, we have added overloads in TimeSpan which takes long type parameters. Now, you need to be specific if you are passing double or long arguments.

CC @tannergooding

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