From: Jef Driesen on
Hi,

I'm using socat and pseudo terminals, to create two virtual serial ports
linked with a null modem cable. The purpose of this setup is to allow
two applications to communicate with each other, as if they were talking
to real serial ports.

socat PTY,link=/tmp/ttyS0 PTY,link=/tmp/ttyS1

But I noticed the performance is quite bad. Trying to transmit data
takes very long. For instance transmitting 32KB takes a few minutes on
my machine (Ubuntu 9.10), while on another user's machine (Mac OS X)
it's much faster, in the order of a few seconds.

Any idea what is causing this?

I know the transfer protocol is not exactly efficient because it's using
very small blocksize (16 bytes packets with a few extra bytes for
framing), but that doesn't explain the difference on other machines.
Note that I don't have control over the transfer protocol.

Thanks in advance,

Jef
From: Alan Curry on
In article <uGM_m.1242$SK6.101(a)newsfe28.ams2>,
Jef Driesen <jefdriesen(a)hotmail.com.invalid> wrote:
>Hi,
>
>I'm using socat and pseudo terminals, to create two virtual serial ports
>linked with a null modem cable. The purpose of this setup is to allow
>two applications to communicate with each other, as if they were talking
>to real serial ports.
>
>socat PTY,link=/tmp/ttyS0 PTY,link=/tmp/ttyS1
>
>But I noticed the performance is quite bad. Trying to transmit data
>takes very long. For instance transmitting 32KB takes a few minutes on
>my machine (Ubuntu 9.10), while on another user's machine (Mac OS X)
>it's much faster, in the order of a few seconds.
>
>Any idea what is causing this?

termios is echoing everything back across the link. And then echoing it
again and again because both sides are in echo mode. A single byte written
should be enough to keep it busy echoing forever. Try adding ,raw,echo=0 to
the options.

The difference between operating systems might be caused by the kernel's
default termios settings for freshly created ptys.

--
Alan Curry
From: Jef Driesen on
On 30/12/09 21:36, Alan Curry wrote:
> In article<uGM_m.1242$SK6.101(a)newsfe28.ams2>,
> Jef Driesen<jefdriesen(a)hotmail.com.invalid> wrote:
>> Hi,
>>
>> I'm using socat and pseudo terminals, to create two virtual serial ports
>> linked with a null modem cable. The purpose of this setup is to allow
>> two applications to communicate with each other, as if they were talking
>> to real serial ports.
>>
>> socat PTY,link=/tmp/ttyS0 PTY,link=/tmp/ttyS1
>>
>> But I noticed the performance is quite bad. Trying to transmit data
>> takes very long. For instance transmitting 32KB takes a few minutes on
>> my machine (Ubuntu 9.10), while on another user's machine (Mac OS X)
>> it's much faster, in the order of a few seconds.
>>
>> Any idea what is causing this?
>
> termios is echoing everything back across the link. And then echoing it
> again and again because both sides are in echo mode. A single byte written
> should be enough to keep it busy echoing forever. Try adding ,raw,echo=0 to
> the options.
>
> The difference between operating systems might be caused by the kernel's
> default termios settings for freshly created ptys.
>

My applications change the termios settings into raw mode, so I assume
that problem doesn't apply in my case?
From: David Schwartz on
On Dec 30 2009, 2:31 pm, Jef Driesen <jefdrie...(a)hotmail.com.invalid>
wrote:

> My applications change the termios settings into raw mode, so I assume
> that problem doesn't apply in my case?

No, what's happen is simply that there are a ridiculous number of
handoffs where A waits for B. Tracing it on my Linux Fedora 12 system,
I've already identified about 60(!) such handoffs (cases where A does
something and then B must do something for any further forward
progress to be made) that have to occur for each block of 128 bytes to
be sent.

DS
From: Jef Driesen on
On 03/01/10 02:36, David Schwartz wrote:
> On Dec 30 2009, 2:31 pm, Jef Driesen<jefdrie...(a)hotmail.com.invalid>
> wrote:
>
>> My applications change the termios settings into raw mode, so I assume
>> that problem doesn't apply in my case?
>
> No, what's happen is simply that there are a ridiculous number of
> handoffs where A waits for B. Tracing it on my Linux Fedora 12 system,
> I've already identified about 60(!) such handoffs (cases where A does
> something and then B must do something for any further forward
> progress to be made) that have to occur for each block of 128 bytes to
> be sent.

I'm not really sure I understand what you wrote.

What socat does is a simple select() loop, waiting until data arrives on
one of the two pseudo terminals. When data is available on one side, it
is read(), and then write() back to the other one (and vice versa of
course). I would think the overhead is quite small.

Or are you referring to the communication protocol, where the sending
side needs to wait every time until the receiving side requests a packet?