Bug 1716 - profiler makes the code to run 6 times faster
Summary: profiler makes the code to run 6 times faster
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: PC Linux
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-10-27 06:12 UTC by Marek Safar
Modified: 2016-04-16 08:24 UTC (History)
4 users (show)

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 GitHub or Developer Community 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:

Description Marek Safar 2011-10-27 06:12:58 UTC
Requires mono master

using System;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;

namespace test6
	class MainClass
		static int iii;
		async static Task AsyncTest ()
			int b = await Task.Factory.StartNew (() => { return iii; });
		public static void Main (string[] args)
			var sw = new Stopwatch ();
			sw.Start ();

			for (int i = 0; i < 100000; ++i) {
				iii = i;
				var t = AsyncTest();
				t.Wait (999999);

			sw.Stop ();
			Console.WriteLine (sw.ElapsedMilliseconds);

5 normal runs on amd64/4 cores

5 runs with profiler as rm output.mlpd && mono --profile=log test.exe
Comment 1 Zoltan Varga 2011-11-04 13:58:13 UTC
This has nothing to do with the profiler, adding a Console.WriteLine ("A") after t.Wait () also makes it faster.
Comment 2 Zoltan Varga 2011-12-02 21:48:34 UTC
-> class libs.
Comment 3 Rodrigo Kumpera 2011-12-03 22:46:28 UTC

This is again our BROKEN threadpool that does no throughting and spins threads like there's no tomorrow. I bet this runs slower on sgen, due to issues mentioned before.

Reporting bugs on tp code using artificial benchmarks such as this one is a waste of time because it's well known and you already filled half a dozen dupes.
Comment 4 Gonzalo Paniagua Javier 2012-01-10 16:17:18 UTC
I don't such a large difference (~9500 boehm vs ~8700 sgen).
Comment 5 Gonzalo Paniagua Javier 2012-01-10 16:18:10 UTC
Btw, I have master + Rolf's GC/TP patch
Comment 6 Gonzalo Paniagua Javier 2012-02-10 02:28:17 UTC
Still can't reproduce this. Anyone else?
Comment 7 Marek Safar 2016-04-16 08:24:04 UTC