From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118469 invoked by alias); 19 Aug 2015 10:51:00 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 118459 invoked by uid 89); 19 Aug 2015 10:50:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS 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, 19 Aug 2015 10:50:58 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 362C519F22C; Wed, 19 Aug 2015 10:50:57 +0000 (UTC) Received: from blade.nx (ovpn-116-91.ams2.redhat.com [10.36.116.91]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7JAouSM019061; Wed, 19 Aug 2015 06:50:56 -0400 Received: by blade.nx (Postfix, from userid 1000) id D1B7E262FAE; Wed, 19 Aug 2015 11:50:54 +0100 (BST) Date: Wed, 19 Aug 2015 10:51:00 -0000 From: Gary Benson To: Sandra Loosemore Cc: gdb-patches@sourceware.org, Pedro Alves , Joel Brobecker , Doug Evans , Jan Kratochvil , =?iso-8859-1?Q?Andr=E9_P=F6nitz?= , Paul Koning Subject: Re: [PATCH] Prelimit number of bytes to read in "vFile:pread:" Message-ID: <20150819105054.GA22009@blade.nx> References: <55D3DB83.4050204@redhat.com> <1439980862-21305-1-git-send-email-gbenson@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1439980862-21305-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00506.txt.bz2 Sandra, could you please try this patch on your Altera 3c120 and on your PandaBoard? I'm interested to know what the times are now. Cheers, Gary Gary Benson wrote: > Pedro Alves wrote: > > The fact that Gary's chunk size limiting patch made things much > > faster on the nios2 board is still mysterious to me. I'd expect > > the slowness to be latency bound, given the request/response > > nature of the RSP, but then I'd expect that more chunking would > > slow things down, not speed it up. > > I think I figured this out... > > While handling "vFile:pread:" packets, gdbserver would read the > number of bytes requested regardless of whether this would fit > into the reply packet. gdbserver would then return a packet's > worth of data and discard the remainder. When accessing large > binaries GDB (via BFD) routinely makes large "vFile:pread:" > requests, resulting in gdbserver allocating large unnecessary > buffers and reading some portions of the file many times over. > > This commit causes gdbserver to limit the number of bytes to be > read to a sensible maximum prior to allocating buffers and reading > data. > > Built and regtested on RHEL 6.6 x86_64. > > May I push this to HEAD and to the branch? > > Thanks, > Gary > > --- > gdb/gdbserver/ChangeLog: > > * hostio.c (handle_pread): Do not attempt to read more data > than hostio_reply_with_data can fit in a packet. > --- > gdb/gdbserver/ChangeLog | 5 +++++ > gdb/gdbserver/hostio.c | 12 ++++++++++++ > 2 files changed, 17 insertions(+), 0 deletions(-) > > diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c > index b38a6bd..8788f07 100644 > --- a/gdb/gdbserver/hostio.c > +++ b/gdb/gdbserver/hostio.c > @@ -344,6 +344,7 @@ handle_pread (char *own_buf, int *new_packet_len) > { > int fd, ret, len, offset, bytes_sent; > char *p, *data; > + static int max_reply_size = -1; > > p = own_buf + strlen ("vFile:pread:"); > > @@ -359,6 +360,17 @@ handle_pread (char *own_buf, int *new_packet_len) > return; > } > > + /* Do not attempt to read more than the maximum number of bytes > + hostio_reply_with_data can fit in a packet. We may still read > + too much because of escaping, but this is handled below. */ > + if (max_reply_size == -1) > + { > + sprintf (own_buf, "F%x;", PBUFSIZ); > + max_reply_size = PBUFSIZ - strlen (own_buf); > + } > + if (len > max_reply_size) > + len = max_reply_size; > + > data = xmalloc (len); > #ifdef HAVE_PREAD > ret = pread (fd, data, len, offset); > -- > 1.7.1 > -- http://gbenson.net/