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

.NET7.0 AOT for clients and services? #1695

Closed
jefflill opened this issue Sep 22, 2022 · 3 comments
Closed

.NET7.0 AOT for clients and services? #1695

jefflill opened this issue Sep 22, 2022 · 3 comments
Labels
investigate Needs further investigation neon-kube Related to our Kubernetes distribution

Comments

@jefflill
Copy link
Collaborator

Investigate new .NET7.0 AOT capabilities:

https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/

@jefflill jefflill added investigate Needs further investigation neon-kube Related to our Kubernetes distribution labels Sep 22, 2022
@marcusbooyah
Copy link
Member

[System.TypeInitializationException]: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property. [inner:System.TypeInitializationException: A type initializer threw an exception. To determine which typ2022-09-26T23:23:36.585336762Z e, inspect the InnerException's StackTrace property.]: stacktrace:    at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x153
   at System.Runtime.CompilerServices.ClassConstructorRunner.2022-09-26T23:23:36.585420363Z CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0x9
   at OpenTelemetry.Logs.OpenTelemetryLoggerProvider..ctor(IOptionsMonitor`1 options) + 0x14
   at bowyer-photo!<BaseAddress>+0x4974f6f
   at System.Reflection2022-09-26T23:23:36.585669214Z .DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x173
   at Internal.Reflection.Execution.MethodInvokers.InstanceMethodInvoker.Invoke(Object, Object[], BinderBundle, Boolean) + 0x4f
   at Internal.Reflection.Core.Execution.Meth2022-09-26T23:23:36.585737171Z odInvoker.Invoke(Object, Object[], Binder, BindingFlags, CultureInfo) + 0x47
   at System.Reflection.Runtime.MethodInfos.RuntimePlainConstructorInfo`1.Invoke(BindingFlags, Binder, Object[], CultureInfo) + 0x96
   at Microsoft.Extensions.DependencyInjection2022-09-26T23:23:36.585823202Z .ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite, RuntimeResolverContext) + 0x78
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument) + 0xcc
   at Mi2022-09-26T23:23:36.586306804Z crosoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite, RuntimeResolverContext) + 0x65
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCal2022-09-26T23:23:36.586424152Z lSite, RuntimeResolverContext) + 0x78
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument) + 0xcc
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRun2022-09-26T23:23:36.586509285Z timeResolver.VisitConstructor(ConstructorCallSite, RuntimeResolverContext) + 0x83
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite, RuntimeResolverContext) + 0x78
   at Microsoft.Extensions2022-09-26T23:23:36.586636623Z .DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument) + 0xcc
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite, ServiceProviderEngineScope2022-09-26T23:23:36.586703429Z ) + 0x1e
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType) + 0xe5
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) + 0x8d
   at Microsoft.Extensions.Depe2022-09-26T23:23:36.586860436Z ndencyInjection.ServiceProvider.GetService(Type, ServiceProviderEngineScope) + 0x33
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) + 0x51
   at Microsoft.Exten2022-09-26T23:23:36.587059753Z sions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) + 0x2f
   at Microsoft.Extensions.Logging.LoggerFactory.Create(Action`1) + 0x79
   at Neon.Service.NeonService..ctor(String name, String version, Ne2022-09-26T23:23:36.587496233Z onServiceOptions options) + 0x975
[System.TypeInitializationException]: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property. [inner:System.TypeInitializationException: A type initializer threw an exception. To determine which typ2022-09-26T23:23:36.592535147Z e, inspect the InnerException's StackTrace property.]

@marcusbooyah
Copy link
Member

@jefflill
Copy link
Collaborator Author

jefflill commented Nov 9, 2022

So AOT will probably wok fine by itself here, just don't do trimming (also because it's too freaking slow) and after a very quick look, it appears that single-file isn't compatible with reflection (I could easily be wrong about this).

I'm not entirely sure that AOT is really that important for the services. On one hand, it'll make app startup a bit faster because we'd avoid JIT, on the other hand, the generated binaries would be roughly twice the size as IL binaries.

I'm going to close this.

@jefflill jefflill closed this as completed Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Needs further investigation neon-kube Related to our Kubernetes distribution
Projects
None yet
Development

No branches or pull requests

2 participants