views:

435

answers:

2

Hi,

What are the main performance overheads (gc/stack copying...) of the new Mono Continuations/Tasklet framework?

How does this overhead (coroutine performance / raw performance) compare to other frameworks such as Lua Coroutine and stackless python?

In Mono 2.6 continuation/coroutines support will be added. I built a svn version and used the following code to estimate its overhead

static void Main()
{
    Console.WriteLine("starting.,..");
    for(int i = 0; i < 10000; i++)
    {
        MicroThread t1 = new MicroThread(Run1);
        t1.Start();
    }
    Scheduler.Run();
    Console.WriteLine("starting raw loop.,..");
    int x = 2;
    for (int i = 0; i < 10000 * 400; i++ )
    {
        x++;
    }
    Console.WriteLine("1finished.,.. " + x.ToString());
    Console.ReadLine();
}

static void Run1()
{
    for (int y = 0; y < 400; y++)
    {
        MicroThread.CurrentThread.Yield();
    }
}

The microthread/scheduler run took around 1.5-2 seconds, while the raw loop is nearly instantenously. While an overhead is expected, this seems a bit much.

What are the main performance overheads of the new Mono Continuations/Tasklet framework? How does this overhead (coroutine performance / raw performance) compare to other frameworks such as Lua Coroutine and stackless python?

Thanks

+3  A: 

Given that there are very few people with the expertise to answer this, you may have to go to them, and ask on the mono-devel list.

You can also look at the archives to see the discussion around monoco/tasklet when it was introduced:

http://lists.ximian.com/pipermail/mono-devel-list/2009-April/031680.html

jpobst
Yea probably a good suggestion.
jameszhao00
Thank you for that link. I took a look and unfortunately mono continuations is the stack copying kind, not the stack pointer kind.
jameszhao00
+5  A: 

If I didn't count wrong, your code does more than 2 million yields per second, which should be roughtly in the same ballpark as stackless python.

Considering that mono will usually execute the real application code 10 to 100 times faster than python, the performance is likely going to be very good unless all your code does is yield without ever doing any real work, which I don't think is very useful:)

lupus