1 |
On Wed 13 Aug 2014 03:23:21 PM EDT, Grant Edwards wrote: |
2 |
> On 2014-08-13, Alec Ten Harmsel <alec@××××××××××××××.com> wrote: |
3 |
>> 2014-08-13 12:21 GMT-05:00 Grant Edwards <grant.b.edwards@×××××.com>: |
4 |
> |
5 |
>> Without knowing what you're doing, this sounds like a bad idea; if |
6 |
>> you *need* to synchronize threads, why aren't they running in the |
7 |
>> same process? |
8 |
> |
9 |
> I'm trying to decouple different portions of a system as much as |
10 |
> possible. Currently, the different parts communicate via Unix domain |
11 |
> sockets. That works OK, but for a few of the high-frequence |
12 |
> operations I'm trying to find a way to eliminate the overhead that's |
13 |
> involved in sockets (system calls, context switches, copying data from |
14 |
> userspace to kernel space and back to user space). |
15 |
|
16 |
Decoupling == great. Is it possible that you could do something like |
17 |
this: |
18 |
|
19 |
Thread 'a' in process 'a': |
20 |
1. Event in thread 'a' is generated or whatever |
21 |
2. if low-frequency event, send a message over a socket to a different |
22 |
thread/process |
23 |
3. if high-frequency event, push event into shared memory thread-safe |
24 |
queue |
25 |
|
26 |
Thread 'b' in process 'a': |
27 |
1. infinite loop reading from shared memory queue and processing events |
28 |
|
29 |
Ideally, the high-frequency events should be handled in the same |
30 |
thread, then in the same process, and only lastly in a different |
31 |
process. While decoupling is great, it seems like you're losing the |
32 |
benefits of it by tightly coupling all of your "decoupled" threads and |
33 |
processes. |
34 |
|
35 |
> I may have to stick with sockets when I want to block until some event |
36 |
> happens. |
37 |
|
38 |
To be clear, do you want to block or sleep/yield until an event happens? |
39 |
|
40 |
I'm sorry for not being too helpful. Just one last question: Can you |
41 |
describe what exactly your code is supposed to do, or is it something |
42 |
that you can't talk about because it's a work thing? I don't care |
43 |
either way, but I'm just curious because it seems you need to optimize |
44 |
quite a bit. |
45 |
|
46 |
Alec |