Mono Tasklet/协同例程的开销
新的 Mono Continuations/Tasklet 框架的主要性能开销(gc/堆栈复制...)是什么?
与其他框架(如Lua Coroutine 和 stackless python?
在 Mono 2.6 中将添加延续/协程支持。我构建了一个 svn 版本,并使用以下代码来估计其开销。
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();
}
}
微线程/调度程序运行大约需要 1.5-2 秒,而原始循环几乎是即时的。虽然预计会有开销,但这似乎有点多。
新的 Mono Continuations/Tasklet 框架的主要性能开销是什么?与 Lua Coroutine 和 stackless python 等其他框架相比,这种开销(协程性能/原始性能)如何?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我没算错的话,你的代码每秒的产量超过 200 万次,这应该与 stackless python 大致相同。
考虑到 mono 通常执行实际应用程序代码的速度比 python 快 10 到 100 倍,性能可能会非常好,除非你的所有代码所做的只是产生而不做任何实际工作,我认为这不是很有用:)
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:)
鉴于具有专业知识来回答这个问题的人很少,您可能必须去找他们,并在单一开发列表上询问。
您还可以查看档案以查看有关 monoco/tasklet 引入时的讨论:
http://lists.ximian.com/pipermail/mono-devel-list/2009-April/031680.html
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