Try using socket syscalls that accepts a single buffer to improve performance by tmds · Pull Request #36371 · dotnet/runtime (original) (raw)

Co-authored-by: Alexander Köplinger alex.koeplinger@outlook.com

Co-authored-by: Alexander Köplinger alex.koeplinger@outlook.com

Large-bubble composite images are special in having more entries in the manifest metadata than in the component assembly table: When the build starts, all component assemblies get hard-injected into the manifest metadata and subsequently we lazily add those additional reference assemblies (within the same version bubble) as we need for encoding signatures.

Thanks

Tomas

It's no longer used.

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

This test is optimization sensitive, but it invokes a subprocess that will inherit environment variables like COMPlus_JITMinOpts that can impact optimization of code jitted in the subprocess and cause the test to fail.

So, update the parent process code to override COMPlus_JITMinOpts and COMPlus_JitStress for the child process.

Closes #35742.

  /Users/alexander/dev/runtime/src/mono/mono/mini/aot-runtime.c:5647:13: warning: unused variable 'image' [-Wunused-variable]

  /Users/alexander/dev/runtime/src/mono/mono/mini/simd-intrinsics-netcore.c:11:1: warning: no previous prototype for function 'mono_simd_intrinsics_init' [-Wmissing-prototypes]

  /Users/alexander/dev/runtime/src/mono/mono/utils/mono-state.c:1230:1: warning: no previous prototype for function 'mono_crash_save_failfast_msg' [-Wmissing-prototypes]
  /Users/alexander/dev/runtime/src/mono/mono/utils/mono-state.c:1236:1: warning: no previous prototype for function 'mono_crash_get_failfast_msg' [-Wmissing-prototypes]

Removing some asserts and returning err_invalid_argument with an error message when it's possible.

Fixes https://github.com/mono/mono/issues/19651

Co-authored-by: thaystg thaystg@users.noreply.github.com

See https://github.com/mono/mono/issues/19393.

We can use the -Werror=partial-availability as a good alternative until the Xcode bug is fixed.

Consolidating subset projects into a single ProjectToBuild item type to allow specifying projects to build from different subsets after the subset was already built.

Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.ApiCompat , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk , Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.GenAPI , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.GenFacades From Version 5.0.0-beta.20258.8 -> To Version 5.0.0-beta.20261.9

Microsoft.NET.ILLink.Tasks From Version 5.0.0-preview.3.20262.1 -> To Version 5.0.0-preview.3.20264.1

Microsoft.DotNet.XHarness.Tests.Runners From Version 1.0.0-prerelease.20263.4 -> To Version 1.0.0-prerelease.20264.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

Expand the name/OID table to support a m:m relationship (secp256r1 and nistP256 are both 1.2.840.10045.3.1.7; 1.3.14.7.2.3.1 and 1.2.840.113549.1.1.4 are both md5RSA) and add in the alternative names for the secp{size}r1 curves (size in 256, 384, 521).

This works around Ubuntu's apparent lack of NO_ATEXIT support in their build of OpenSSL.

Fixes https://github.com/dotnet/runtime/issues/36255

Depprojs depend on IntermediateOutputPath being set in a props file early enough as restore is happening per configuration. Even though it isn't recommended that the TargetFramework property is read before the project is loaded, we currently encode the TargetFramework in the IntermediateOutputPath for depproj files. The long-term fix is to get rid of per configuration restores by getting rid of our depproj files.

We would like to know the MonoNativeThreadId (pthread_t on Linux) of the main thread of the application. We can identify the main thread (on linux) because it is the one for which gettid () == getpid (). (gettid() returns a pid_t which is not the same thing as a pthread_t, hence this roundabout way of detecting it.)

A complication arises in embedding scenarios: the main thread is not necessarily the one that calls mono_jit_init or otherwise interacts with the runtime. Therefore we do the gettid() == getpid () test at MonoThreadInfo creation time when we call register_thread.

If the main thread never interacts with Mono, the main thread is not known to us.

Setting the name of the main thread also changes the name of the process.

Fixes https://github.com/dotnet/runtime/issues/35908

The corresponding fix for CoreCLR is https://github.com/dotnet/runtime/pull/34064

During my work on fixing runtime crashes in composite build with large version bubble enabled I noticed room for startup perf improvement and a very slight working set optimization:

For component assemblies of a composite image, we can basically share the cache of those manifest assembly references that have already been resolved (GetNativeMetadataAssemblyRefFromCache) within the native image because that is the logical owner of the manifest metadata.

In the "asymptotic" case of composite images with many components, the pre-existing behavior was basically a quadratic O(n^2) algorithm in the number of component assemblies. This change reduces it to linear in the sense that all assembly references from the composite image get resolved only once.

Thanks

Tomas

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Stephen Toub stoub@microsoft.com

Allow compiling composite R2R images which reference assemblies not in the composite. For example, this would allow compiling a set of application assemblies with references to ASP.NET / Framework. Currently R2RTest treats all references as unrooted inputs for the composite image.

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Eirik Tsarpalis eirik.tsarpalis@gmail.com Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Alexander Chermyanin flamencist@mail.ru

Co-authored-by: Alexander Chermyanin flamencist@mail.ru

They were used in asserts only, no changes.

Used to make some new methods const as well.

Delete an unnecessary nested condition and make checks more straightforward.

This includes a couple of fixes in xharness.

Moving the projects will make sure their artifacts are always available to the different CI legs.

Microsoft.NET.ILLink.Tasks From Version 5.0.0-preview.3.20264.1 -> To Version 5.0.0-preview.3.20265.1

Microsoft.NET.Test.Sdk From Version 16.7.0-preview-20200429-01 -> To Version 16.7.0-preview-20200515-01

Microsoft.DotNet.XHarness.Tests.Runners From Version 1.0.0-prerelease.20264.9 -> To Version 1.0.0-prerelease.20265.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Viktor Hofer viktor.hofer@microsoft.com

This is a zero-diff set of mostly refactoring changes in preparation for supporting multireg locals:

We need to dispose of the linked token source we create.

Also cleaned up some unnecessarily complicated code nearby.

My previous changes here were flawed for the sync-completing case, and also accidentally introduced a closure.

Rather than creating temporary linked token sources with the request body source and the supplied cancellation token, we can instead just register with the supplied token to cancel the request body source. This is valid because canceling any part of sending a request cancels any further sending of that request, not just that one constituent operation.

We can avoid registering with the cancellation token until after we know that our send is completing asynchronously.

this was being closed over accidentally. I can't wait for static lambdas.

Since it only exists to be defensive but we don't expect response.TrailingHeaders to be accessed until after the whole response has been received, we can store the headers into an HttpResponseHeaders instance and swap that instance in at the end. Best and common case, we avoid the list. Worst and uncommon case, we pay the overhead of the extra HttpResponseHeaders instead of the List.

Minor optimizations to improve the asm

Makes a significant impact on reducing lock contention.

Including moving credit adjustment out of the lock

Remove it from within the lock

IHttpTrace doesn't need to be prioritized.

The System.Net.* libs in dotnet/runtime inherited this from .NET Framework. To my knowledge it's not once helped flag any issues in dotnet/runtime, it's only built into debug builds, it's become very inconsistent as the code base has evolved, and it's just cluttering stuff up. So, goodbye.

This is part of the work to create an apphost that bundles both hostfxr and hostpolicy. The main distinction between the static and shared versions of hostfxr is that the static version contains a hostpolicy resolver that references the hostpolicy symbols directly rather than loading them from a DLL.

This change is part of the work to enable an apphost that bundles both hostfxr and hostpolicy. There's no distinction between hostpolicy that's built as a shared library and as a static library: the shared library is built by linking an empty object file with the static library.

Provide a hostfxr_iface class, that abstracts how the hostfxr functions called by the early stage in the hosting layer is resolved.

This provides two implementations of hostfxr_iface: one for the static apphost, which bundles hostfxr and hostpolicy, and another for the conventional apphost, which loads them dynamically on startup.

Co-authored-by: Leandro Pereira leandro.pereira@microsoft.com Co-authored-by: Swaroop Sridhar swaroop.sridhar@microsoft.com

Disable optimization/inlining on methods that are expected to remain on the stack.

We share interp_in wrappers for different types of signatures if the corresponding params are equivalent. This was added in https://github.com/mono/mono/commit/5cbe93884798684efbb81abd79e0e2a170544b75. This was reusing some sharing mechanism used by gsharedvt. Those wrappers are shared with regard to managed->managed transitions so it takes additional freedoms, converting all valuetypes to ValueTuples instances. These can end up being marshalled differently from the initial struct so we can't use this valuetype sharing infrastructure in the interp_in_wrappers which can operate on native structs.

Fixes test_0_marshal_struct_delegate from pinvoke3.cs

Co-authored-by: BrzVlad BrzVlad@users.noreply.github.com

Microsoft.NET.ILLink.Tasks From Version 5.0.0-preview.3.20265.1 -> To Version 5.0.0-preview.3.20265.2

Microsoft.NET.Test.Sdk From Version 16.7.0-preview-20200515-01 -> To Version 16.7.0-preview-20200515-03

Microsoft.DotNet.XHarness.Tests.Runners From Version 1.0.0-prerelease.20265.1 -> To Version 1.0.0-prerelease.20265.8

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

Change mono interpreter runs to be a scenario instead of a seperate leg. Also enable arm64 interpreter runs, and add test exclusions.

This change implements:

Fixes #32822

Needed for the iOS Simulator for 32bit iOS devices.

We initially intended to just use libmono.so/dylib as the name to simplify and follow the libcoreclr.dylib pattern and we did that by just copying to a different name after the build.

However that didn't work on Android since the name gets embedded inside the binary and Android checks that these match, so we'd either have to change the (auto)make to use the correct library name (and possibly creates complex conditionals in the Makefile for netcore) or go back to using libmonosgen-2.0 on iOS.

We decided to do the latter.

Linking statically ICU shim on mono for windows, linux, macOs and android.

Microsoft.NET.ILLink.Tasks From Version 5.0.0-preview.3.20265.2 -> To Version 5.0.0-preview.3.20268.2

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

The optimization removes the O(n log n) cost of the OrderBy. But it can result in executing the predicate passed to First{OrDefault} more than in .NET Framework; it would always execute it n times, whereas previously it would execute it <= n times. Developers have expressed concern about the change, in particular when using a relatively expensive predicate on a relatively short list, or when unadvisedly relying on side-effecting predicates.

The DefaultArrayConverter type was been refactored away causing the linker to warn about it.

This makes it easier to add oddball variant builds, without a big pile of booleans for every possible variant

The format of the file has changed a bit some time ago, but the R2RTest wasn't updated accordingly, so test exclusion stopped working. This change fixes it.

Gets rid of a bunch of IAsyncResult cruft and makes the XxAsync APIs cancelable.

Including for cancellation and a product fix to enable cancellation.

Rename unused autoconfig dir aux -> aux_ consistent with original checkin

Introduced by libunwind/libunwind#71

__reseverved needs to be big enough to store a unw_fpsimd_context_t Which includes 32 128-bit registers, stored as 64 64-bit half registers. Fix off by 2 issue

Co-authored-by: Adeel adeelbm@outlook.com

Co-authored-by: Miha Zupan mihazupan.zupan1@gmail.com Co-authored-by: Ben Adams thundercat@illyriad.co.uk

Co-authored-by: Ben Adams thundercat@illyriad.co.uk

Co-authored-by: Ben Adams thundercat@illyriad.co.uk

Co-authored-by: Miha Zupan mihazupan.zupan1@gmail.com Co-authored-by: Ben Adams thundercat@illyriad.co.uk

The native code was still using the previous WEBASSEMBLY name instead of BROWSER as decided in https://github.com/dotnet/runtime/issues/33328.

Microsoft.NET.ILLink.Tasks From Version 5.0.0-preview.3.20268.2 -> To Version 5.0.0-preview.3.20268.5

Microsoft.NET.Test.Sdk From Version 16.7.0-preview-20200515-03 -> To Version 16.7.0-preview-20200518-01

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

This attribute is used by the linker to know which methods are unsafe to use when an application is trimmed.

Fix #33862

Addresses https://github.com/dotnet/runtime/pull/35864#issuecomment-629803015. In an earlier change I also added the type.Instantiation[0].IsPrimitive condition to the IsVectorType predicate. Revert that part as well and allow only primitive numeric types for HFA/HVA purpose. The same list of 10 types is recognized in MethodTable::GetVectorSize and Compiler::getBaseTypeAndSizeOfSIMDType.

Json benchmark showed improvement from 237,827 RPS to 270,306 RPS, and reduced working set by about 10MB

Fixes #36686.

Co-authored-by: Tomas Weinfurt furt@Shining.local

Remove extra / from path on runtimetests.

The jit tracks the number of no return calls to determine if it should run throw helper merging and to decide if no return calls should tail called.

The accounting is currently done when the calls are initially imported, so if code is duplicated (by say finally cloning the count may end up being an under-estimate. While not a correctness issue, it is better for the count to be accurate (or an over-estimate).

So, update the count when cloning a no-return call.

Closes #36584.

Use dotnet publish with linker just like for Android.

Co-authored-by: BrzVlad BrzVlad@users.noreply.github.com

Fixes https://github.com/mono/mono/issues/19801.

Co-authored-by: vargaz vargaz@users.noreply.github.com

This means we won't be upgrading existing packages on the system that we don't need for the build. Marks install-native-dependencies.sh as executable (+x) so we don't need to start it with sh in the build .yml

Fixes https://github.com/dotnet/runtime/issues/36727

During lowering, don't create a controlExpr for indirect call. Instead use temp register for such calls and during codegen, load the indirect from x11 into that temp register before calling the address in that temp register.

Add support for emitting an event with an arbitrary number of arguments over EventPipe.

It shouldn't be needed anymore since we have real assets for these targets now.

Before this change, pop-ing a vt from the stack was done in 2 opcodes, a MINT_POP (decrementing the stack) and the weird MINT_VTRESULT (decrementing the vtstack). However, optimizations could have removed both the initial loading of the value type on the stack as well as the MINT_POP, leaving MINT_VTRESULT underflowing the vtstack. Fix this and cleanup the code by pop-ing a value type from the stack in a single instruction.

Co-authored-by: BrzVlad BrzVlad@users.noreply.github.com

runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk From Version 9.0.1-alpha.1.20262.1 -> To Version 9.0.1-alpha.1.20268.2

Microsoft.NET.ILLink.Tasks From Version 5.0.0-preview.3.20268.5 -> To Version 5.0.0-preview.3.20269.1

Microsoft.DotNet.XHarness.Tests.Runners From Version 1.0.0-prerelease.20265.8 -> To Version 1.0.0-prerelease.20270.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

Don't use bitcast if the source is in memory or has the same type.

Move call handling to the users.

Windows x64 was supported in a previous PR, this adds x86 (Windows and Linux) and x64 Unix.

Simple here means of rank 1, and with a blittable value type as element type.

Since we're pushing the value of these fields we need to widen the value to a stack type.

Addresses issues seen in #36592.

Handle CORINFO_HELP_THROW_NOT_IMPLEMENTED

Fix two issues with hosting on SunOS:

Contributes to: #34944.

The linker was removing the icu shim functions even exporting them. The unique solution that we found until now is to force the linking using the -u flag. This is a temporary fix until we don't implement QCalls. Fixes https://github.com/dotnet/runtime/issues/36685

Fix #36619

Unity has a pdb with zero sequence points somehow. If a user added a reference to the library and then attempted to set a managed breakpoint mono would hit an assert and crash when it would attempt to decode this pdb.

Call stack would look like:

>	mono-2.0-boehm.dll!mono_ppdb_get_seq_points(_MonoDebugMethodInfo * minfo, char * * source_file, _GPtrArray * * source_file_list, int * * source_files, MonoSymSeqPoint * * seq_points, int * n_seq_points) Line 508	C
     mono-2.0-boehm.dll!mono_debug_get_seq_points(_MonoDebugMethodInfo * minfo, char * * source_file, _GPtrArray * * source_file_list, int * * source_files, MonoSymSeqPoint * * seq_points, int * n_seq_points) Line 1093	C
     mono-2.0-boehm.dll!get_source_files_for_type(_MonoClass * klass) Line 6920	C
     mono-2.0-boehm.dll!get_types_for_source_file(void * key, void * value, void * user_data) Line 7003	C
     mono-2.0-boehm.dll!monoeg_g_hash_table_foreach(_GHashTable * hash, void(*)(void *, void *, void *) func, void * user_data) Line 364	C
     mono-2.0-boehm.dll!mono_de_foreach_domain(void(*)(void *, void *, void *) func, void * user_data) Line 95	C
     mono-2.0-boehm.dll!vm_commands(int command, int id, unsigned char * p, unsigned char * end, Buffer * buf) Line 7341	C
     mono-2.0-boehm.dll!debugger_thread(void * arg) Line 10323	C
     mono-2.0-boehm.dll!start_wrapper_internal(StartInfo * start_info, unsigned __int64 * stack_ptr) Line 1241	C
     mono-2.0-boehm.dll!start_wrapper(void * data) Line 1315	C
     kernel32.dll!00007ffc12017bd4()	Unknown
     ntdll.dll!00007ffc121ece51()	Unknown

Adding a check to ignore pdbs like this prevents the crash and debugging can continue normally.

Related unity issue: https://issuetracker.unity3d.com/issues/macos-editor-crashes-on-mono-log-write-logfile-when-attaching-a-debugger-and-then-setting-a-breakpoint

Co-authored-by: UnityAlex UnityAlex@users.noreply.github.com

Seems to work fine for the Mono.CoreLib subset, which is all we care about in the IL Linker-land.

The logic in dir.common.props for relativizing test directories doesn't work well for the generated XUnit wrapper csproj files as these are generated under artifacts\tests. Relativizing this directory against src\coreclr\tests\src ended up with a weird sequence that ended up duplicating the tests/artifacts folder level. I have fixed this by explicitly passing the root directory for relativization for the XUnit wrapper projects.

Thanks

Tomas

Fixes: #1655

Co-authored-by: Krzysztof Wicher mordotymoja@gmail.com

Co-authored-by: Krzysztof Wicher mordotymoja@gmail.com

This can get called before morph and run into issues where morph specific data is not yet initialized. The remorphing wasn't going to do much other than extract side effects and rethread the statement ordering. So just do these latter bits.

Closes #36468.

Co-authored-by: radical radical@users.noreply.github.com

This library overlapped with other System APIs and is now obsolete. For API replacement:

ApplicationEnvironment.ApplicationBasePath => AppContext.BaseDirectory HashCodeCombiner => System.HashCode RuntimeEnvironment.GetRuntimeIdentifier() => RuntimeInformation.RuntimeIdentifier RuntimeEnvironment.OperatingSystemPlatform => RuntimeInformation.IsOSPlatform(OSPlatform) RuntimeEnvironment.RuntimeArchitecture => RuntimeInformation.ProcessArchitecture RuntimeEnvironment.OperatingSystem => RuntimeInformation.OSDescription RuntimeEnvironment.OperatingSystemVersion => RuntimeInformation.OSDescription / Environment.OSVersion.Version

Fix #3470

Today on Unix, we create an anonymous pipe via pipe/pipe2 to be used for stdin/stdout/stderr on processes created by Process.Start. We then wrap the resulting file descriptors with FileStreams to hand out via Process.StandardInput/Output/Error. This has a few issues, however. Any async operations on the resulting stream (or wrapping stream reader) will actually be async-over-sync, and that in turn means that a) any async read will end up blocking a thread pool thread until it's satisified, and b) the operation isn't cancelable. The implications of (b) are obvious, and the problem with (a) is that code which launches a bunch of processes and uses BeginOutput/ErrorReadLine or the like will end up blocking a bunch of thread pool threads.

This change replaces the pipe/pipe2 calls with socketpair calls, and instead of wrapping the resulting file descriptors with FileStream, wraps them in Sockets and NetworkStreams. This gives us the full capabilities of the networking stack, which fully supports asynchronous and cancelable reads and writes.

This change shifts producing wasm binaries to the native dir so that they'll come over to the installer on CI.

Contributes to #35199

This removes x86 OSX code that was never used for .NET Core.

Also, capitalize it in line with the rest of the repo

I don't fully understand why we use TargetOS in helixpublishwitharcade.proj but set __TargetOS in the calling send-to-helix-step.yml.

Implements PolynomialMultiplyWideningLower and PolynomialMultiplyWideningUpper

Fixing make dist after implementation of static ICU Shim.

Co-authored-by: thaystg thaystg@users.noreply.github.com

Co-authored-by: Adeel Mujahid adeelbm@outlook.com

Fixes https://github.com/dotnet/runtime/issues/34379.

Co-authored-by: vargaz vargaz@users.noreply.github.com

This reverts commit 8c6c7655bb7abc5c4ce769923aa5bea1daee6bd3.

Issue #36850

Quote user strings and escape control characters, unpaired surrogates, and other unsafe characters.

Microsoft.NET.ILLink.Tasks From Version 5.0.0-preview.3.20269.1 -> To Version 5.0.0-preview.3.20270.1

Microsoft.NET.Test.Sdk From Version 16.7.0-preview-20200518-01 -> To Version 16.7.0-preview-20200521-01

Microsoft.DotNet.XHarness.Tests.Runners From Version 1.0.0-prerelease.20270.1 -> To Version 1.0.0-prerelease.20270.2

Microsoft.NET.ILLink.Tasks From Version 5.0.0-preview.3.20269.1 -> To Version 5.0.0-preview.3.20271.1

Microsoft.DotNet.XHarness.Tests.Runners From Version 1.0.0-prerelease.20270.1 -> To Version 1.0.0-prerelease.20271.3

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

HAVE_STRUCT_SOCKADDR_IN6 needs to be defined to enable IPv6 features in mono/metadata/w32socket.c.

Fixes TcpListener issues in wine-mono.

Co-authored-by: w-flo w-flo@users.noreply.github.com

Microsoft.DotNet.XHarness.Tests.Runners From Version 1.0.0-prerelease.20271.3 -> To Version 1.0.0-prerelease.20275.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

The preebEndIndex offset was a total value in to the PEM's contents, not a moving offset. This would cause it to advance past the contents of th…