From 69bde6077e178a0049763e42c551574f7aa84a81 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Fri, 31 Aug 2012 20:19:55 +0200 Subject: [PATCH] pty: improve application data read-path The kernel tty buffer is actually too small to buffer data for 20ms, which is the time a frame may take in kmscon so we can still get 50 fps. However, profiling showed that we often read multiple times from the pty. We can optimize this by increasing the buffer to match the tty internal buffer. The kernel internal buffering is currently the only performance slowdown that we have. That is, the data an application writes while we do a single rendering is more than the kernel can buffer. Therefore, the application waits until we read from the pty again. We then wait with redrawing until the next vblank. Signed-off-by: David Herrmann --- src/pty.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pty.c b/src/pty.c index b3b904b..acc7296 100644 --- a/src/pty.c +++ b/src/pty.c @@ -43,8 +43,7 @@ #define LOG_SUBSYSTEM "pty" -/* Match N_TTY_BUF_SIZE from the kernel to read as much as we can. */ -#define KMSCON_NREAD 4096 +#define KMSCON_NREAD 16384 struct kmscon_pty { unsigned long ref; @@ -324,7 +323,10 @@ static void pty_input(struct ev_fd *fd, int mask, void *data) log_err("cannot read from pty: %m"); goto err; } - } while (len > 0 && --num); + } while (--num && len > 0); + + if (!num) + log_debug("cannot read application data fast enough"); } return;