[Mono-dev] High CPU usage in System.Thread.Sleep on OS X after v. 4.3.2

Zoltan Varga vargaz at gmail.com
Fri Sep 9 01:24:34 UTC 2016


Hi,

Filed as:

https://bugzilla.xamarin.com/show_bug.cgi?id=44132

         Zoltan

On Thu, Sep 8, 2016 at 4:16 PM, Emil Sandstø <emil at fusetools.com> wrote:

> There has been a CPU performance regression in between the release of
> 4.3.2 and 4.4.0, on OS X when using System.Threading.Sleep. It's pretty
> critical, we are talking about order of magnitude difference in performance
> between those versions. Also it has been reproduced on more than one
> machine that runs either El Capitan or Sierra, but not tested on earlier OS
> X versions.
>
> I have made a code snippet that triggers the regression:
> https://gist.github.com/Tapped/b4c0df072b2ff6fd38c6c4aff55d4669
> It creates a thread that sleeps for one millisecond continuously in a loop.
>
> # Profile data
> When running the test in version 4.4.0 or higher the CPU usage is around
> 60 % of a core on my machine. However when running 4.3.2 or earlier
> versions, the CPU usage is around 2-3 % of a core, which is as expected.
> Furthermore, I've found that the bottleneck is pretty deep in Mono.
>
> This is profile data from running 4.3.2:
> https://az664292.vo.msecnd.net/files/TOfPF56ct1ePQsdN-
> Screen%20Shot%202016-09-08%20at%2015.34.14.png
>
> And this is profile data from running 4.4.0:
> https://az664292.vo.msecnd.net/files/6To3h9tsG0DXzxFQ-
> Screen%20Shot%202016-09-08%20at%2015.35.03.png
>
> What I'm find interesting is how much more time which is spent in
> 'pthread_cond_wait' in version 4.4.0 than in 4.3.2.
> To be more specific, in 4.4.0 'pthread_cond_wait' calls __gettimeofday
> which is where most of the CPU time is used.
> And in 4.3.2 that internal method in pthread_cond_wait isn't called at
> all.
>
> # Steps to reproduce
> 1. Download and install http://download.mono-project.
> com/archive/4.3.2/macos-10-universal/MonoFramework-MDK-4.
> 3.2.macos10.xamarin.universal.pkg
> 2. Build and run my test code (https://az664292.vo.msecnd.
> net/files/VHeBcT7ZrmA5siqf-TestSleep.zip)
> 3. Take a note of the "average" CPU usage.
>
> 4. Download and install http://download.mono-project.com/archive/4.4.0/
> or a later version (same issue on 4.6.0 as well)
> 5. Build and run my test code (https://az664292.vo.msecnd.
> net/files/VHeBcT7ZrmA5siqf-TestSleep.zip)
> 6. Take a note of the "average" CPU usage and compare to what you found in
> 4.3.2.
>
> I would like someone with more knowledge of the mono codebase to take a
> look at this issue. I'm also available to test patches in our production
> codebase, for end-to-end testing.
>
> Thanks!
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.dot.net
> http://lists.dot.net/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20160909/b72088a6/attachment-0001.html>


More information about the Mono-devel-list mailing list