context: add support for multiple data loops

Add config options to create and start multiple data loops, each with
their own priority and thread affinity if requested.

Make it possible to assign loop.classes to the data-loops. Use the
node.loop.class to find a data-loop for the node of the same class. Try
to evenly spread the nodes over the available matching loops.

With this, it is possible to separate the processing of the nodes
depending on the classes, like audio/video and improve concurency on
the server.

No attempt is done yet to move nodes between loops or to move
independent nodes to separate data loops.

Fixes #3969
This commit is contained in:
Wim Taymans 2024-04-19 14:57:53 +02:00
parent e85bb7194b
commit a4bfdd7f82
10 changed files with 331 additions and 63 deletions

View file

@ -262,6 +262,16 @@ When the node is not linked anymore, it becomes idle. Normally idle nodes keep p
When the session manager does not suspend nodes (or when there is no session manager), the node.suspend-on-idle property can be used instead.
\endparblock
@PAR@ client.conf node.loop.name = null
@PAR@ client.conf node.loop.class = data.rt
\parblock
Add the node to a specific loop name or loop class. By default the node is added to the
data.rt loop class. You can make more specific data loops and then assign the nodes to those.
Other well known names are main-loop.0 and the main node.loop.class which runs the node data processing
in the main loop.
\endparblock
## Session Manager Properties @IDX@ client.conf
@PAR@ client.conf node.autoconnect = true

View file

@ -153,6 +153,41 @@ The name of the shared library to use for the system functions for the data proc
thread. This can typically be changed if the data thread is running on a realtime
kernel such as EVL.
@PAR@ pipewire.conf loop.rt-prio = -1
The priority of the data loops. The data loops are used to schedule the nodes in the graph.
A value of -1 uses the default realtime priority from the module-rt. A value of 0 disables
realtime scheduling for the data loops.
@PAR@ pipewire.conf loop.class = [ data.rt .. ]
An array of classes of the data loops. Normally nodes are assigned to a loop by name or by class.
Nodes are by default assigned to the data.rt class so it is good to have a data loop
of this class as well.
@PAR@ pipewire.conf context.num-data-loops = 1
The number of data loops to create. By default 1 data-loop is created and all nodes are
scheduled in this thread. A value of 0 disables the real-time data loops and schedules
all nodes in the main thread. A value of -1 spawns as many data threads as there are
cpu cores.
@PAR@ pipewire.conf context.data-loops = [ ... ]
This controls the data loops that will be created for the context. Is is an array of
data loop specifications, one entry for each data loop to start:
```json
context.data-loops = [
{
#library.name.system = support/libspa-support
loop.rt-prio = -1
loop.class = [ data.rt .. ]
thread.name = data-loop.0
thread.affinity = [ 0 1 ]
}
...
]
```
A specific priority, classes and name can be given with loop.rt-prio, loop.class and
thread.name respectively. It is also possible to pin the data loop to specific CPU
cores with the thread.affinity property.
@PAR@ pipewire.conf core.daemon = false
Makes the PipeWire process, started with this config, a daemon
process. This means that it will manage and schedule a graph for