From patchwork Wed Feb 4 11:55:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 4908 Received: (qmail 7819 invoked by alias); 4 Feb 2015 11:55:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 7795 invoked by uid 89); 4 Feb 2015 11:55:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 04 Feb 2015 11:55:45 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t14BtfRB003713 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Feb 2015 06:55:41 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t14BtcC2005231; Wed, 4 Feb 2015 06:55:38 -0500 Message-ID: <54D208B9.8060705@redhat.com> Date: Wed, 04 Feb 2015 12:55:37 +0100 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Eli Zaretskii , Doug Evans CC: gdb-patches@sourceware.org Subject: Re: [PATCH] Speed up "gdb -tui" output References: <83zj9v7urq.fsf@gnu.org> <83sifn7mpt.fsf@gnu.org> <83h9w278a9.fsf@gnu.org> <83bnma75yt.fsf@gnu.org> <837fwy74ny.fsf@gnu.org> <21677.44074.982761.250152@ruffy2.mtv.corp.google.com> <83iog2y7s9.fsf@gnu.org> <83vbjnjpfb.fsf@gnu.org> <54D10AE6.8080500@redhat.com> In-Reply-To: <54D10AE6.8080500@redhat.com> On 02/03/2015 06:52 PM, Pedro Alves wrote: > I'm working on this now. Turns out that flushing on every line like in my patch was still considerably (and noticeably) slower than delaying until an explicit gdb_flush is done, like in Doug's. So I went with Doug's version. The recent changes to unify CLI/TUI interface to readline tab completion made the patch even simpler. Here's what I pushed to master. --- From 518be979d905d8e8708c70149fdb3207aba53aa1 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Wed, 4 Feb 2015 12:27:28 +0100 Subject: [PATCH] Speed up GDB's TUI output In the TUI mode, we call wrefresh after outputting every single character. This results in the I/O becoming very slow. Fix this by delaying refreshing the console window until an explicit flush of gdb_stdout is requested, or a write to any other (unbuffered) file is done. 2015-02-04 Doug Evans Pedro Alves Eli Zaretskii PR tui/17810 * tui/tui-command.c (tui_refresh_cmd_win): New function. * tui/tui-command.c (tui_refresh_cmd_win): Declare. * tui/tui-file.c: #include tui/tui-command.h. (tui_file_fputs): Refresh command window if stream is not gdb_stdout. (tui_file_flush): Refresh command window if stream is gdb_stdout. * tui/tui-io.c (tui_puts): Remove calls to wrefresh, fflush. --- gdb/ChangeLog | 12 ++++++++++++ gdb/tui/tui-command.c | 15 +++++++++++++++ gdb/tui/tui-command.h | 3 +++ gdb/tui/tui-file.c | 10 +++++++++- gdb/tui/tui-io.c | 9 ++++----- 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1116853..d5ec6d1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2015-02-04 Doug Evans + Pedro Alves + Eli Zaretskii + + PR tui/17810 + * tui/tui-command.c (tui_refresh_cmd_win): New function. + * tui/tui-command.c (tui_refresh_cmd_win): Declare. + * tui/tui-file.c: #include tui/tui-command.h. + (tui_file_fputs): Refresh command window if stream is not gdb_stdout. + (tui_file_flush): Refresh command window if stream is gdb_stdout. + * tui/tui-io.c (tui_puts): Remove calls to wrefresh, fflush. + 2015-02-04 Pedro Alves Fix build breakage. diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c index d1a5ddb..3551063 100644 --- a/gdb/tui/tui-command.c +++ b/gdb/tui/tui-command.c @@ -129,3 +129,18 @@ tui_dispatch_ctrl_char (unsigned int ch) return c; } } + +/* See tui-command.h. */ + +void +tui_refresh_cmd_win (void) +{ + WINDOW *w = TUI_CMD_WIN->generic.handle; + + wrefresh (w); + + /* FIXME: It's not clear why this is here. + It was present in the original tui_puts code and is kept in order to + not introduce some subtle breakage. */ + fflush (stdout); +} diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h index 8cc5be4..ede2ecc 100644 --- a/gdb/tui/tui-command.h +++ b/gdb/tui/tui-command.h @@ -24,4 +24,7 @@ extern unsigned int tui_dispatch_ctrl_char (unsigned int); +/* Refresh the command window. */ +extern void tui_refresh_cmd_win (void); + #endif diff --git a/gdb/tui/tui-file.c b/gdb/tui/tui-file.c index b32cfa6..4b4b92c 100644 --- a/gdb/tui/tui-file.c +++ b/gdb/tui/tui-file.c @@ -20,7 +20,7 @@ #include "ui-file.h" #include "tui/tui-file.h" #include "tui/tui-io.h" - +#include "tui/tui-command.h" #include "tui.h" /* A ``struct ui_file'' that is compatible with all the legacy @@ -179,6 +179,10 @@ tui_file_fputs (const char *linebuffer, struct ui_file *file) else { tui_puts (linebuffer); + /* gdb_stdout is buffered, and the caller must gdb_flush it at + appropriate times. Other streams are not so buffered. */ + if (file != gdb_stdout) + tui_refresh_cmd_win (); } } @@ -239,6 +243,10 @@ tui_file_flush (struct ui_file *file) case astring: break; case afile: + /* gdb_stdout is buffered. Other files are always flushed on + every write. */ + if (file == gdb_stdout) + tui_refresh_cmd_win (); fflush (stream->ts_filestream); break; } diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 2b5a166..21b2a00 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -159,7 +159,10 @@ tui_putc (char c) tui_puts (buf); } -/* Print the string in the curses command window. */ +/* Print the string in the curses command window. + The output is buffered. It is up to the caller to refresh the screen + if necessary. */ + void tui_puts (const char *string) { @@ -201,10 +204,6 @@ tui_puts (const char *string) TUI_CMD_WIN->detail.command_info.curch); TUI_CMD_WIN->detail.command_info.start_line = TUI_CMD_WIN->detail.command_info.cur_line; - - /* We could defer the following. */ - wrefresh (w); - fflush (stdout); } /* Readline callback.