Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Download & Upload
Music Search
KVR
   
KVR Forum » DSP and Plug-in Development
Thread Read
IPC considerations
TabSel
KVRist
- profile
- pm
- e-mail
PostPosted: Thu Sep 06, 2012 11:27 pm reply with quote
How much is the performance impact difference on

Running multiple processes, each with its own named shared memory mapped file read/write and one process which maps all of these named smm files

Versus

Running one process, creating multiple threads, with only one memory mapped file shared by the threads and another process which which maps the one named smm file.

I'm talking about multiple server processes which each host a different ASIO device, sharing buffers with one client process versus a single server process which hosts multiple asio devices (which is quite tricky to achieve) and one client process.

I'm just interested in the performance difference of the two different process/thread/memory mapping approaches... Has anybody experience to share?
^ Joined: 13 Mar 2002  Member: #2110  
Resplendence
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Fri Sep 07, 2012 6:30 am reply with quote
Assuming this is on Windows..

You need to synchronize access to the MMF for all the threads (or processes) that want to access it. As more threads need to access the resouce, this will introduce latency.

If the question is, does executing multiple processes vs multiple threads generally give you a performance gain, the answer is no.

Although MMF are known to be the best IPC mechanism performance wise, they are not necessarily suitable for audio software especially because the memory can be paged out, causing a hard pagefault when the memory is touched. Latency which can result in an audio dropout.

The best way to do IPC latency wise is to have shared resident memory. This is not easy to achieve and requires the backing of a kernel driver. I am working on a SDK which exposes this functionality to application level programmers.


//Daniel
^ Joined: 29 Sep 2007  Member: #161561  Location: Europe
TabSel
KVRist
- profile
- pm
- e-mail
PostPosted: Fri Sep 07, 2012 7:20 am reply with quote
Windows, yes.

Assuming that the kernel needs some time to map shared memory mapped files into the process space, I think mapping multiple shared memory mapped files into one process space takes longer? So it would be faster to have ONE process sharing ONE SMMF with another, than having multiple processes sharing multiple individual SMMF with one other process?

Take for example steinbergs asio multi server / asio client. These two processes communicate via a SMMF, I assum? Or Rewire? How does Rewire IPC work then, when SMMF is not suitable for Realtime applications?

Where can I find more info on shared resident memory, and/or your SDK?
^ Joined: 13 Mar 2002  Member: #2110  
Resplendence
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Fri Sep 07, 2012 8:54 am reply with quote
TabSel wrote:

Assuming that the kernel needs some time to map shared memory mapped files into the process space, I think mapping multiple shared memory mapped files into one process space takes longer?


The mapping is usually done at initialization time and not in a critical path. So from what I can see, it should not matter.

Quote:

So it would be faster to have ONE process sharing ONE SMMF with another, than having multiple processes sharing multiple individual SMMF with one other process?


I cannot answer that question because I have no insight in your design or even know what purpose your solution serves. In general terms, as more threads need to access your shared data, the more the locking will put weight in.

Quote:

Take for example steinbergs asio multi server / asio client. These two processes communicate via a SMMF, I assum? Or Rewire? How does Rewire IPC work then, when SMMF is not suitable for Realtime applications?


I don't know what they use. I did not say that MMF are unsuitable for real-time applications per se, but there is the problem of hard pagefaults that needs to be taken care of as the memory is backed by a file on disk.

Quote:

Where can I find more info on shared resident memory, and/or your SDK?


Unfortunately it isn't available yet, hope I will get it done by this winter.

//Daniel
^ Joined: 29 Sep 2007  Member: #161561  Location: Europe
TabSel
KVRist
- profile
- pm
- e-mail
PostPosted: Fri Sep 07, 2012 10:00 am reply with quote
Thanks anyway! Useful information!
^ Joined: 13 Mar 2002  Member: #2110  
camsr
KVRAF
- profile
- pm
PostPosted: Sat Sep 08, 2012 9:08 am reply with quote
Whatever you decide, it should be small, data-wise. This will minimize the chances of a hard fault. With today's CPUs, the cache size has increased very well, but audio data is still large in comparison. Also, the system using IPC should be optimized for the DAW only, to give it more paging priority.
----
^ Joined: 16 Feb 2005  Member: #58183  
TabSel
KVRist
- profile
- pm
- e-mail
PostPosted: Sat Sep 08, 2012 9:24 am reply with quote
Thanks. Just a question: how do "others" share data between processes? I mean, a multiclient asio driver for example, or rewire, VEPro local, jackaudio server etc...? These aren't necessarily kernel drivers...
^ Joined: 13 Mar 2002  Member: #2110  
Resplendence
KVRist
- profile
- pm
- e-mail
- www
PostPosted: Sat Sep 08, 2012 10:55 pm reply with quote
TabSel wrote:
Thanks. Just a question: how do "others" share data between processes? I mean, a multiclient asio driver for example, or rewire, VEPro local, jackaudio server etc...? These aren't necessarily kernel drivers...


I opened the Rewire DLL with Dependency Walker and see it imports CreateFileMapping, MapViewOfFile among few other functions so I would assume it uses MMF.

Jack has its source code published so you can download that and see what it does.

//Daniel
^ Joined: 29 Sep 2007  Member: #161561  Location: Europe
camsr
KVRAF
- profile
- pm
PostPosted: Sun Sep 09, 2012 12:35 pm reply with quote
Another consideration is how to 'address' the processes. They need to be able to find each other and recall state through a shutdown.
----
^ Joined: 16 Feb 2005  Member: #58183  
All times are GMT - 8 Hours

Printable version
Page 1 of 1
Display posts from previous:   
ReplyNew TopicPrevious TopicNext Topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Username: Password:  
KVR Developer Challenge 2012