Bug 24694 - Mono Runtime repeatedly loads and unloads core assemblies, causing long startup times
Summary: Mono Runtime repeatedly loads and unloads core assemblies, causing long start...
Status: RESOLVED UPSTREAM
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.12.3
Hardware: Macintosh Mac OS
: Low normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-11-20 09:21 UTC by Johannes Rudolph
Modified: 2017-06-28 15:56 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description Johannes Rudolph 2014-11-20 09:21:27 UTC
We are currently working on improving App startup times and 90% of our startup time is due to the mono runtime. 
We noticed there are lots of assembly image loads and unloads happening at startup and I believe a large percent of unloads (and repeated re-loads) are avoidable. These are the mscorlib unloads alone that we get during the startup of our app : 

  516: 11-20 14:48:22.361: D/Mono(7343): Unloading image mscorlib.dll [0x5c7cb428].
  519: 11-20 14:48:23.021: D/Mono(7343): Unloading image mscorlib.dll [0x5c81d560].
  523: 11-20 14:48:23.231: D/Mono(7343): Unloading image mscorlib.dll [0x5c85a6e0].
  532: 11-20 14:48:23.282: D/Mono(7343): Unloading image mscorlib.dll [0x5c884500].
  537: 11-20 14:48:23.602: D/Mono(7343): Unloading image mscorlib.dll [0x5c9150e8].
  540: 11-20 14:48:23.612: D/Mono(7343): Unloading image mscorlib.dll [0x5c9159e0].
  564: 11-20 14:48:25.053: D/Mono(7343): Unloading image mscorlib.dll [0x5c8eb080].
  567: 11-20 14:48:25.063: D/Mono(7343): Unloading image mscorlib.dll [0x5c8eb080].
  571: 11-20 14:48:25.063: D/Mono(7343): Unloading image mscorlib.dll [0x5c8eb080].
  583: 11-20 14:48:25.143: D/Mono(7343): Unloading image mscorlib.dll [0x5c8eba80].
  592: 11-20 14:48:25.273: D/Mono(7343): Unloading image mscorlib.dll [0x5cabaae0].
  616: 11-20 14:48:25.694: D/Mono(7343): Unloading image mscorlib.dll [0x5cc053f8].
  620: 11-20 14:48:25.704: D/Mono(7343): Unloading image mscorlib.dll [0x5cc05700].
  635: 11-20 14:48:25.734: D/Mono(7343): Unloading image mscorlib.dll [0x5cc15828].
  646: 11-20 14:48:25.754: D/Mono(7343): Unloading image mscorlib.dll [0x5cc22e60].
  698: 11-20 14:48:27.556: D/Mono(7343): Unloading image mscorlib.dll [0x5cdff6b8].
  702: 11-20 14:48:27.606: D/Mono(7343): Unloading image mscorlib.dll [0x5ce06740].
  723: 11-20 14:48:29.668: D/Mono(7343): Unloading image mscorlib.dll [0x5d106b70].
  728: 11-20 14:48:29.688: D/Mono(7343): Unloading image mscorlib.dll [0x5d119d30].
  735: 11-20 14:48:29.708: D/Mono(7343): Unloading image mscorlib.dll [0x5d0ba510].
  747: 11-20 14:48:29.968: D/Mono(7343): Unloading image mscorlib.dll [0x5d216988].
  766: 11-20 14:48:30.008: D/Mono(7343): Unloading image mscorlib.dll [0x5d235450].
  782: 11-20 14:48:30.028: D/Mono(7343): Unloading image mscorlib.dll [0x5d201918].
  792: 11-20 14:48:30.889: D/Mono(7343): Unloading image mscorlib.dll [0x64287b88].
  804: 11-20 14:48:31.099: D/Mono(7343): Unloading image mscorlib.dll [0x642f1998].
  812: 11-20 14:48:32.010: D/Mono(7343): Unloading image mscorlib.dll [0x64819af0].
  834: 11-20 14:48:32.771: D/Mono(7343): Unloading image mscorlib.dll [0x6494cd58].
  900: 11-20 14:48:40.348: D/Mono(7343): Unloading image mscorlib.dll [0x63b602d8].
  911: 11-20 14:48:42.190: D/Mono(7343): Unloading image mscorlib.dll [0x66008160].
  921: 11-20 14:48:42.210: D/Mono(7343): Unloading image mscorlib.dll [0x6601d6a8].
  937: 11-20 14:48:44.402: D/Mono(7343): Unloading image mscorlib.dll [0x663f6b50].
  950: 11-20 14:48:52.640: D/Mono(7343): Unloading image mscorlib.dll [0x66de5a20].
  959: 11-20 14:48:52.650: D/Mono(7343): Unloading image mscorlib.dll [0x65b39de0].
 1484: 11-20 14:52:14.002: D/Mono(7968): Unloading image mscorlib.dll [0x5c7cb488].
 1487: 11-20 14:52:14.743: D/Mono(7968): Unloading image mscorlib.dll [0x5c81dec8].
 1491: 11-20 14:52:14.983: D/Mono(7968): Unloading image mscorlib.dll [0x5c85a678].
 1500: 11-20 14:52:15.044: D/Mono(7968): Unloading image mscorlib.dll [0x5c885aa8].
 1505: 11-20 14:52:15.454: D/Mono(7968): Unloading image mscorlib.dll [0x5c863008].
 1508: 11-20 14:52:15.454: D/Mono(7968): Unloading image mscorlib.dll [0x5c863008].
 1532: 11-20 14:52:17.005: D/Mono(7968): Unloading image mscorlib.dll [0x5c8ed6f8].
 1535: 11-20 14:52:17.005: D/Mono(7968): Unloading image mscorlib.dll [0x5c8ed6f8].
 1539: 11-20 14:52:17.015: D/Mono(7968): Unloading image mscorlib.dll [0x5c8ed6f8].
 1551: 11-20 14:52:17.096: D/Mono(7968): Unloading image mscorlib.dll [0x5c8ee2d0].
 1560: 11-20 14:52:17.226: D/Mono(7968): Unloading image mscorlib.dll [0x5cb39168].
 1584: 11-20 14:52:17.636: D/Mono(7968): Unloading image mscorlib.dll [0x5cc04fb8].
 1588: 11-20 14:52:17.636: D/Mono(7968): Unloading image mscorlib.dll [0x5cc052c0].
 1603: 11-20 14:52:17.656: D/Mono(7968): Unloading image mscorlib.dll [0x5cc153e8].
 1614: 11-20 14:52:17.666: D/Mono(7968): Unloading image mscorlib.dll [0x5cc222c0].
 1666: 11-20 14:52:19.548: D/Mono(7968): Unloading image mscorlib.dll [0x5cdfefe0].
 1670: 11-20 14:52:19.588: D/Mono(7968): Unloading image mscorlib.dll [0x5ce06088].
 1691: 11-20 14:52:20.759: D/Mono(7968): Unloading image mscorlib.dll [0x5d0f86f8].
 1696: 11-20 14:52:20.769: D/Mono(7968): Unloading image mscorlib.dll [0x5d0b7540].
 1703: 11-20 14:52:20.789: D/Mono(7968): Unloading image mscorlib.dll [0x5d11db10].
 1715: 11-20 14:52:21.039: D/Mono(7968): Unloading image mscorlib.dll [0x5d216870].
 1734: 11-20 14:52:21.149: D/Mono(7968): Unloading image mscorlib.dll [0x5d35a6b8].
 1750: 11-20 14:52:21.169: D/Mono(7968): Unloading image mscorlib.dll [0x5d362020].
 1760: 11-20 14:52:21.940: D/Mono(7968): Unloading image mscorlib.dll [0x6428b858].
 1772: 11-20 14:52:22.140: D/Mono(7968): Unloading image mscorlib.dll [0x642f6ea0].
 1780: 11-20 14:52:23.021: D/Mono(7968): Unloading image mscorlib.dll [0x6481efe0].
 1788: 11-20 14:52:23.522: D/Mono(7968): Unloading image mscorlib.dll [0x648fa488].
 1803: 11-20 14:52:23.582: D/Mono(7968): Unloading image mscorlib.dll [0x648f8b28].
 1827: 11-20 14:52:24.112: D/Mono(7968): Unloading image mscorlib.dll [0x64a8fb28].
 1893: 11-20 14:52:43.181: D/Mono(7968): Unloading image mscorlib.dll [0x65c26008].
 1905: 11-20 14:52:46.544: D/Mono(7968): Unloading image mscorlib.dll [0x663fa898].
 1918: 11-20 14:52:54.922: D/Mono(7968): Unloading image mscorlib.dll [0x66137548].
 1927: 11-20 14:52:54.942: D/Mono(7968): Unloading image mscorlib.dll [0x6611b448].
 1970: 11-20 14:56:58.716: D/Mono(7968): Unloading image mscorlib.dll [0x66df8dc8].

I traced this to mono_image_close_except_pools() in mono/runtime/image.c

Others have previously complained about slow Xamarin Android performance and I believe this an important opportunity for optimization. Also see: http://forums.xamarin.com/discussion/10272/unloading-image-system-dll-log-spam
Comment 1 Jon Douglas [MSFT] 2017-06-28 15:56:12 UTC
Hi Johannes,

I believe majority of this issue has been resolved and not problematic in nature based on https://bugzilla.xamarin.com/show_bug.cgi?id=25737, but if it continues to be an issue, please reopen this bug.

When you reopen this bug, please upload a sample project that shows overly verbose unloading/loading messages to this bugzilla report.