On 12/04/14 05:04 AM, Jeremy Ong wrote:
> I am considering authoring a webserver (think nginx, apache, cowboy,
> etc) in Rust. From a user point of view, mapping tasks (green) to web
> requests makes the most sense as the tasks could be long running,
> perform their own I/O, sessions, or what have you. It would also allow
> the user to do per-request in memory caching.
> 
> My main concern is obviously the cooperative scheduler. Given that the
> mantra of Rust seems to be safety, I'm curious about how feasible it
> would be to provide the option for task safety as well. Preemptive
> scheduling provides two things:
> 
> 1. If preemption is used aggressively, the user can opt for a lower
> latency system (a la Erlang style round robin preemptive scheduling)
> 2. Preemption of any sort can be used as a safety net to isolate bugs
> or blocks in tasks for long running systems, or at least mitigate
> damage until the developer intervenes.
> 
> I noticed in issue 5731[1] on the repo, it was pointed out that this
> was possible, albeit difficult. The issue was closed with a comment
> that the user should use OS threads instead. I really think this
> misses the point as it no longer allows preemption on a smaller
> granularity scale. Could any devs chime in on the scope and difficulty
> of this project? Could any users/devs chime in on any of the points
> above?
> 
> tl;dr I think preemptive scheduling is a must for safe concurrency in
> long running executables at the bottom of the stack. Opinions?
> 
> 
> [1] https://github.com/mozilla/rust/issues/5731

Native threading is the default and provides preemption. The argument
for including green threads is the potential to increase performance by
eliminating context switches, and that evaporates if the compiler needs
to insert yield points at loop edges.

The same compiled code supports both native and green threading, so
you're asking for *everyone* to pay the cost of this feature whether or
not they're going to use it. Rust's goal is to be a viable systems
language, and it won't be one if there's the cost of yield checks. The
name of the game is "pay for what you use" and in my opinion any feature
breaking that rule to this extent is a no go.

It could be a compile-time flag, but the libraries shipping with Rust
are not going to be compiled with it... so it would always involve
someone building their own Rust compiler / libraries.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to