简体   繁体   English

为什么Rust会删除绿色线程模型; 有什么缺点?

[英]Why did Rust remove the green-threading model; what's the disadvantage?

Runtime freedom: Rust's runtime system and green-threading model has been entirely removed, which cut the static binary size of “hello world” in half and has opened the door to lower-level hooks into the standard library. 运行时自由:Rust的运行时系统和绿色线程模型已被完全删除,它将“hello world”的静态二进制大小减少了一半,并打开了通向标准库的低级钩子的大门。 Implemented by Aaron Turon. 由Aaron Turon实施。

http://blog.rust-lang.org/2015/01/09/Rust-1.0-alpha.html http://blog.rust-lang.org/2015/01/09/Rust-1.0-alpha.html

What's the disadvantage of the green-threading model? 绿色线程模型的缺点是什么?

Why is Erlang so fast? 为什么Erlang这么快?

Erlang uses green threads with preemption. Erlang使用带有抢占的绿色线程。 This is possible only because Erlang has a VM, which also allows a lot of other things like code hotswap. 这是可能的,因为Erlang有一个VM,它还允许很多其他的东西,比如代码hotswap。 But languages with VM are unsuitable for systems programming because they always have some constant overhead, both in memory and processing power. 但是具有VM的语言不适合系统编程,因为它们在内存和处理能力方面总是有一些不变的开销。 Rust is a systems programming language, and so it cannot have a significant runtime system. Rust是一种系统编程语言,因此它不具备重要的运行时系统。 I'd also add that Erlang is not fast . 我还要补充一点,Erlang并不 It is notoriously ineffective in numerical computations, for example - see here . 例如,在数值计算中它是无效的 - 见这里 Its concurrency model allows for high throughput for I/O operations, but this is a different thing. 它的并发模型允许I / O操作的高吞吐量,但这是另一回事。

So in order to support green threads in a feasible way a language has to have some kind of runtime. 因此,为了以可行的方式支持绿色线程,语言必须具有某种运行时。 The reasons of runtime removal in Rust are outlined in the corresponding RFC . Rust中运行时删除的原因在相应的RFC中列出。 In short, the runtime model used in Rust at that time was difficult to work with efficiently and hard to improve, while not having sufficient benefits due to implementation problems and general constraints due to the API, so it was scrapped. 简而言之,Rust当时使用的运行时模型很难高效地工作,难以改进,而由于API的实现问题和一般约束而没有足够的好处,所以它被废弃了。 As far as I know, nothing in principle prevents someone from writing a green thread-based runtime for Rust, just no one did that yet. 据我所知,原则上没有任何东西可以防止有人为Rust编写一个基于绿色线程的运行时,但还没有人这么做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM