I am experimenting with akka / scala 2.10.3 on an Ubuntu 12.04 system running an AMD Quad-Core processor.
I have written a server that should perform some computation when it receives a request. A client will send some data (list of strings) using an actor message. When the actor on the server receives the list, it splits it into four lists and has four child actors sort the list.
So far so good: the program works and I could verify that the client receives a correctly sorted list as a result.
There are however two things I do not understand in the behaviour of the server:
- As soon as I start the server, even though no actor is doing any processing (they are all are waiting for messages), all the four cores of my processor go up to almost 100% usage. How is this possible? Shouldn't the cores only be used when some actors are scheduled to process some messages?
- I had expected that having the work done by four actors would automatically imply that the sorting would be sped up by a factor of four: each actor is run in a separate thread, and each thread is run by a different core. However, this is not the case: no speed-up observed or, even, the actor-based sorting is much slower than a plain single-threaded sort. Can the cause be my dispatcher configuration, i.e. the default configuration does not exploit multiple cores automatically?
Edit
Following Dan Simon's suggestions, I have looked into problem 1 using visualvm
.
visualvm
reports several dispatcher threads that are waiting most of the time (so they do not seem to use much CPU time).
visualvm
also shows several other threads that are running all the time, even though the application is not doing anything; at least, none of my code is being executed. These busy threads are named New I/O worker #1, #2, #4, #5
, New I/O boss #3
, New I/O server boss
, Signal Dispatcher
, RMI TCP Connection(2)-127.0.0.1
, Attach Listener
, and RMI TCP Accept-0
.
I have some experience programming akka but almost no experience configuring it, so I cannot make much sense out the above information.