From c46d31decfa529ab188405547672d94f89a88a1d Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Mon, 9 Feb 2026 15:07:52 +0100 Subject: [PATCH 1/3] [net11.0] Enable launch time logging with environment variable --- dotnet/targets/Xamarin.Shared.Sdk.props | 4 ++++ runtime/monotouch-main.m | 32 ++++++++++++++----------- runtime/runtime-internal.h | 7 +----- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.props b/dotnet/targets/Xamarin.Shared.Sdk.props index 523bea4d6f07..9527c4b0dfa1 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.props +++ b/dotnet/targets/Xamarin.Shared.Sdk.props @@ -234,6 +234,10 @@ <_BundlerEnvironmentVariables Include="DOTNET_ReadyToRun" Value="0" /> + + <_BundlerEnvironmentVariables Include="DEBUG_LAUNCH_TIME" Value="1" /> + + <_SdkIsSimulator Condition="'$(RuntimeIdentifier)' != '' And '$(_SdkIsSimulator)' == ''">$(RuntimeIdentifier.Contains('simulator')) diff --git a/runtime/monotouch-main.m b/runtime/monotouch-main.m index 791901bd65c6..a27be493d6e1 100644 --- a/runtime/monotouch-main.m +++ b/runtime/monotouch-main.m @@ -151,31 +151,35 @@ } #endif // !defined (CORECLR_RUNTIME) -#ifdef DEBUG_LAUNCH_TIME -uint64_t startDate = 0; -uint64_t date = 0; +static uint64_t debug_launch_startDate = 0; +static uint64_t debug_launch_date = 0; +static int debug_launch_time_enabled = -1; + void debug_launch_time_print (const char *msg) { + if (debug_launch_time_enabled == -1) { + const char *env = getenv ("DEBUG_LAUNCH_TIME"); + debug_launch_time_enabled = (env != NULL && env[0] == '1') ? 1 : 0; + } + + if (!debug_launch_time_enabled) + return; + uint64_t unow; struct timeval now; gettimeofday (&now, NULL); - unow = now.tv_sec * 1000000ULL + now.tv_usec; + unow = (uint64_t) now.tv_sec * 1000000ULL + (uint64_t) now.tv_usec; - if (startDate == 0) { - startDate = unow; - date = startDate; + if (debug_launch_startDate == 0) { + debug_launch_startDate = unow; + debug_launch_date = debug_launch_startDate; } - PRINT ("%s: %llu us Total: %llu us", msg, unow - date, unow - startDate); + PRINT ("%s: %llu us Total: %llu us", msg, unow - debug_launch_date, unow - debug_launch_startDate); - date = unow; + debug_launch_date = unow; } -#else -inline void debug_launch_time_print (const char *msg) -{ -} -#endif /* * This class will listen for memory warnings and when received, force diff --git a/runtime/runtime-internal.h b/runtime/runtime-internal.h index c260a900c251..c53eccacf860 100644 --- a/runtime/runtime-internal.h +++ b/runtime/runtime-internal.h @@ -16,14 +16,9 @@ #define PRINT(...) do { xamarin_printf (__VA_ARGS__); } while (0); #define LOG(...) do { if (xamarin_log_level > 0) xamarin_printf (__VA_ARGS__); } while (0); -// #define DEBUG_LAUNCH_TIME - -#ifdef DEBUG_LAUNCH_TIME +void debug_launch_time_print (const char *msg); #define DEBUG_LAUNCH_TIME_PRINT(msg) \ debug_launch_time_print (msg); -#else -#define DEBUG_LAUNCH_TIME_PRINT(...) -#endif // Uncomment the TRACK_MONOOBJECTS define to show a summary at process exit of // the MonoObjects that were created, and if any were not freed. If there are From 66652b6a9db379172dbfc6eb06af03b4fe207e53 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 10 Feb 2026 12:25:26 +0100 Subject: [PATCH 2/3] Rename function and locals --- runtime/monotouch-main.m | 38 +++++++++++++++++++------------------- runtime/monovm-bridge.m | 8 ++++---- runtime/runtime-internal.h | 6 +++--- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/runtime/monotouch-main.m b/runtime/monotouch-main.m index a27be493d6e1..aba63dead0e1 100644 --- a/runtime/monotouch-main.m +++ b/runtime/monotouch-main.m @@ -151,18 +151,18 @@ } #endif // !defined (CORECLR_RUNTIME) -static uint64_t debug_launch_startDate = 0; -static uint64_t debug_launch_date = 0; -static int debug_launch_time_enabled = -1; +static uint64_t xamarin_launch_startDate = 0; +static uint64_t xamarin_launch_date = 0; +static int xamarin_launch_time_enabled = -1; -void debug_launch_time_print (const char *msg) +void xamarin_launch_time_print (const char *msg) { - if (debug_launch_time_enabled == -1) { + if (xamarin_launch_time_enabled == -1) { const char *env = getenv ("DEBUG_LAUNCH_TIME"); - debug_launch_time_enabled = (env != NULL && env[0] == '1') ? 1 : 0; + xamarin_launch_time_enabled = (env != NULL && env[0] == '1') ? 1 : 0; } - if (!debug_launch_time_enabled) + if (!xamarin_launch_time_enabled) return; uint64_t unow; @@ -171,14 +171,14 @@ void debug_launch_time_print (const char *msg) gettimeofday (&now, NULL); unow = (uint64_t) now.tv_sec * 1000000ULL + (uint64_t) now.tv_usec; - if (debug_launch_startDate == 0) { - debug_launch_startDate = unow; - debug_launch_date = debug_launch_startDate; + if (xamarin_launch_startDate == 0) { + xamarin_launch_startDate = unow; + xamarin_launch_date = xamarin_launch_startDate; } - PRINT ("%s: %llu us Total: %llu us", msg, unow - debug_launch_date, unow - debug_launch_startDate); + PRINT ("%s: %llu us Total: %llu us", msg, unow - xamarin_launch_date, unow - xamarin_launch_startDate); - debug_launch_date = unow; + xamarin_launch_date = unow; } /* @@ -260,10 +260,10 @@ - (void) memoryWarning: (NSNotification *) sender managed_argv [managed_argc++] = "monotouch"; #endif - DEBUG_LAUNCH_TIME_PRINT ("Main entered"); + XAMARIN_LAUNCH_TIME_PRINT ("Main entered"); xamarin_setup (); - DEBUG_LAUNCH_TIME_PRINT ("MonoTouch setup time"); + XAMARIN_LAUNCH_TIME_PRINT ("MonoTouch setup time"); MonoAssembly *assembly; GCHandle exception_gchandle = NULL; @@ -282,7 +282,7 @@ - (void) memoryWarning: (NSNotification *) sender xamarin_bridge_setup (); - DEBUG_LAUNCH_TIME_PRINT ("Spin-up time"); + XAMARIN_LAUNCH_TIME_PRINT ("Spin-up time"); { /* @@ -412,7 +412,7 @@ - (void) memoryWarning: (NSNotification *) sender xamarin_bridge_initialize (); xamarin_initialize (); - DEBUG_LAUNCH_TIME_PRINT ("\tmonotouch init time"); + XAMARIN_LAUNCH_TIME_PRINT ("\tmonotouch init time"); if (xamarin_register_assemblies != NULL) xamarin_register_assemblies (); @@ -442,13 +442,13 @@ - (void) memoryWarning: (NSNotification *) sender (void)exception_gchandle; #endif // !defined (NATIVEAOT) - DEBUG_LAUNCH_TIME_PRINT ("\tAssembly register time"); + XAMARIN_LAUNCH_TIME_PRINT ("\tAssembly register time"); [[[XamarinGCSupport alloc] init] autorelease]; - DEBUG_LAUNCH_TIME_PRINT ("\tGC defer time"); + XAMARIN_LAUNCH_TIME_PRINT ("\tGC defer time"); - DEBUG_LAUNCH_TIME_PRINT ("Total initialization time"); + XAMARIN_LAUNCH_TIME_PRINT ("Total initialization time"); int rv = 0; switch (launch_mode) { diff --git a/runtime/monovm-bridge.m b/runtime/monovm-bridge.m index dda287dcfbfb..6013963693da 100644 --- a/runtime/monovm-bridge.m +++ b/runtime/monovm-bridge.m @@ -53,11 +53,11 @@ { if (xamarin_register_modules != NULL) xamarin_register_modules (); - DEBUG_LAUNCH_TIME_PRINT ("\tAOT register time"); + XAMARIN_LAUNCH_TIME_PRINT ("\tAOT register time"); #ifdef DEBUG monotouch_start_debugging (); - DEBUG_LAUNCH_TIME_PRINT ("\tDebug init time"); + XAMARIN_LAUNCH_TIME_PRINT ("\tDebug init time"); #endif if (xamarin_init_mono_debug) @@ -68,7 +68,7 @@ #ifdef DEBUG monotouch_start_profiling (); - DEBUG_LAUNCH_TIME_PRINT ("\tProfiler config time"); + XAMARIN_LAUNCH_TIME_PRINT ("\tProfiler config time"); #endif mono_set_signal_chaining (TRUE); @@ -82,7 +82,7 @@ This is wasteful, but there's no way to manipulate the preload hook list except by adding to it. */ mono_install_assembly_preload_hook (xamarin_assembly_preload_hook, NULL); - DEBUG_LAUNCH_TIME_PRINT ("\tJIT init time"); + XAMARIN_LAUNCH_TIME_PRINT ("\tJIT init time"); } void diff --git a/runtime/runtime-internal.h b/runtime/runtime-internal.h index c53eccacf860..f35c9995ce78 100644 --- a/runtime/runtime-internal.h +++ b/runtime/runtime-internal.h @@ -16,9 +16,9 @@ #define PRINT(...) do { xamarin_printf (__VA_ARGS__); } while (0); #define LOG(...) do { if (xamarin_log_level > 0) xamarin_printf (__VA_ARGS__); } while (0); -void debug_launch_time_print (const char *msg); -#define DEBUG_LAUNCH_TIME_PRINT(msg) \ - debug_launch_time_print (msg); +void xamarin_launch_time_print (const char *msg); +#define XAMARIN_LAUNCH_TIME_PRINT(msg) \ + xamarin_launch_time_print (msg); // Uncomment the TRACK_MONOOBJECTS define to show a summary at process exit of // the MonoObjects that were created, and if any were not freed. If there are From 79e9b702f66fb8b805046364b7f6f7925965536f Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 11 Feb 2026 09:03:36 +0100 Subject: [PATCH 3/3] [tests] Update expected sizes. --- .../UnitTests/expected/iOS-MonoVM-interpreter-size.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-size.txt b/tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-size.txt index ff563d529e80..bec783451d9f 100644 --- a/tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-size.txt +++ b/tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-size.txt @@ -1,12 +1,12 @@ -AppBundleSize: 3,611,961 bytes (3,527.3 KB = 3.4 MB) +AppBundleSize: 3,631,541 bytes (3,546.4 KB = 3.5 MB) # The following list of files and their sizes is just informational / for review, and isn't used in the test: _CodeSignature/CodeResources: 3,997 bytes (3.9 KB = 0.0 MB) archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB) -Info.plist: 1,167 bytes (1.1 KB = 0.0 MB) -Microsoft.iOS.dll: 150,528 bytes (147.0 KB = 0.1 MB) +Info.plist: 1,147 bytes (1.1 KB = 0.0 MB) +Microsoft.iOS.dll: 153,088 bytes (149.5 KB = 0.1 MB) PkgInfo: 8 bytes (0.0 KB = 0.0 MB) runtimeconfig.bin: 1,405 bytes (1.4 KB = 0.0 MB) -SizeTestApp: 2,388,080 bytes (2,332.1 KB = 2.3 MB) +SizeTestApp: 2,405,120 bytes (2,348.8 KB = 2.3 MB) SizeTestApp.dll: 7,680 bytes (7.5 KB = 0.0 MB) System.Private.CoreLib.aotdata.arm64: 41,368 bytes (40.4 KB = 0.0 MB) System.Private.CoreLib.dll: 1,004,032 bytes (980.5 KB = 1.0 MB)