> Will Dart utilize multiple CPU cores, and how does a program achieve that. (Eg. Does a program need to create Isolates to achieve that)?
As far as I know, yes, isolates are the only way to go multicore with Dart.
LT
I initially looked at Dart as a JS replacement, and it does an absolutely brilliant job of satisfying that criteria. Then, I looked at some server-side coding, and found that it is extremely fast, so I started thinking about using server-side Dart as well. Then, I read recently that Dart compares well to Java in some benchmarks, however I don't know if that means utilizing multiple cores. While I would like to use Dart for both client-side and server-side, I am unsure as to what level it will perform that role. In terms of high-performance server with a lot of demand from the client-side, can Dart compete with other well-established and emerging languages? eg. C#, Java, Go? I have completed some tests doing batch-type RDBMS access, and Dart running a test program from multiple command-line processes, and performed extremely well. However that test does not show how the performance is shared across CPU's, because the O/S by virtue of running multiple processes would do that, and so would the RDBMS. Will Dart utilize multiple CPU cores, and how does a program achieve that. (Eg. Does a program need to create Isolates to achieve that)?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
> The current implementation uses a separate thread to run epoll/kqueue/etc.
Sounds like there might be a lot of copying involved, or are you trying to avoid that too?
> However, in the current implementation, a Socket is bound to a single isolate. To overcome this limitation, we'd like to introduce the ability to transfer Sockets between isolates
Is this going to be specific to sockets, or are we introducing "transferables"?
LT
P.S.: looks like you are doing a lot of awesome work. Hope that my questions don't sound like I don't appreciate it :-)
> The current implementation uses a separate thread to run epoll/kqueue/etc.Sounds like there might be a lot of copying involved, or are you trying to avoid that too?
> However, in the current implementation, a Socket is bound to a single isolate. To overcome this limitation, we'd like to introduce the ability to transfer Sockets between isolates
Is this going to be specific to sockets, or are we introducing "transferables"?
LT
P.S.: looks like you are doing a lot of awesome work. Hope that my questions don't sound like I don't appreciate it :-)
When a worker is started on a given message, it may execute a lot of async commands. How can I re-use the Isolate for another request while it's blocked in the current request???
If those commands are async, then it won't be "blocked" on the current request at all. Each time it starts an async operation, it will return control back to the event loop which can then start responding to other requests when new ones come in.
If a worker Isolate receives a new ClientMessage (from the main Isolate), it cannot register itself as available until it's finished with the current request, which could include a lot of async commands.
Quinta-feira, 23 de Maio de 2013 17:11:46 UTC+1, Bob Nystrom escreveu:If those commands are async, then it won't be "blocked" on the current request at all. Each time it starts an async operation, it will return control back to the event loop which can then start responding to other requests when new ones come in.We are in a worker Isolate. It doesn't directly receive new requests. The main Isolate gets all or most new requests and re-routes them to worker isolates when they're not currently running a previous request.If a worker Isolate receives a new ClientMessage (from the main Isolate), it cannot register itself as available until it's finished with the current request, which could include a lot of async commands. We have no way to re-use a working Isolate when it's waiting for futures within its current request.
Dart is looking great for stateless HTTP requests (provided we use Apache or Nginx), way better than PHP, Node.js or any other single-threaded environment. Isolates are more than enough in this case.But I think we need another approach for concurrent real-time applications. I don't think we can compete with Java or .NET on that front.Shared-state task/thread queue are kind of a standard for high performance.
--
is hyper threading really a big deal? afaict, if you are in the need of massive hyper threading, you'd be better of with an opencl binding / analogue of webcl.
Quinta-feira, 23 de Maio de 2013 18:08:09 UTC+1, Don David Alegria escreveu:is hyper threading really a big deal? afaict, if you are in the need of massive hyper threading, you'd be better of with an opencl binding / analogue of webcl.
Le's say you write a multiplayer game server, you'll probably setup a virtual server to host it, so it can scale independently of other apps.
If your game gets even little success (on a global scale), with a single processor, even the most powerful you can find, it won't scale.
You will need to assign more processors to your virtual server to successfully scale.
So yes, multi-threading IS a big deal, specially in server-side.
>> But I think we need another approach for concurrent real-time applications.
In such cases, I recommend to get acquainted with the already accumulated experience.Concurrent interaction and communication.Explicit communication can be divided into two classes:1. Shared memory communication2. Message passing communication
>> Shared-state task/thread queue are kind of a standard for high performance.
Can you explain what you mean by that?1. Shared-state2. Thread queueShared memory requires the application of some form of locking (e.g., mutexes, semaphores, or monitors) to coordinate between threads.Is that what you want?
>> So we end-up assigning heavy work to apps written in another language because Dart can't.
No problem here. Run any number of isolates as you wish.Each isolate will be run in parallel (may be in different thread).But there will be no shared memory.Your isolates can communicate with each other through messages.You may create your own message service and use it as shared object.Inside each isolate code executed without concurrency with one common state.
>> With transferable arrays which may land in dart at some point (and please soon) you can send large amount of bytedata across isolates with zero copies (it just transfers the pointer to the array)
In javascript in web browser also?
>> So we end-up assigning heavy work to apps written in another language because Dart can't.
No problem here. Run any number of isolates as you wish.Each isolate will be run in parallel (may be in different thread).But there will be no shared memory.Your isolates can communicate with each other through messages.You may create your own message service and use it as shared object.Inside each isolate code executed without concurrency with one common state.
>> With transferable arrays which may land in dart at some point (and please soon) you can send large amount of bytedata across isolates with zero copies (it just transfers the pointer to the array)
In javascript in web browser also?
Quinta-feira, 23 de Maio de 2013 18:12:54 UTC+1, mezoni escreveu:>> But I think we need another approach for concurrent real-time applications.In such cases, I recommend to get acquainted with the already accumulated experience.Concurrent interaction and communication.Explicit communication can be divided into two classes:1. Shared memory communication2. Message passing communication>> Shared-state task/thread queue are kind of a standard for high performance.Can you explain what you mean by that?1. Shared-state2. Thread queueShared memory requires the application of some form of locking (e.g., mutexes, semaphores, or monitors) to coordinate between threads.Is that what you want?
Yes, it's what I want.
Without shared memory, I would have to use a DB server as a shared state-holder, because DB servers CAN perform true concurrency.
So we end-up assigning heavy work to apps written in another language because Dart can't.
--
It's not that Dart can't, it's that Dart has an actor-like concurrency model, but there hasn't been a lot of emphasis on writing the necessary frameworks to use it easily yet, the focus has been on web apps so far.
>> It's also that isolates are still pretty heavy. Erlang shows that actors can be super-awesome, if they are super-cheap. Right now, isolates in Dart are neither.
Heavy on which?1. Creation, initialization2. Consume many memory3. Long time for switching context
There are two kind of isolates.1. spawn uri2. spawn functionBoth heavy?
This is generally the much easier method to use, as you can also allow Apache/Nginx/etc to serve the static content much easier, and only forward your ajax calls for instance. This is the path I'm working towards for my apps. To get a 'comfortable' proxy configuration to allow me to write less dart server code, so I only need to worry about the logic stuff and not the static content which is much better optimized than what I want to work on for each of my projects.
On Thursday, May 23, 2013 7:17:44 AM UTC-3, Greg Lowe wrote:Another approach is to run multiple Dart HttpServer processes behind Apache or Nginx configured as a reverse proxy. I understand this is typically how node.js is deployed in production systems.
From what they say, it follows that processor can copy memory internally at the rate of about 200MB/sec.
This doesn't make sense. Try the following experiment: create 200 MB file (note: FILE, not memory block), and read it in dart. It will take 0.3 sec on lousy hardware.
The solution depends on the problem which depends on the other solution.
If your solution is having all game data as shared data (maybe object coordinates for MMO), then isolates might not be the solution even with transferable sockets.
Wonder if it wouldn't be better single-threaded.
--
> >> It's also that isolates are still pretty heavy.
>
> Right. And always will be.
Not necessarily. Isolates in Dart will probably never be as cheap as actors in Erlang (overhead of cca 300 bytes), but they are supposed to be quite lightweight. In https://code.google.com/p/dart/issues/detail?id=5006, Lars says "It will take some time before isolates in the VM are minimal (a few KB)". If we get the overhead down to few kBs, then we are fine.
> Because for every new isolate cloned the entire global context.
You can't do anything with that. If you want to run large programs in all isolates, you can't have a lot of them. However, if you want to run a lot of small programs, each in its own isolate, then currently, the overhead of isolates will easily dominate the entire price of the system. Look at the commit message of https://code.google.com/p/dart/source/detail?r=23115 which implemented diet parsing of classes -- they have some encouraging numbers there for the initial memory usage.
> The threads are very lightweight
Surely you must be kidding here? The overhead of threads is pretty huge. Sure, modern OSes can maintain tens of thousands of threads, but if you try to use so many threads in your program, then the price of context switch will kill you. On the other hand, you can easily have a million of actors in an Erlang program without a sweat (and I think that Akka will give you similar numbers on the JVM, but it's a long time since I looked at the numbers).
Of course threads and actors are not directly comparable, they are two different worlds, but still.
LT
>> If we get the overhead down to few kBs, then we are fine.
I also love to dream.Why do you link to other people's dreams?
>> If you want to run large programs in all isolates, you can't have a lot of them.
You not understand. This is not my problem that I want.This is a problem of 'isolate' model. They so constructed. They not effective in this case.If in large program I want run a lot of 'small task' in parallel then we have great overhead.This is because each 'isolate' clone entire context of all program.The 'isolate' based on that principle. It always create another 'big program' in each case.
>> No it doesn't. You don't have to clone the entire program (spawnFunction), you can run a completely new one (spawnUri).
You are sure?This example run task in parallel, It use 'spawnFunction'.Each task (not task but isolate) create 'new big program'.
Please explain me about what you speaking... that not required cloning of all constants and global variables.
--
You want to say if 'isolate' created in 'spawnUri' the code that executed in this isolate does not have global variables (execution context)?
Did we start petitioning for support of data: uri yet? We discussed it briefly, but I can't find open issue for this.
>> This one looks relevant: https://code.google.com/p/dart/issues/detail?id=10733 I'm starring it right now.
Eval?
>> It's also that isolates are still pretty heavy.Right. And always will be.
Because for every new isolate cloned the entire global context.
Did we start petitioning for support of data: uri yet? We discussed it briefly, but I can't find open issue for this.This one looks relevant: https://code.google.com/p/dart/issues/detail?id=10733 I'm starring it right now.
On Sat, May 25, 2013 at 9:46 AM, Ladislav Thon <lad...@gmail.com> wrote:
Did we start petitioning for support of data: uri yet? We discussed it briefly, but I can't find open issue for this.This one looks relevant: https://code.google.com/p/dart/issues/detail?id=10733 I'm starring it right now.There was an older almost identical one in http://dartbug.com/5187I just closed 10733 as a dupe and updated the title of 5187. You probably want to start 5178 now.