Bug 53093 - Enabling the concurrent GC doesn't work in debug mode
Summary: Enabling the concurrent GC doesn't work in debug mode
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 10.8 (d15-1)
Hardware: PC Mac OS
: Normal normal
Target Milestone: 15.1
Assignee: Vlad Brezae
URL:
Depends on:
Blocks:
 
Reported: 2017-03-06 21:34 UTC by Rodrigo Kumpera
Modified: 2017-03-17 15:22 UTC (History)
7 users (show)

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


Attachments
Test Case (11.07 KB, application/zip)
2017-03-07 20:55 UTC, Vincent Dondain [MSFT]
Details
Bug 53093 Logs and Build Output Stacktrace (1019.82 KB, application/x-zip-compressed)
2017-03-17 15:21 UTC, Mohak Barokar
Details


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:
VERIFIED FIXED

Description Rodrigo Kumpera 2017-03-06 21:34:55 UTC
Enabling it in debug builds doesn't work. I always get the serial GC.

It works fine in Release builds.
Comment 1 Vincent Dondain [MSFT] 2017-03-07 16:31:35 UTC
Hey,

I'm not really familiar with the way to test this, can you explain?

Repro steps or mini test case maybe?

I see there's a new build option to enable the concurrent GC but how do I tell if it's using it or the serial GC?
Comment 2 Rodrigo Kumpera 2017-03-07 20:08:30 UTC
Repro steps:

1)Create iOS project
1.a)Add code that alloc a lot `var l = new List<object> (); while (true) { l.Add (new int[400]); }`

2)Enable gc logging by setting the following 2 env vars: MONO_LOG_LEVEL=debug MONO_LOG_MASK=gc

3)Run the application and look at the GC_MAJOR log messages. They won't mention the concurrent GC.

4)Enable concurrent GC in the "iOS Build" options for the debug configuration

5)Run the application again and look at the GC_MAJOR log message. Still all serial.

To see the different, do it under the release configuration instead as that one works as expected.
Comment 3 Vincent Dondain [MSFT] 2017-03-07 20:55:04 UTC
Created attachment 20189 [details]
Test Case
Comment 4 Vincent Dondain [MSFT] 2017-03-07 20:58:22 UTC
Thanks Rodrigo for the info I was able to reproduce.

I created a test case to save some times to other team members. There's a `GCLogging` configuration you can set (it has the env variables Rodrigo mentioned).

Also the concurrent GC is enabled in both Debug and Release modes and it seems to only work with Release so that bug is confirmed.

Here's the wrong output (serial GC):

2017-03-07 15:33:45.693 MyIOSProject[33923:9994679] info: GC_MAJOR: (Minor allowance) time 12.71ms, stw 12.73ms los size: 3076K in use: 2058K
2017-03-07 15:33:45.700 MyIOSProject[33923:9994679] info: GC_MAJOR_SWEEP: major size: 456720K in use: 446903K

and here's the one we expect when enabling the build option:

2017-03-07 15:44:22.527 MyIOSProject[34386:10065044] info: GC_MINOR: (Concurrent start) time 0.29ms, stw 0.41ms promoted 503K major size: 5808K in use: 4991K los size: 1024K in use: 66K
2017-03-07 15:44:22.527 MyIOSProject[34386:10065044] info: GC_MAJOR_CONCURRENT_START: (Minor allowance)
2017-03-07 15:44:22.527 MyIOSProject[34386:10065044] info: GC_MINOR: (Nursery full) time 0.36ms, stw 0.37ms promoted 503K major size: 6368K in use: 5541K los size: 1024K in use: 66K
2017-03-07 15:44:22.528 MyIOSProject[34386:10065044] info: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 1.20ms, stw 0.34ms los size: 1024K in use: 42K
2017-03-07 15:44:22.528 MyIOSProject[34386:10065044] info: GC_MAJOR_SWEEP: major size: 6928K in use: 6092K

I'm using the following environment: https://gist.github.com/VincentDondain/2634763d924944b48d29cf91ae4d3f66
Comment 5 Sebastien Pouliot 2017-03-13 20:19:34 UTC
My bad I missed the PR (ETL meeting) but I'm not sure why [1] was merged [2], as far as I can see, without links to any test [3], documentation or QA sign off.

Are any of the above available ?

[1] https://github.com/xamarin/xamarin-macios/pull/1546

[2] c.c. Rolf and Chris

[3] the mmp test only check the argument is accepted, not that the feature works
Comment 6 Chris Hamons 2017-03-13 20:24:00 UTC
I did not realize that the +1 implied it was ready to go / they had not handled the required QA. Will keep in mind for future. My bad.

The mmp test does run it through all the way of generating MONO_GC_PARAMS in your launcher and running that code.
Comment 7 Rolf Bjarne Kvinge [MSFT] 2017-03-14 07:11:22 UTC
Yeah, I should not have merged this.

Regarding testing: using Rodrigo's method of verifying that the feature works (looking for GC_MAJOR_CONCURRENT in the verbose GC output) is currently not possible on iOS without major changes to our tests, so in that case manual QA testing is likely required. OTOH I believe it's not too complicated to implement such tests for Xamarin.Mac (Chris?)
Comment 8 Chris Hamons 2017-03-14 13:03:16 UTC
It depends how far you want to go down the rabbit hole.

Inside Unified_SgenConcurrent_Test if you want to just check for GC_MAJOR_CONCURRENT being set as an environmental setting then you just add some TestCode to Unified_SgenConcurrent_Test that checks for it and throws if not.

If you want to actually check the GC output, I would do something like:

Add another field here for env vars to set during test run: https://github.com/xamarin/xamarin-macios/blob/master/tests/common/mac/ProjectTestHelpers.cs#L44

Then here set it before test running and then unset after (make sure to do unset in a finally block to not pollute other tests).

https://github.com/xamarin/xamarin-macios/blob/master/tests/common/mac/ProjectTestHelpers.cs#L208 

Then you could look at the output of TestUnifiedExecutable for the stdout.
Comment 9 Vlad Brezae 2017-03-14 14:56:32 UTC
At runtime, the easiest to test this would be : System.Environment.GetEnvironmentVariable("MONO_GC_PARAMS").Contains("major=marksweep-conc");
Comment 10 GouriKumari 2017-03-15 19:24:12 UTC
Based on comment#9, I tested a template iOS project after setting a Console.WriteLine(System.Environment.GetEnvironmentVariable("MONO_GC_PARAMS").Contains("major=marksweep-conc"); in finished launching and it returned true with debug configuration.

##Logs:
Build Log: https://gist.github.com/GouriKumari/b9919f600cc8a03e42404cb77465978b
Application Output: https://gist.github.com/GouriKumari/c701875f7bd2809338c1783b12b4efdb


##Test Env:
=== Xamarin Studio Enterprise ===

Version 6.3 (build 838)
Installation UUID: 5ed3a124-4b77-4c6f-beb9-c830fd815e2a
Runtime:
	Mono 4.8.0 (mono-4.8.0-branch/8f6d0f6) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000520

=== NuGet ===

Version: 3.5.0.0

=== Xamarin.Profiler ===

Version: 1.2.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 7.1.0.41 (Visual Studio Enterprise)
Android SDK: /Users/gourikumari/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)

SDK Tools Version: 25.2.3
SDK Platform Tools Version: 25.0.1
SDK Build Tools Version: 25.0.1

Java SDK: /usr
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 8.2 (11766)
Build 8C38

=== Xamarin.iOS ===

Version: 10.8.0.20 (Visual Studio Enterprise)
Hash: f94cf26
Branch: d15-1
Build date: 2017-03-14 12:37:51-0400

=== Xamarin.Mac ===

Version: 3.0.0.393 (Visual Studio Enterprise)

=== Xamarin Inspector ===

Version: 1.1.2.0
Hash: cdc01b9
Branch: 1.1-release
Build date: Wed, 22 Feb 2017 23:24:11 GMT

=== Build Information ===

Release ID: 603000838
Git revision: 9f27643fb97c5d2bcec86b3d1f027ad0e51eb5cd
Build date: 2017-03-15 13:05:30-04
Xamarin addins: 3a6091980cf8c3b1159fe2d99807bb6a7209d865
Build lane: monodevelop-lion-d15-1

=== Operating System ===

Mac OS X 10.12.2
Darwin GouriKumari 16.3.0 Darwin Kernel Version 16.3.0
    Thu Nov 17 20:23:58 PST 2016
    root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
Comment 11 GouriKumari 2017-03-15 20:03:59 UTC
Updates to Comment #10:
Vlad said in slack that issue is not reproducible with device.

With simulator, System.Environment.GetEnvironmentVariable("MONO_GC_PARAMS").Contains("major=marksweep-conc" gives an NRE.

StackTrace:https://gist.github.com/GouriKumari/da8139a7460874ac4040c8923fc12614
Build Log: https://gist.github.com/GouriKumari/9deb2f9c2231c87d9d55639ea0d02248

In the build log (mentioned in comment#9 and comment #10), the environment variable is set both for Debug|iPhone and Debug|iPhoneSimulator.

## Supplemental Info:
With Release|Simulator configuration, System.Environment.GetEnvironmentVariable("MONO_GC_PARAMS").Contains("major=marksweep-conc" returned "true".

Build Log:https://gist.github.com/GouriKumari/2786b98897e2d27d9f4b2f1196ceac6a
Application output: https://gist.github.com/GouriKumari/2de0652b152030b690ca6f89767c089a

##Test Env:
=== Xamarin Studio Enterprise ===

Version 6.3 (build 838)
Installation UUID: 5ed3a124-4b77-4c6f-beb9-c830fd815e2a
Runtime:
	Mono 4.8.0 (mono-4.8.0-branch/8f6d0f6) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000520

=== NuGet ===

Version: 3.5.0.0

=== Xamarin.Profiler ===

Version: 1.2.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 7.1.0.41 (Visual Studio Enterprise)
Android SDK: /Users/gourikumari/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)

SDK Tools Version: 25.2.3
SDK Platform Tools Version: 25.0.1
SDK Build Tools Version: 25.0.1

Java SDK: /usr
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 8.2 (11766)
Build 8C38

=== Xamarin.iOS ===

Version: 10.8.0.20 (Visual Studio Enterprise)
Hash: f94cf26
Branch: d15-1
Build date: 2017-03-14 12:37:51-0400

=== Xamarin.Mac ===

Version: 3.0.0.393 (Visual Studio Enterprise)

=== Xamarin Inspector ===

Version: 1.1.2.0
Hash: cdc01b9
Branch: 1.1-release
Build date: Wed, 22 Feb 2017 23:24:11 GMT

=== Build Information ===

Release ID: 603000838
Git revision: 9f27643fb97c5d2bcec86b3d1f027ad0e51eb5cd
Build date: 2017-03-15 13:05:30-04
Xamarin addins: 3a6091980cf8c3b1159fe2d99807bb6a7209d865
Build lane: monodevelop-lion-d15-1

=== Operating System ===

Mac OS X 10.12.2
Darwin GouriKumari 16.3.0 Darwin Kernel Version 16.3.0
    Thu Nov 17 20:23:58 PST 2016
    root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
Comment 12 Sebastien Pouliot 2017-03-15 21:09:27 UTC
@Gouri no the issue is only with the pre-built simlauncher.

I merged PR1867 [1] (master) so that should be enough to verify the fix (not the feature). It can also be backported to `d15-1` as the decision to show the related UI (or not) is being made in a different PR [2] pending tests.

[1] https://github.com/xamarin/xamarin-macios/pull/1867
[2] https://github.com/xamarin/xamarin-macios/pull/1873
Comment 13 GouriKumari 2017-03-16 22:01:12 UTC
Verified with master build Xamarin.iOSVersion: 10.9.0.65 (Visual Studio Enterprise)
Hash: 8b376ef, Branch: master.

## Result:
System.Environment.GetEnvironmentVariable("MONO_GC_PARAMS").Contains("major=marksweep-conc" returned true with Debug|Simulator.

##
Screenshot: https://www.screencast.com/t/EH7appf2
Build Log: https://gist.github.com/GouriKumari/f888d73d56392d9b9f80e75b81690303

## Test Env:
=== Xamarin Studio Enterprise ===

Version 6.3 (build 838)
Installation UUID: 5ed3a124-4b77-4c6f-beb9-c830fd815e2a
Runtime:
	Mono 4.8.0 (mono-4.8.0-branch/8f6d0f6) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000520

=== NuGet ===

Version: 3.5.0.0

=== Xamarin.Profiler ===

Version: 1.2.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 7.1.0.41 (Visual Studio Enterprise)
Android SDK: /Users/gourikumari/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)

SDK Tools Version: 25.2.3
SDK Platform Tools Version: 25.0.1
SDK Build Tools Version: 25.0.1

Java SDK: /usr
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 8.2 (11766)
Build 8C38

=== Xamarin.iOS ===

Version: 10.9.0.65 (Visual Studio Enterprise)
Hash: 8b376ef
Branch: master
Build date: 2017-03-16 16:52:39-0400

=== Xamarin.Mac ===

Version: 3.0.0.393 (Visual Studio Enterprise)

=== Xamarin Inspector ===

Version: 1.1.2.0
Hash: cdc01b9
Branch: 1.1-release
Build date: Wed, 22 Feb 2017 23:24:11 GMT

=== Build Information ===

Release ID: 603000838
Git revision: 9f27643fb97c5d2bcec86b3d1f027ad0e51eb5cd
Build date: 2017-03-15 13:05:30-04
Xamarin addins: 3a6091980cf8c3b1159fe2d99807bb6a7209d865
Build lane: monodevelop-lion-d15-1

=== Operating System ===

Mac OS X 10.12.2
Darwin GouriKumari 16.3.0 Darwin Kernel Version 16.3.0
    Thu Nov 17 20:23:58 PST 2016
    root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
Comment 14 GouriKumari 2017-03-16 22:03:44 UTC
## Updates to Screenshot:
Attached the wrong link in comment #13

Correct: https://www.screencast.com/t/cGkQpNWvb
Comment 15 Sebastien Pouliot 2017-03-16 22:21:22 UTC
PR d15-1 https://github.com/xamarin/xamarin-macios/pull/1883
Comment 16 Sebastien Pouliot 2017-03-17 03:30:49 UTC
PR for d15-1 merged in https://github.com/xamarin/xamarin-macios/commit/4557a827783e41072c6c6f27540706ae568fb657
Comment 17 Mohak Barokar 2017-03-17 15:21:20 UTC
Created attachment 20438 [details]
Bug 53093 Logs and Build Output Stacktrace

Verified this bug on following configuration and found to be fixed : 

=== Xamarin Studio Enterprise ===

Version 6.3 (build 834)
Installation UUID: 1556bf59-77b8-4ed6-abe9-32ef4bc21a9c
Runtime:
 Mono 4.8.0 (mono-4.8.0-branch/8f6d0f6) (64-bit)
 GTK+ 2.24.23 (Raleigh theme)

 Package version: 408000520

=== NuGet ===

Version: 3.5.0.0

=== Xamarin.Profiler ===

Version: 1.3.2
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.iOS ===

Version: 10.8.0.25 (Visual Studio Enterprise Trial)
Hash: 04cff68
Branch: d15-1
Build date: 2017-03-17 01:25:55-0400

=== Xamarin Inspector ===

Version: 1.1.2.0
Hash: cdc01b9
Branch: 1.1-release
Build date: Wed, 22 Feb 2017 23:24:11 GMT

=== Xamarin.Android ===

Version: 7.2.0.2 (Visual Studio Enterprise Trial)
Android SDK: /Users/globallogic/Library/Developer/Xamarin/android-sdk-macosx
 Supported Android versions:
  4.4 (API level 19)
  6.0 (API level 23)
  7.1 (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 25.0.1

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin.Mac ===

Version: 3.2.0.20 (Visual Studio Enterprise Trial)

=== Build Information ===

Release ID: 603000834
Git revision: bb1dff522ee38d9963b4d97f6cfa0f92c85e8ecb
Build date: 2017-03-14 13:38:37-04
Xamarin addins: 8aac7919dc66c1ce0d9d75fe150ddc1ab15fd941
Build lane: monodevelop-lion-d15-1

=== Operating System ===

Mac OS X 10.12.3
Darwin NAG1-DMAC-26706 16.4.0 Darwin Kernel Version 16.4.0
    Thu Dec 22 22:53:21 PST 2016
    root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

Attached Logs and Build output stacktrace

Screencast Link : https://www.screencast.com/t/74CG4wFnJ