Bug 27902 - Threading and Timers shows degraded performance over time on Mac
Summary: Threading and Timers shows degraded performance over time on Mac
Status: RESOLVED ANSWERED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.10.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 2.4.0 (C6)
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2015-03-11 14:01 UTC by James
Modified: 2015-03-27 14:29 UTC (History)
4 users (show)

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


Attachments
Sample of Issue (20.76 KB, application/zip)
2015-03-11 14:01 UTC, James
Details
Sample Console output displaying the change in results over time (2.31 KB, text/plain)
2015-03-11 14:04 UTC, James
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:
RESOLVED ANSWERED

Description James 2015-03-11 14:01:11 UTC
Created attachment 10272 [details]
Sample of Issue

Attached project exhibits the issue:

In the AppDelegate.cs file, there is a System.Timers.Timer object to log a message to the console every 5 seconds, and then also create a task that sits in a loop that calls Task.Delay(5000). Initially everything is fine but after 10-15 loops, they begin taking 15 seconds and eventually they both seem to return from sleep/get called simultaneously at 15 second intervals. 

I can reproduce this with JUST the timer or task, but wanted to demonstrate that it effects more than just one type of timer.
Comment 1 James 2015-03-11 14:04:46 UTC
Created attachment 10273 [details]
Sample Console output displaying the change in results over time
Comment 2 James 2015-03-11 14:24:27 UTC
I just realized the project is referencing MonoMac, and is not part of the unified API. Upon upgrading this issue is no longer exhibited. This can be closed
Comment 5 Timothy Risi 2015-03-25 15:31:05 UTC
I've been unable to reproduce this on XM 1.12.0.14 using the attached sample.  Could you test it out again and see if you're still having issues with it?
Comment 6 Josh Ferguson 2015-03-25 16:29:57 UTC
I just updated to 5.8.2 in the alpha channel and can still reproduce the issue. Here's my info:

Xamarin Studio
Version 5.8.2 (build 5)
Installation UUID: 3ecdda6d-fd0e-4e5d-bafa-e96dee903a6d
Runtime:
	Mono 3.12.1 ((detached/b63df7d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010002

Apple Developer Tools
Xcode 6.2 (6776)
Build 6C131e

Xamarin.iOS
Version: 8.8.2.2 (Starter Edition)
Hash: f5d0c5e
Branch: 
Build date: 2015-03-20 06:51:49-0400

Xamarin.Android
Version: 4.20.1.0 (Starter Edition)
Android SDK: /Users/joshferguson/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.4   (API level 19)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Xamarin Android Player
Not Installed

Xamarin.Mac
Version: 1.12.0.14 (Trial Edition)

Build Information
Release ID: 508020005
Git revision: 541c06a4f6c95383333375d56fd6c23ce48cb916
Build date: 2015-03-20 09:23:08-04
Xamarin addins: 02510c4990dee3475c282b3182d588975a63ff07

Operating System
Mac OS X 10.10.3
Darwin Retina-MacBook-Pro.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 16 23:12:31 PDT 2015
    root:xnu-2782.20.48~4/RELEASE_X86_64 x86_64
Comment 8 James 2015-03-26 15:50:49 UTC
It appears app nap was affecting perforance

_activity = NSProcessInfo.ProcessInfo.BeginActivity(NSActivityOptions.Background | NSActivityOptions.LatencyCritical, "GoDriveProcessing”);

appears to smooth out behavior and run without the delay after a time.
Comment 9 Chris Hamons 2015-03-27 14:29:46 UTC
I believe ^ solves your issue. Please reopen if you have additional questions on this issue.