From: Gary Benson <gbenson@redhat.com>
To: Sandra Loosemore <sandra@codesourcery.com>
Cc: gdb-patches@sourceware.org, "Pedro Alves" <palves@redhat.com>,
"Joel Brobecker" <brobecker@adacore.com>,
"Doug Evans" <dje@google.com>,
"Jan Kratochvil" <jan.kratochvil@redhat.com>,
"André Pönitz" <apoenitz@t-online.de>,
"Paul Koning" <Paul_Koning@dell.com>
Subject: Re: [PATCH] Prelimit number of bytes to read in "vFile:pread:"
Date: Wed, 19 Aug 2015 10:51:00 -0000 [thread overview]
Message-ID: <20150819105054.GA22009@blade.nx> (raw)
In-Reply-To: <1439980862-21305-1-git-send-email-gbenson@redhat.com>
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/
next prev parent reply other threads:[~2015-08-19 10:51 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 17:22 [PATCH 0/2] Better handling of slow remote transfers Doug Evans
2015-08-11 18:55 ` Jan Kratochvil
2015-08-11 19:44 ` Doug Evans
2015-08-11 19:59 ` Joel Brobecker
2015-08-12 9:48 ` Gary Benson
2015-08-12 10:10 ` Pedro Alves
2015-08-12 10:38 ` Gary Benson
2015-08-12 11:29 ` Pedro Alves
2015-08-12 12:32 ` Gary Benson
2015-08-12 12:51 ` Pedro Alves
2015-08-12 13:02 ` Gary Benson
2015-08-12 13:34 ` Pedro Alves
2015-08-12 13:38 ` Gary Benson
2015-08-12 13:44 ` Gary Benson
2015-08-12 13:58 ` Pedro Alves
2015-08-12 14:44 ` Pedro Alves
2015-08-12 15:08 ` Gary Benson
2015-08-12 15:31 ` Pedro Alves
2015-08-12 15:45 ` Gary Benson
2015-08-12 13:29 ` Gary Benson
2015-08-14 18:26 ` Joel Brobecker
2015-08-14 22:26 ` Sandra Loosemore
2015-08-16 18:49 ` Joel Brobecker
[not found] ` <20150817085310.GC25320@blade.nx>
2015-08-17 14:26 ` Sandra Loosemore
2015-08-18 9:59 ` Gary Benson
2015-08-18 16:52 ` Sandra Loosemore
2015-08-19 1:27 ` Pedro Alves
2015-08-19 10:41 ` [PATCH] Prelimit number of bytes to read in "vFile:pread:" Gary Benson
2015-08-19 10:51 ` Gary Benson [this message]
2015-08-19 12:00 ` Pedro Alves
2015-08-19 16:43 ` Sandra Loosemore
2015-08-19 17:21 ` Gary Benson
2015-08-19 21:14 ` Sandra Loosemore
2015-08-20 14:48 ` Pedro Alves
2015-08-20 15:52 ` Pedro Alves
2015-08-20 17:00 ` Pedro Alves
2015-08-20 18:23 ` Sandra Loosemore
2015-08-21 14:52 ` [PATCH] remote: allow aborting long operations (e.g., file transfers) (Re: [PATCH] Prelimit number of bytes to read in "vFile:pread:") Pedro Alves
2015-08-21 17:12 ` Sandra Loosemore
2015-08-21 17:27 ` Pedro Alves
2015-08-25 10:57 ` Pedro Alves
2015-08-25 15:36 ` Pedro Alves
2015-08-25 20:19 ` GDB 7.10 release tentative date: Fri Aug 28 (was: "Re: [PATCH] remote: allow aborting long operations (e.g., file transfers) (Re: [PATCH] Prelimit number of bytes to read in "vFile:pread:")") Joel Brobecker
2015-08-24 8:45 ` [PATCH] remote: allow aborting long operations (e.g., file transfers) (Re: [PATCH] Prelimit number of bytes to read in "vFile:pread:") Gary Benson
2015-08-19 11:44 ` [PATCH] Prelimit number of bytes to read in "vFile:pread:" Pedro Alves
2015-08-19 13:07 ` [pushed] " Gary Benson
2015-08-19 13:42 ` [PATCH 0/2] Better handling of slow remote transfers Gary Benson
2015-08-20 14:46 ` Pedro Alves
2015-08-20 18:01 ` Gary Benson
2015-08-21 9:34 ` [pushed] Add readahead cache to gdb's vFile:pread (Re: [PATCH 0/2] Better handling of slow remote transfers) Pedro Alves
2015-08-11 20:00 ` [PATCH 0/2] Better handling of slow remote transfers Jan Kratochvil
2015-08-12 10:05 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150819105054.GA22009@blade.nx \
--to=gbenson@redhat.com \
--cc=Paul_Koning@dell.com \
--cc=apoenitz@t-online.de \
--cc=brobecker@adacore.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=palves@redhat.com \
--cc=sandra@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox