Continuation of #17. In the random graphs benchmark, actors can do 5 things:
Spawn actors
Send a ref from one actor to another
Release refs to actors
Send application messages to actors
Do nothing
Each of these actions should have a configurable probability that is less than 1.
Whenever an actor gets a message, it generates M random numbers between 0 and 1 (where M is a configurable fixed parameter). Using each random number, it decides which of the 5 actions above to perform. The benchmark terminates when N actors have been spawned (where N is a configurable parameter).
To detect when N actors have been spawned, we use a CountDownLatch initialized to N; each time an actor is spawned, the counter is decremented. The main thread stops the benchmark when the counter hits 0.
Initially, we just have one actor (a receptionist). We send it P Ping messages (where P is some large-ish configurable parameter like 100). This will cause it to start spawning actors and sending messages and etc.
Implementation
[x] Create a Scala object that holds the configuration parameters: The value of M, N, and the probabilities of each action.
[x] Add a parameter latch: CountDownLatch to the constructor of the benchmark actor. Modify the spawnActor method so that it invokes latch.countDown whenever an actor is spawned. Also, the spawned actor should be given a reference to latch in its constructor.
[x] Add a method doSomeActions() to the benchmark actor behavior. This method should get invoked by both Ping and Link messages. This method should do the following:
Look up M from the configuration object
Generate a list R containing M random numbers between 0 and 1
Look up the probabilities p1, p2, p3, p4 of the four actions in the configuration object.
For each r in R:
If r < p1, do action 1
Else if r < p1 + p2, do action 2
Else if r < p1 + p2 + p3, do action 3
Else if r < p1 + p2 + p3 + p4, do action 4
Else do nothing.
[x] Create a subclass of savina's Benchmark class:
initialize does nothing
printArgInfo does nothing
cleanupIteration does nothing
runIteration
look up the value of N and P in the configuration object
create a new CountDownLatch, with the initial value N
create a new random graph benchmark actor, passing the CountDownLatch instance to its constructor.
Continuation of #17. In the random graphs benchmark, actors can do 5 things:
Whenever an actor gets a message, it generates M random numbers between 0 and 1 (where M is a configurable fixed parameter). Using each random number, it decides which of the 5 actions above to perform. The benchmark terminates when N actors have been spawned (where N is a configurable parameter).
To detect when N actors have been spawned, we use a CountDownLatch initialized to N; each time an actor is spawned, the counter is decremented. The main thread stops the benchmark when the counter hits 0.
Initially, we just have one actor (a receptionist). We send it P Ping messages (where P is some large-ish configurable parameter like 100). This will cause it to start spawning actors and sending messages and etc.
Implementation
[x] Create a Scala
object
that holds the configuration parameters: The value of M, N, and the probabilities of each action.[x] Add a parameter
latch: CountDownLatch
to the constructor of the benchmark actor. Modify thespawnActor
method so that it invokeslatch.countDown
whenever an actor is spawned. Also, the spawned actor should be given a reference tolatch
in its constructor.[x] Add a method
doSomeActions()
to the benchmark actor behavior. This method should get invoked by both Ping and Link messages. This method should do the following:Look up M from the configuration object
Generate a list R containing M random numbers between 0 and 1
Look up the probabilities p1, p2, p3, p4 of the four actions in the configuration object.
For each r in R:
[x] Create a subclass of savina's
Benchmark
class:initialize
does nothingprintArgInfo
does nothingcleanupIteration
does nothingrunIteration