Haskell软实时状态 [英] Current state of Haskell soft real-time

查看:117
本文介绍了Haskell软实时状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑Haskell的软实时应用程序。我可能会使用演员,因为它是值得的。我想知道是否有人可以通过Haskell洞察当前的实时状态。特别是,GC暂停应用的问题。我已经广泛使用谷歌搜索,并且在2年前我发现了很多讨论,但没有任何最新消息。以下是我找到的几个参考资料:





Haskell的软件实时应用程序的GC性能如何? / b>

我读过的大部分旧内容都表明情况(当时)被认为正在改善。有吗?

甚至2年前,有一些评论建议可以调整Haskell应用程序以可靠地将GC暂停减少到一两毫秒。这样看起来是否真实? 所以对实时的关注是GC集合引入的延迟。



GHC使用多核垃圾回收器(并且有分支每线程本地堆栈)。最初为提高多核性能而开发(每个核心可独立收集)通过降低频繁停止世界同步的成本,这种情况也会因同样的原因而受益于软实时。然而,截至2013年,每线程本地堆还没有合并到主要的GHC中,尽管并行GC已经完成。



对于游戏,您应该能够通过使用线程来利用这一点,从而减少对停止世界本地集合的需求。



对于长期存在的对象,在全局堆中,仍然存在风险一些(毫秒)GC。然而,仔细地用例如 ThreadScope 将在这里消除障碍。我已经看到实时1080p视频流通过GHC管理的网络堆栈,而没有明显的GC暂停。



即使没有这些优化,事情可能会奏效。 Frag几乎不需要优化,现在已经有近10年了。


$ b

然后就是编码:使用unboxed类型(无GC),最小化惰性结构分配。以打包的形式保存长时间的数据。测试和基准测试。



我认为你会好的。


I'm considering Haskell for a soft real-time app. I will likely use actors, for what it's worth. I'm wondering if anyone has insight into the current state of real-time with Haskell. Specifically, issues with the GC pausing the app. I've Googled extensively, and I've found a great deal of discussions from 2+ years ago, but nothing current. Here are a couple of the references I've found:

Using Haskell for sizable real-time systems: how (if?)?

How about Haskell's GC performance for soft realtime application like games?

Much of the older stuff I've read suggests that the situation was (at the time) thought to be improving. Has it?

Even 2+ years ago, there were a few comments suggesting Haskell apps could be tuned to reliably keep GC pauses down to a millisecond or two. Does this seem realistic?

解决方案

So the concern for "real time" is the latency introduced by GC collections.

GHC uses a multicore garbage collector (and there is a branch with per-thread local heaps). Originally developed to improve multcore performance (each core can collect independently) by reducing the cost of frequent stop-the-world synchronisation, this happens to also benefit soft-real time for the same reason. However, as of 2013, the per-thread local heap has not yet been merged into main GHC, although the parallel GC has been.

For a game you should be able to exploit this, by using threads, and thus reducing the need for stop-the-world local collections.

For long lived objects, in the global heap, you still risk some (ms) GC. However, careful profiling with e.g. ThreadScope will remove obstacles here. I've seen real time 1080p video streamed through a GHC-managed network stack without noticeable GC pauses.

And even without these tuneups, things "might just work". Frag needed almost no optimization, and was soft realtime nearly 10 years ago now.

Finally, there are many tools and GHC flags to improve performance:

And then there is coding: use unboxed types (no GC), minimize lazy structure allocation. Keep long lived data around in packed form. Test and benchmark.

I think you'll be fine.

这篇关于Haskell软实时状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆