zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: turn off baud rate compensation by default
@ 2007-02-07 11:43 Peter Stephenson
  2007-02-07 16:20 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2007-02-07 11:43 UTC (permalink / raw)
  To: Zsh hackers list

I was seeing odd delays in my xterm when updating long lines (but not
*that* long: about ten screen lines) which I eventually tracked down to
the baud rate compensation mechanism in zle.  Setting BAUD to 0 removed
this effect, but it seems to me that it's no longer appropriate to turn
this on by default:

- If it took me several minutes to find out where the delay was coming
from, it's going to puzzle a lot of people if they notice it.  That
would be OK if the benefits outweighed this.  However:
- It's initialised from the output baud rate set in the terminal driver.
On most modern systems that's got very little to do with the actual
rate at which the display is updated; it's a hangover from the days of
serial communications when your terminal was attached by RS232 rather
than a virtual terminal running in an ATI RADEON SeveralZillion (TM)
1024 squigabyte display card.
- If you *do* have a slow line, nowadays it's probably the Internet,
or some modem line between your PC and the shell server, not the
actual terminal line for which the baud rate is available to the shell.
- Hence on those occasions where it makes a useful difference, it's
almost always better to allow the user to set BAUD to an appropriate
value.

I won't check this in until you've had a chance to fault my logic.

Index: Doc/Zsh/params.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v
retrieving revision 1.35
diff -u -r1.35 params.yo
--- Doc/Zsh/params.yo	30 Oct 2006 10:37:17 -0000	1.35
+++ Doc/Zsh/params.yo	7 Feb 2007 11:30:48 -0000
@@ -744,17 +744,15 @@
 )
 vindex(BAUD)
 item(tt(BAUD))(
-The baud rate of the current connection.  Used by the line editor
-update mechanism to compensate for a slow terminal by delaying
-updates until necessary.  This may be profitably set to a lower value
-in some circumstances, e.g.
-for slow modems dialing into a communications server which is connected
-to a host via a fast link; in this case, this variable
-would be set by default to the speed of the fast link, and not
-the modem.
-This parameter should be set to the baud
-rate of the slowest part of the link for best performance. The compensation
-mechanism can be turned off by setting the variable to zero.
+The rate in bits per second at which data reaches the terminal.
+The line editor will use this value in order to compensate for a slow
+terminal by delaying updates to the display until necessary.  The default
+value is zero, which turns off the compensation mechanism.
+
+This may be profitably set in some circumstances, e.g.
+for slow modems dialing into a communications server, or on a slow wide
+area network.  This parameter should be set to the baud
+rate of the slowest part of the link for best performance.
 )
 vindex(cdpath)
 vindex(CDPATH)
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.122
diff -u -r1.122 params.c
--- Src/params.c	6 Feb 2007 21:47:55 -0000	1.122
+++ Src/params.c	7 Feb 2007 11:30:51 -0000
@@ -641,7 +641,17 @@
     setiparam("KEYTIMEOUT", 40);
     setiparam("LISTMAX", 100);
 #ifdef HAVE_SELECT
-    setiparam("BAUD", getbaudrate(&shttyinfo));  /* get the output baudrate */
+    /*
+     * We used to get the output baud rate here.  However, that's
+     * pretty irrelevant to a terminal on an X display and can lead
+     * to unnecessary delays if it's wrong (which it probably is).
+     * Furthermore, even if the output is slow it's very likely
+     * to be because of WAN delays, not covered by the output
+     * baud rate.
+     * So allow the user to set it in the special cases where it's
+     * useful.
+     */
+    setiparam("BAUD", 0);
 #endif
     setsparam("TMPPREFIX", ztrdup(DEFAULT_TMPPREFIX));
     setsparam("TIMEFMT", ztrdup(DEFAULT_TIMEFMT));

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: turn off baud rate compensation by default
  2007-02-07 11:43 PATCH: turn off baud rate compensation by default Peter Stephenson
@ 2007-02-07 16:20 ` Bart Schaefer
  2007-02-07 16:46   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2007-02-07 16:20 UTC (permalink / raw)
  To: Zsh hackers list

On Feb 7, 11:43am, Peter Stephenson wrote:
}
} - Hence on those occasions where it makes a useful difference, it's
} almost always better to allow the user to set BAUD to an appropriate
} value.
} 
} I won't check this in until you've had a chance to fault my logic.

It's not the first time it's come up, and I think changing the default
is the right thing, but perhaps there should be a way to cause the
value to be read from the tty.  Unfortunately I can't think just now
of a convenient way to express that.

However, I suggest that the new default be for BAUD to not be set at
all, rather than set to zero.  The only useful effect of having it
set to zero is that you can use $+BAUD to determine whether zsh was
compiled with HAVE_SELECT.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: turn off baud rate compensation by default
  2007-02-07 16:20 ` Bart Schaefer
@ 2007-02-07 16:46   ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2007-02-07 16:46 UTC (permalink / raw)
  To: Zsh hackers list

Bart Schaefer <schaefer@brasslantern.com> wrote:
> However, I suggest that the new default be for BAUD to not be set at
> all, rather than set to zero.

That seems reasonable:  I'd vaguely thought the parameter was special, but
it isn't, it's read by getiparam() at the start of zle which defaults to
returning zero anyway.  Also there's no remaining use of getbaudrate().

We *could* make it magic, so setting it to a negative value calls
getbaudrate() to get the value, but I think that's probably overkill.
(Then the parameter would have to be special, at least if we wanted
the effect to be apparent when it was read.  Alternatively we
could just put the getbaudrate() where zle reads the value, but then
the user can't see what it is.)

Index: Doc/Zsh/params.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v
retrieving revision 1.35
diff -u -r1.35 params.yo
--- Doc/Zsh/params.yo	30 Oct 2006 10:37:17 -0000	1.35
+++ Doc/Zsh/params.yo	7 Feb 2007 16:43:01 -0000
@@ -744,17 +744,16 @@
 )
 vindex(BAUD)
 item(tt(BAUD))(
-The baud rate of the current connection.  Used by the line editor
-update mechanism to compensate for a slow terminal by delaying
-updates until necessary.  This may be profitably set to a lower value
-in some circumstances, e.g.
-for slow modems dialing into a communications server which is connected
-to a host via a fast link; in this case, this variable
-would be set by default to the speed of the fast link, and not
-the modem.
-This parameter should be set to the baud
-rate of the slowest part of the link for best performance. The compensation
-mechanism can be turned off by setting the variable to zero.
+The rate in bits per second at which data reaches the terminal.
+The line editor will use this value in order to compensate for a slow
+terminal by delaying updates to the display until necessary.  If the
+parameter is unset or the value is zero the compensation mechanism is
+turned off.  The parameter is not set by default.
+
+This may be profitably set in some circumstances, e.g.
+for slow modems dialing into a communications server, or on a slow wide
+area network.  This parameter should be set to the baud
+rate of the slowest part of the link for best performance.
 )
 vindex(cdpath)
 vindex(CDPATH)
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.122
diff -u -r1.122 params.c
--- Src/params.c	6 Feb 2007 21:47:55 -0000	1.122
+++ Src/params.c	7 Feb 2007 16:43:01 -0000
@@ -640,9 +640,16 @@
     setiparam("LOGCHECK", 60);
     setiparam("KEYTIMEOUT", 40);
     setiparam("LISTMAX", 100);
-#ifdef HAVE_SELECT
-    setiparam("BAUD", getbaudrate(&shttyinfo));  /* get the output baudrate */
-#endif
+    /*
+     * We used to get the output baud rate here.  However, that's
+     * pretty irrelevant to a terminal on an X display and can lead
+     * to unnecessary delays if it's wrong (which it probably is).
+     * Furthermore, even if the output is slow it's very likely
+     * to be because of WAN delays, not covered by the output
+     * baud rate.
+     * So allow the user to set it in the special cases where it's
+     * useful.
+     */
     setsparam("TMPPREFIX", ztrdup(DEFAULT_TMPPREFIX));
     setsparam("TIMEFMT", ztrdup(DEFAULT_TIMEFMT));
     setsparam("WATCHFMT", ztrdup(default_watchfmt));
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.154
diff -u -r1.154 utils.c
--- Src/utils.c	7 Feb 2007 10:18:31 -0000	1.154
+++ Src/utils.c	7 Feb 2007 16:43:02 -0000
@@ -3435,108 +3435,6 @@
     return arg;
 }
 
-/* Return the output baudrate */
-
-#ifdef HAVE_SELECT
-/**/
-long
-getbaudrate(struct ttyinfo *shttyinfo)
-{
-    long speedcode;
-
-#ifdef HAS_TIO
-# if defined(HAVE_TCGETATTR) && defined(HAVE_TERMIOS_H)
-    speedcode = cfgetospeed(&shttyinfo->tio);
-# else
-    speedcode = shttyinfo->tio.c_cflag & CBAUD;
-# endif
-#else
-    speedcode = shttyinfo->sgttyb.sg_ospeed;
-#endif
-
-    switch (speedcode) {
-    case B0:
-	return (0L);
-    case B50:
-	return (50L);
-    case B75:
-	return (75L);
-    case B110:
-	return (110L);
-    case B134:
-	return (134L);
-    case B150:
-	return (150L);
-    case B200:
-	return (200L);
-    case B300:
-	return (300L);
-    case B600:
-	return (600L);
-#ifdef _B900
-    case _B900:
-	return (900L);
-#endif
-    case B1200:
-	return (1200L);
-    case B1800:
-	return (1800L);
-    case B2400:
-	return (2400L);
-#ifdef _B3600
-    case _B3600:
-	return (3600L);
-#endif
-    case B4800:
-	return (4800L);
-#ifdef _B7200
-    case _B7200:
-	return (7200L);
-#endif
-    case B9600:
-	return (9600L);
-#ifdef B19200
-    case B19200:
-	return (19200L);
-#else
-# ifdef EXTA
-    case EXTA:
-	return (19200L);
-# endif
-#endif
-#ifdef B38400
-    case B38400:
-	return (38400L);
-#else
-# ifdef EXTB
-    case EXTB:
-	return (38400L);
-# endif
-#endif
-#ifdef B57600
-    case B57600:
-	return (57600L);
-#endif
-#ifdef B115200
-    case B115200:
-	return (115200L);
-#endif
-#ifdef B230400
-    case B230400:
-	return (230400L);
-#endif
-#ifdef B460800
-    case B460800:
-	return (460800L);
-#endif
-    default:
-	if (speedcode >= 100)
-	    return speedcode;
-	break;
-    }
-    return (0L);
-}
-#endif
 
 /* Escape tokens and null characters.  Buf is the string which should be     *
  * escaped.  len is the length of the string.  If len is -1, buf should be   *
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.94
diff -u -r1.94 zle_main.c
--- Src/Zle/zle_main.c	8 Nov 2006 10:38:06 -0000	1.94
+++ Src/Zle/zle_main.c	7 Feb 2007 16:43:02 -0000
@@ -1074,6 +1074,7 @@
     Thingy initthingy;
 
 #if defined(HAVE_POLL) || defined(HAVE_SELECT)
+    /* may not be set, but that's OK since getiparam() returns 0 == off */
     baud = getiparam("BAUD");
     costmult = (baud) ? 3840000L / baud : 0;
 #endif



-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-07 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-07 11:43 PATCH: turn off baud rate compensation by default Peter Stephenson
2007-02-07 16:20 ` Bart Schaefer
2007-02-07 16:46   ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).