Context switching during a chain of external clients from the same process?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Context switching during a chain of external clients from the same process?

Arne Jacobs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

I have a (hopefully) simple question: If I connect multiple Jack clients
which were registered from the same process, will there be context
switches between that process and the Jack server between the
activations of successive clients?

Intuitively I would say that the control logic, which calls the Jack
clients' callbacks in graph order, would reside in the server process,
and thus a context switch would occur between clients, even if they are
from the same process. However, I thought that it might be possible to
push some of the control logic to the client's process if such a chain
of clients in the same process occurs.

How is it implemented in Jack (1 and 2)? Would it be possible at all to
"wrap" connected parts of the Jack graph which all reside in the same
process, such that no context switches occur?

With kind regards,

Arne
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNRW96AAoJEF1b7P/CXy5Ed5IQAIIhJ8itDOUxLqp0Ia0Zs+1M
UL7zeDSz1TC9xhqFh9SexXNKcI4Pto2QiOsTNrotsOjBf8zPLiNK3EH9Nz1XsRnu
FNpEaqzalncIIbFB3GytFUtZLHpMx3mKCxpf3FBG/Yy0acK4ed476/zdMbfffdHT
Yh0A19NlzAXxalggYC4gOAcV7BA5Uq0EtZ39XiKdOoyryCZcxHe2PDjbiAOvCcEp
JmMfO0SrgE+TTK0/iL0wl8kCeD8k4y5KOLhMlSkt2LtH/UnnmXE/WY8KBCicYE6k
u1PtsYJwTK129psFiNQ4R61yAgDlJr/M3R4X9ABMPQ66PdC6hIJc3U75ZdYHehD9
tQxfPhOMBvUHvFM8fx/qQBtaq7kz4SVQF0Xa765KFfJKrJ64aunXVEKyCuOmT+j5
sLv3Io8Hp0ZyvWY0YhZCJXilwzT5cgK/06+/IZbrFRo1fXgVIjSsyRGeX+yBn3L3
NAgf8mAYqWPbV1dtWwNVccFc8PO5BgUPDEv/TeVIR38CmnsIbB0W7Zq348lCe4Ab
Mqt/cGzLFYV3lrVAluAmEi6g9adOycOMBOBiJZNocsIthLT1unYi6ox95uX6JUAm
WvH1LevO6xZQcB1oRTClwCuxCrBYcCHUJLJV47HoqDM1YnnO3qdKZIXSrfyr03sf
I/p0i/5Z3xvoKgXNtpZh
=0QhJ
-----END PGP SIGNATURE-----
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

Fons Adriaensen-2
On Sun, Jan 30, 2011 at 03:02:35PM +0100, Arne Jacobs wrote:

> I have a (hopefully) simple question: If I connect multiple Jack clients
> which were registered from the same process, will there be context
> switches between that process and the Jack server between the
> activations of successive clients?

At least for Jack1 there will be no process switch if the next and
current clients are in the same process. Also a switch between two
processes will be a single one and not via jackd itself. Don't know
for Jack2 but I assume it does the same.

Ciao,

--
FA

There are three of them, and Alleline.

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

Stéphane Letz

Le 30 janv. 2011 à 15:24, [hidden email] a écrit :

> On Sun, Jan 30, 2011 at 03:02:35PM +0100, Arne Jacobs wrote:
>
>> I have a (hopefully) simple question: If I connect multiple Jack clients
>> which were registered from the same process, will there be context
>> switches between that process and the Jack server between the
>> activations of successive clients?
>
> At least for Jack1 there will be no process switch if the next and
> current clients are in the same process. Also a switch between two
> processes will be a single one and not via jackd itself. Don't know
> for Jack2 but I assume it does the same.

Same for jack2.

Stéphane

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

Paul Davis
In reply to this post by Arne Jacobs
On Sun, Jan 30, 2011 at 9:02 AM, Arne Jacobs <[hidden email]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi!
>
> I have a (hopefully) simple question: If I connect multiple Jack clients
> which were registered from the same process, will there be context
> switches between that process and the Jack server between the
> activations of successive clients?

one of JACK's specific design goals is to minimize context switching.
wakeups from client to client happen without a return to the server.

so if you register clients A, B and C from the same process, and they
run in the order (A B C) then each client thread will wake the next
without a context switch.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

David Henningsson-3
In reply to this post by Stéphane Letz
On 2011-01-30 18:25, Stéphane Letz wrote:

>
> Le 30 janv. 2011 à 15:24, [hidden email] a écrit :
>
>> On Sun, Jan 30, 2011 at 03:02:35PM +0100, Arne Jacobs wrote:
>>
>>> I have a (hopefully) simple question: If I connect multiple Jack clients
>>> which were registered from the same process, will there be context
>>> switches between that process and the Jack server between the
>>> activations of successive clients?
>>
>> At least for Jack1 there will be no process switch if the next and
>> current clients are in the same process. Also a switch between two
>> processes will be a single one and not via jackd itself. Don't know
>> for Jack2 but I assume it does the same.
>
> Same for jack2.

Out of curiosity, jackmp is able to use multiple processors - so if you
have four processes and five clients in each, how is this distributed
over say three processor cores?

Can jackmp determine whether waking up additional processors is worth
the overhead of doing so?


--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

Stéphane Letz

Le 31 janv. 2011 à 10:14, David Henningsson a écrit :

> On 2011-01-30 18:25, Stéphane Letz wrote:
>>
>> Le 30 janv. 2011 à 15:24, [hidden email] a écrit :
>>
>>> On Sun, Jan 30, 2011 at 03:02:35PM +0100, Arne Jacobs wrote:
>>>
>>>> I have a (hopefully) simple question: If I connect multiple Jack clients
>>>> which were registered from the same process, will there be context
>>>> switches between that process and the Jack server between the
>>>> activations of successive clients?
>>>
>>> At least for Jack1 there will be no process switch if the next and
>>> current clients are in the same process. Also a switch between two
>>> processes will be a single one and not via jackd itself. Don't know
>>> for Jack2 but I assume it does the same.
>>
>> Same for jack2.
>
> Out of curiosity, jackmp is able to use multiple processors - so if you have four processes and five clients in each, how is this distributed over say three processor cores?

Obviously this depends of data dependancies between clients: having five clients in each process does not say anything, the important point is connection topology.

>
> Can jackmp determine whether waking up additional processors is worth the overhead of doing so?
>


What jackdmp does is only "waking clients RT thread" (to be then scheduled by the system) when data dependancies say it can be done. More precisely for a given "multi clients connected to a next client" scheme, the *last* client is the one that will effectively resume the next client activation token (a semaphore, or fifo or whatever model is used on each system). jackmp does not contain any additional logic to find out if waking up additional processors would be useful in a given context.

I think Torben did some tests in tschak following this idea, lI don't know if it gave some interesting results or not.

Stéphane
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

David Henningsson-3
On 2011-01-31 10:30, Stéphane Letz wrote:

>
> Le 31 janv. 2011 à 10:14, David Henningsson a écrit :
>
>> On 2011-01-30 18:25, Stéphane Letz wrote:
>>>
>>> Le 30 janv. 2011 à 15:24, [hidden email] a écrit :
>>>
>>>> On Sun, Jan 30, 2011 at 03:02:35PM +0100, Arne Jacobs wrote:
>>>>
>>>>> I have a (hopefully) simple question: If I connect multiple Jack clients
>>>>> which were registered from the same process, will there be context
>>>>> switches between that process and the Jack server between the
>>>>> activations of successive clients?
>>>>
>>>> At least for Jack1 there will be no process switch if the next and
>>>> current clients are in the same process. Also a switch between two
>>>> processes will be a single one and not via jackd itself. Don't know
>>>> for Jack2 but I assume it does the same.
>>>
>>> Same for jack2.
>>
>> Out of curiosity, jackmp is able to use multiple processors - so if you have four processes and five clients in each, how is this distributed over say three processor cores?
>
> Obviously this depends of data dependancies between clients: having five clients in each process does not say anything, the important point is connection topology.
>
>>
>> Can jackmp determine whether waking up additional processors is worth the overhead of doing so?
>>
>
>
> What jackdmp does is only "waking clients RT thread" (to be then scheduled by the system) when data dependancies say it can be done. More precisely for a given "multi clients connected to a next client" scheme, the *last* client is the one that will effectively resume the next client activation token (a semaphore, or fifo or whatever model is used on each system). jackmp does not contain any additional logic to find out if waking up additional processors would be useful in a given context.
>
> I think Torben did some tests in tschak following this idea, lI don't know if it gave some interesting results or not.

Let me clarify, assuming we have three cores, four processes and five
clients in every process. All twenty clients can execute in parallel (e
g if they are 20 different independent instruments).

Does jackmp wake up 20 RT threads simultaneously? What does jack1 do?


--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

Paul Davis
On Mon, Jan 31, 2011 at 6:51 AM, David Henningsson
<[hidden email]> wrote:

> Let me clarify, assuming we have three cores, four processes and five
> clients in every process. All twenty clients can execute in parallel (e g if
> they are 20 different independent instruments).
>
> Does jackmp wake up 20 RT threads simultaneously? What does jack1 do?

jack1 does nothing - it always runs all clients 1 at a time,
serialized by the data flow.

i'll have to let stephane answer as to whether or not jack2 has a
cpu-count limit on the number of clients it will activate at once, and
ditto for torben and tschak's model.

note that that its far from obvious that its the right thing to run N
(parallel) clients on N cpus given that some of the clients could
themselves be multithreaded.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

Stéphane Letz
In reply to this post by David Henningsson-3

Le 31 janv. 2011 à 12:51, David Henningsson a écrit :

> On 2011-01-31 10:30, Stéphane Letz wrote:
>>
>> Le 31 janv. 2011 à 10:14, David Henningsson a écrit :
>>
>>> On 2011-01-30 18:25, Stéphane Letz wrote:
>>>>
>>>> Le 30 janv. 2011 à 15:24, [hidden email] a écrit :
>>>>
>>>>> On Sun, Jan 30, 2011 at 03:02:35PM +0100, Arne Jacobs wrote:
>>>>>
>>>>>> I have a (hopefully) simple question: If I connect multiple Jack clients
>>>>>> which were registered from the same process, will there be context
>>>>>> switches between that process and the Jack server between the
>>>>>> activations of successive clients?
>>>>>
>>>>> At least for Jack1 there will be no process switch if the next and
>>>>> current clients are in the same process. Also a switch between two
>>>>> processes will be a single one and not via jackd itself. Don't know
>>>>> for Jack2 but I assume it does the same.
>>>>
>>>> Same for jack2.
>>>
>>> Out of curiosity, jackmp is able to use multiple processors - so if you have four processes and five clients in each, how is this distributed over say three processor cores?
>>
>> Obviously this depends of data dependancies between clients: having five clients in each process does not say anything, the important point is connection topology.
>>
>>>
>>> Can jackmp determine whether waking up additional processors is worth the overhead of doing so?
>>>
>>
>>
>> What jackdmp does is only "waking clients RT thread" (to be then scheduled by the system) when data dependancies say it can be done. More precisely for a given "multi clients connected to a next client" scheme, the *last* client is the one that will effectively resume the next client activation token (a semaphore, or fifo or whatever model is used on each system). jackmp does not contain any additional logic to find out if waking up additional processors would be useful in a given context.
>>
>> I think Torben did some tests in tschak following this idea, lI don't know if it gave some interesting results or not.
>
> Let me clarify, assuming we have three cores, four processes and five clients in every process. All twenty clients can execute in parallel (e g if they are 20 different independent instruments).
>
> Does jackmp wake up 20 RT threads simultaneously?

Yes it will.

> What does jack1 do?
>

Topological sort of the graph that finally produce a sequence of activations for the 20 clients.

Stéphane
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

Stéphane Letz
In reply to this post by Paul Davis

Le 31 janv. 2011 à 13:02, Paul Davis a écrit :

> On Mon, Jan 31, 2011 at 6:51 AM, David Henningsson
> <[hidden email]> wrote:
>
>> Let me clarify, assuming we have three cores, four processes and five
>> clients in every process. All twenty clients can execute in parallel (e g if
>> they are 20 different independent instruments).
>>
>> Does jackmp wake up 20 RT threads simultaneously? What does jack1 do?
>
> jack1 does nothing - it always runs all clients 1 at a time,
> serialized by the data flow.
>
> i'll have to let stephane answer as to whether or not jack2 has a
> cpu-count limit on the number of clients it will activate at once, and
> ditto for torben and tschak's model.

Nothing special in jack2. Simple data flow model: basically make clients RT thread runnable when the data is ready.

>
> note that that its far from obvious that its the right thing to run N
> (parallel) clients on N cpus given that some of the clients could
> themselves be multithreaded.

My first guess is that if jackd starts to do (part of) the job of the system scheduler, then we may end up in a lot of complexity. I may be wrong but doing otherwise would require of lot of real-life setup testing.

Stéphane

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Context switching during a chain of external clients from the same process?

torbenh
In reply to this post by Paul Davis
On Mon, Jan 31, 2011 at 07:02:08AM -0500, Paul Davis wrote:

> On Mon, Jan 31, 2011 at 6:51 AM, David Henningsson
> <[hidden email]> wrote:
>
> > Let me clarify, assuming we have three cores, four processes and five
> > clients in every process. All twenty clients can execute in parallel (e g if
> > they are 20 different independent instruments).
> >
> > Does jackmp wake up 20 RT threads simultaneously? What does jack1 do?
>
> jack1 does nothing - it always runs all clients 1 at a time,
> serialized by the data flow.
>
> i'll have to let stephane answer as to whether or not jack2 has a
> cpu-count limit on the number of clients it will activate at once, and
> ditto for torben and tschak's model.

tschack can limit the cpu count.
but this costs quite a few cycles. and i am currently tempted to remove
that feature again.

>
> note that that its far from obvious that its the right thing to run N
> (parallel) clients on N cpus given that some of the clients could
> themselves be multithreaded.
> _______________________________________________
> Jack-Devel mailing list
> [hidden email]
> http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org

--
torben Hohn
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org