Merge pull request #310 from jboner/wip-executor-patriknw

PinnedDispatcher config and docs for dispatcher executor.
This commit is contained in:
patriknw 2012-02-07 04:36:37 -08:00
commit 6427663fdc
12 changed files with 71 additions and 6 deletions

View file

@ -14,6 +14,7 @@ import akka.util.duration._
object SupervisorMiscSpec { object SupervisorMiscSpec {
val config = """ val config = """
pinned-dispatcher { pinned-dispatcher {
executor = thread-pool-executor
type = PinnedDispatcher type = PinnedDispatcher
} }
test-dispatcher { test-dispatcher {

View file

@ -435,6 +435,7 @@ object DispatcherModelSpec {
val config = { val config = {
""" """
boss { boss {
executor = thread-pool-executor
type = PinnedDispatcher type = PinnedDispatcher
} }
""" + """ +
@ -506,6 +507,7 @@ object BalancingDispatcherModelSpec {
val config = { val config = {
""" """
boss { boss {
executor = thread-pool-executor
type = PinnedDispatcher type = PinnedDispatcher
} }
""" + """ +

View file

@ -12,6 +12,7 @@ import akka.pattern.ask
object PinnedActorSpec { object PinnedActorSpec {
val config = """ val config = """
pinned-dispatcher { pinned-dispatcher {
executor = thread-pool-executor
type = PinnedDispatcher type = PinnedDispatcher
} }
""" """

View file

@ -16,6 +16,7 @@ object CallingThreadDispatcherModelSpec {
val config = { val config = {
""" """
boss { boss {
executor = thread-pool-executor
type = PinnedDispatcher type = PinnedDispatcher
} }
""" + """ +

View file

@ -156,7 +156,8 @@ akka {
# the same type), PinnedDispatcher, or a FQCN to a class inheriting # the same type), PinnedDispatcher, or a FQCN to a class inheriting
# MessageDispatcherConfigurator with a constructor with # MessageDispatcherConfigurator with a constructor with
# com.typesafe.config.Config parameter and akka.dispatch.DispatcherPrerequisites # com.typesafe.config.Config parameter and akka.dispatch.DispatcherPrerequisites
# parameters # parameters.
# PinnedDispatcher must be used toghether with executor=thread-pool-executor.
type = "Dispatcher" type = "Dispatcher"
# Which kind of ExecutorService to use for this dispatcher # Which kind of ExecutorService to use for this dispatcher

View file

@ -23,6 +23,7 @@ object AkkaException {
sb.append("\tat %s\n" format trace(i)) sb.append("\tat %s\n" format trace(i))
sb.toString sb.toString
} }
} }
/** /**

View file

@ -10,11 +10,13 @@ akka {
# The dispatcher used for agent-send-off actor # The dispatcher used for agent-send-off actor
send-off-dispatcher { send-off-dispatcher {
executor = thread-pool-executor
type = PinnedDispatcher type = PinnedDispatcher
} }
# The dispatcher used for agent-alter-off actor # The dispatcher used for agent-alter-off actor
alter-off-dispatcher { alter-off-dispatcher {
executor = thread-pool-executor
type = PinnedDispatcher type = PinnedDispatcher
} }

View file

@ -55,6 +55,17 @@ Default values are taken from ``default-dispatcher``, i.e. all options doesn't n
:ref:`configuration` for the default values of the ``default-dispatcher``. You can also override :ref:`configuration` for the default values of the ``default-dispatcher``. You can also override
the values for the ``default-dispatcher`` in your configuration. the values for the ``default-dispatcher`` in your configuration.
There are two different executor services:
* executor = "fork-join-executor", ``ExecutorService`` based on ForkJoinPool (jsr166y). This is used by default for
``default-dispatcher``.
* executor = "thread-pool-executor", ``ExecutorService`` based on ``java.util.concurrent.ThreadPoolExecutor``.
Note that the pool size is configured differently for the two executor services. The configuration above
is an example for ``fork-join-executor``. Below is an example for ``thread-pool-executor``:
.. includecode:: ../scala/code/akka/docs/dispatcher/DispatcherDocSpec.scala#my-thread-pool-dispatcher-config
Let's now walk through the different dispatchers in more detail. Let's now walk through the different dispatchers in more detail.
Thread-based Thread-based
@ -67,9 +78,11 @@ has worse performance and scalability than the event-based dispatcher but works
a low frequency of messages and are allowed to go off and do their own thing for a longer period of time. Another advantage with a low frequency of messages and are allowed to go off and do their own thing for a longer period of time. Another advantage with
this dispatcher is that Actors do not block threads for each other. this dispatcher is that Actors do not block threads for each other.
The ``PinnedDispatcher`` can't be configured, but is created and associated with an actor like this: The ``PinnedDispatcher`` is configured like this:
.. includecode:: code/akka/docs/dispatcher/DispatcherDocTestBase.java#defining-pinned-dispatcher .. includecode:: ../scala/code/akka/docs/dispatcher/DispatcherDocSpec.scala#my-pinned-dispatcher-config
Note that it must be used with ``executor = "thread-pool-executor"``.
Event-based Event-based
^^^^^^^^^^^ ^^^^^^^^^^^

View file

@ -20,6 +20,27 @@ object DispatcherDocSpec {
val config = """ val config = """
//#my-dispatcher-config //#my-dispatcher-config
my-dispatcher { my-dispatcher {
# Dispatcher is the name of the event-based dispatcher
type = Dispatcher
# What kind of ExecutionService to use
executor = "fork-join-executor"
# Configuration for the fork join pool
fork-join-executor {
# Min number of threads to cap factor-based parallelism number to
parallelism-min = 2
# Parallelism (threads) ... ceil(available processors * factor)
parallelism-factor = 2.0
# Max number of threads to cap factor-based parallelism number to
parallelism-max = 10
}
# Throughput defines the number of messages that are processed in a batch before the
# thread is returned to the pool. Set to 1 for as fair as possible.
throughput = 100
}
//#my-dispatcher-config
//#my-thread-pool-dispatcher-config
my-thread-pool-dispatcher {
# Dispatcher is the name of the event-based dispatcher # Dispatcher is the name of the event-based dispatcher
type = Dispatcher type = Dispatcher
# What kind of ExecutionService to use # What kind of ExecutionService to use
@ -37,7 +58,14 @@ object DispatcherDocSpec {
# thread is returned to the pool. Set to 1 for as fair as possible. # thread is returned to the pool. Set to 1 for as fair as possible.
throughput = 100 throughput = 100
} }
//#my-dispatcher-config //#my-thread-pool-dispatcher-config
//#my-pinned-dispatcher-config
my-pinned-dispatcher {
executor = "thread-pool-executor"
type = PinnedDispatcher
}
//#my-pinned-dispatcher-config
//#my-bounded-config //#my-bounded-config
my-dispatcher-bounded-queue { my-dispatcher-bounded-queue {

View file

@ -54,6 +54,17 @@ Default values are taken from ``default-dispatcher``, i.e. all options doesn't n
:ref:`configuration` for the default values of the ``default-dispatcher``. You can also override :ref:`configuration` for the default values of the ``default-dispatcher``. You can also override
the values for the ``default-dispatcher`` in your configuration. the values for the ``default-dispatcher`` in your configuration.
There are two different executor services:
* executor = "fork-join-executor", ``ExecutorService`` based on ForkJoinPool (jsr166y). This is used by default for
``default-dispatcher``.
* executor = "thread-pool-executor", ``ExecutorService`` based on ``java.util.concurrent.ThreadPoolExecutor``.
Note that the pool size is configured differently for the two executor services. The configuration above
is an example for ``fork-join-executor``. Below is an example for ``thread-pool-executor``:
.. includecode:: code/akka/docs/dispatcher/DispatcherDocSpec.scala#my-thread-pool-dispatcher-config
Let's now walk through the different dispatchers in more detail. Let's now walk through the different dispatchers in more detail.
Thread-based Thread-based
@ -66,9 +77,11 @@ has worse performance and scalability than the event-based dispatcher but works
a low frequency of messages and are allowed to go off and do their own thing for a longer period of time. Another advantage with a low frequency of messages and are allowed to go off and do their own thing for a longer period of time. Another advantage with
this dispatcher is that Actors do not block threads for each other. this dispatcher is that Actors do not block threads for each other.
The ``PinnedDispatcher`` can't be configured, but is created and associated with an actor like this: The ``PinnedDispatcher`` is configured like this:
.. includecode:: code/akka/docs/dispatcher/DispatcherDocSpec.scala#defining-pinned-dispatcher .. includecode:: code/akka/docs/dispatcher/DispatcherDocSpec.scala#my-pinned-dispatcher-config
Note that it must be used with ``executor = "thread-pool-executor"``.
Event-based Event-based
^^^^^^^^^^^ ^^^^^^^^^^^

View file

@ -133,6 +133,7 @@ akka {
# The dispatcher used for the system actor "network-event-sender" # The dispatcher used for the system actor "network-event-sender"
network-event-sender-dispatcher { network-event-sender-dispatcher {
executor = thread-pool-executor
type = PinnedDispatcher type = PinnedDispatcher
} }
} }

View file

@ -15,6 +15,7 @@ akka {
socket-dispatcher { socket-dispatcher {
# A zeromq socket needs to be pinned to the thread that created it. # A zeromq socket needs to be pinned to the thread that created it.
# Changing this value results in weird errors and race conditions within zeromq # Changing this value results in weird errors and race conditions within zeromq
executor = thread-pool-executor
type = "PinnedDispatcher" type = "PinnedDispatcher"
} }
} }