Erlang 对 F# 中并发性的承诺

发布于 2024-09-25 12:35:29 字数 113 浏览 1 评论 0原文

Joe Armstrong 先生表示,使用 Erlang,我们可以让 N 个核心的顺序代码运行速度提高 N 倍。这也适用于 F# 吗?或者Erlang VM就是这样设计的? F# 是否管理操作系统或语言中的进程?

Mr Joe Armstrong says that with Erlang we might have sequential code running N times faster with N cores. Does this apply to F# also? Or is the Erlang VM designed in that way? Does F# manage processes in the OS or language?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

相思碎 2024-10-02 12:35:29

F# 中的 MailboxProcessor 类型(请参阅 MSDN 文档) 实现了与 Erlang 基本相同的基于代理的并发模型。唯一的区别是Erlang更适合分布式计算(跨多台计算机),而F#使用主要在单机上(但多线程/核心)的编程模型。

总的来说,我认为关于 Erlang 的说法也适用于 F#。

关于引用:我不太确定作者到底想说什么(也许缺少一些上下文?)。这当然并不意味着您可以采用通常的(顺序)程序并神奇地以 N 倍的速度运行它。

但是,如果您使用 Erlang 或 F# 基于 agnet 的并发编程模型,那么每个额外的核心都可以带来加速。这意味着您将把程序编写为大量代理(F# 中的 MailboxProcessor 实例)。 单个代理被编写为顺序子程序,但您仍然需要以不同的方式考虑编程。

技术方面:Erlang 不使用物理操作系统线程,F# 也不使用,因此行为应该非常相似。这意味着您可以创建大量代理(这是编程模型的要点)。 F# 中的代理基于异步工作流,这使得这成为可能。

The MailboxProcessor type in F# (see MSDN docs) implements essentially the same agent-based concurrency model as Erlang. The only difference is that Erlang is more suitable for distributed computing (across multiple computers), while F# uses the programming model mainly on a single machine (but multiple threads/cores).

In general, I think that claims about Erlang would also apply to F#.

Regarding the quote: I'm not quite sure what the is the author exactly trying to say (maybe there is some context missing?). It certainly doesn't mean that you can take usual (sequential) program and run it magically N times faster.

However, if you use the programming model of Erlang or F# agnet-based concurrency then you can get a speedup with every additional core. This means that you'll write the program as a large number of agents (instances of MailboxProcessor in F#). Individual agents are written as sequential sub-programs, but you still need to think about programming differently.

Technical aspects: Erlang doesn't use physical OS threads and neither does F#, so the behavior should be very roughly similar. This means that you can create a large number of agents (which is the point of the programming model). Agents in F# are based on asynchronous workflows, that make this possible.

你げ笑在眉眼 2024-10-02 12:35:29

添加核心只会提高应用程序的速度,前提是应用程序的并发程度足以使用它们,请参阅阿姆达尔定律< /a>.正确使用 Erlang 可以更轻松地以这种方式构建应用程序,因为并发性既简单又便宜。

Adding cores will only improve the speed of your application if it is concurrent enough to use them, see Amdahl's Law. Using Erlang properly makes it easier to build apps in this way as concurrency is simple and cheap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文