Le 11/07/2012 03:41, Sebastian Sylvan a écrit :
> On Tue, Jul 10, 2012 at 6:05 PM, Brian Anderson <[email protected]> wrote:
>> Tasks do have a memory cost, but it is theoretically quite low. Rust tasks
>> on linux currently have somewhere around 4K of overhead, and that's around
>> 3K more than we would like and think is possible. Most of that is dedicated
>> to the call stack, and there are a lot of potential future optimizations to
>> minimize the cost of creating a task (by e.g. reusing them). The intent is
>> that you should not have to think about whether using a task is too
>> expensive, because it is cheap.
> It would be cool if tasks started out more like PPL/TBB/Cilk tasks and
> transitioned into the current thread-like construct and allocated
> stack space only if needed.
That's probably a good step towards the middle ground I mentionned earlier.

> I.e. the first time a task needs to yield
> its underlying "worker thread" (because it's about to block) it would
> go through the work of allocating a stack (and heap?) and copy its
> state into it. This would make task-parallel type things very cheap
> since in that scenario most tasks would just run to completion on the
> worker thread's task (and heap?), while still allowing you to use the
> same mechanism for longer running tasks.
+1. The point is that there is a maximum number of processors (let's be
honest, 2, 4 or 8 in current machines, maybe 16 soon, but we're not
there yet), so spawing thousands of tasks and creating thousands of
stacks that may need to be moved around and require scheduling is a
clear waste of resources.
Assigning concurrent tasks to the different processors (if things can
run in parallel) with run-to-completion sounds more reasonable. And as
you said if all the tasks being processed really take too long, then do
some preemption and stack allocation to run a new task.

> Tasks which have a clear
> non-avoidable yield point in them could just allocate all this
> up-front of course. Maybe this is a bit too magical and there should
> just be a different task-like concept that maps better to
> task-parallelism.
What's a yield point? How do you create one in Rust?

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

Reply via email to