|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
actor performance question
by Eric Brown-17
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message Hi,
I'm developing a server and want to use the actor loop-react pattern with non-blocking network i/o. It should be faster than one-thread per connection. However, my first test is to just see how long it takes to switch back-and-forth between two actors 1 million times. The interesting bit is that when I do the same thing with stackless python and coroutines, python is much faster. On my system (a macbook pro/Leopard's JDK 1.5), stackless python takes 0.6 seconds while scala takes about 15 seconds. Can anybody tell me if there is anyway to make the following faster? import scala.actors.Actor import scala.actors.Actor._ case object Msg case object Done class FirstActor(count: int, other: Actor) extends Actor { def act() { var start = System.currentTimeMillis() var cnt = count loop { react { case Msg => cnt = cnt - 1 if (cnt != 0) { other ! Msg } else { var duration = System.currentTimeMillis() - start Console.println("Done in " + duration) exit() } } } } } class SecondActor extends Actor { def act() { loop { react { case Msg => sender ! Msg } } } } object SwitchTest { def main(args : Array[String]) : Unit = { var a2 = new SecondActor var a1 = new FirstActor(1000000, a2) a1.start a2.start a1 ! Msg } } |
|
|
Re: actor performance question
by stephaneLeDorze
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message Is also scala slower with, say, 10000 Actors and 10000 exchanges?
Was the startup time considered? As far as I know Python coroutine (almost know nothing about it) I think Actor can receive and select the matching messages whereas Python coroutines doesn't provide the same abstraction.. Stephane On Jan 7, 2008 10:03 AM, Eric Brown <yogieric.list@...> wrote: Hi, |
| Free embeddable forum powered by Nabble | Forum Help |