1

In the answer of this, it mentioned:

People also hear that X uses the "network" and think this is going to be a performance bottleneck. "Network" here means local UNIX domain socket, which has negligible overhead on modern Linux. Things that would bottleneck on the network, there are X extensions to make fast (shared memory pixmaps, DRI, etc.). Threads in-process wouldn't necessarily be faster than the X socket, because the bottlenecks have more to do with the inherent problem of coordinating multiple threads or processes accessing the same hardware, than with the minimal overhead of local sockets.

I don't get it. I always think that multiple threads communicate by shared variables should be faster than multiple processes communicate by Unix domain socket. So...am I wrong? Is that coordinating multiple threads such a time consuming job? And the order of how processes get scheduled does not affect the performance of the Unix domain socket at all?

Any idea? Please...


Sorry, I didn't make the question clear. What I wanted to ask is about IPC efficiency rather than X Window/Wayland system.

I just want to know why UNIX domain socket can be faster than shared memory? AFAIK, shared memory is the most primitive way to communicate between processes and threads isn't it? So UNIX domain socket should be built on top of shared memory mechanism (accompany with proper locking). How come a student (i.e. Unix domain socket) can outperform his teacher (i.e. shared memory)?

Community
  • 1
  • 1
Justin
  • 169
  • 5

1 Answers1

0

For performance, what matters is the slowest thing (the bottleneck). If some part of the program could be faster, but it isn't the bottleneck, modifying that part of the program will not help you.

This is why improving performance should always start with profiling. Every single bit of a program can always be made faster, but you need to make the bottleneck faster, not just some random thing.

With X, people will often latch on to the easy insight that something over a socket could always be slightly faster if in a single process. Which is true, but it doesn't necessarily matter to overall performance. More important is the overall design of the system... that's what something like Wayland is trying to fix.

Havoc P
  • 8,365
  • 1
  • 31
  • 46
  • "This is why improving performance should always start with profiling." ... well, but sometimes we can come up with several designs first and then compare which design implementation is better (maybe by profiling as you said) ... it is another approach to improve performance I think. I mean we can improve performance not only by improving the existing one (e.g. X Window) but also by inventing a brand new design (e.g. Wayland). – Justin Oct 01 '13 at 08:28
  • Sorry, I didn't make the question clear. What I wanted to ask is about IPC efficiency rather than X Window/Wayland system. I've revised the original question. – Justin Oct 01 '13 at 10:03