I noticed a large (100MB) restore took hours to complete. The problem
is target_xfer_partial repeatedly mallocs and memcpys the entire
100MB buffer only to find a small portion of it is actually written.
We already cap reads to 4K, so do that for writes. The testcase that
originally took hours now takes 50 seconds.
--
2013-07-25 Anton Blanchard <anton@samba.org>
* target.c (target_write_with_progress): Cap write to 4K
Index: b/gdb/target.c
===================================================================
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2287,9 +2287,11 @@ target_write_with_progress (struct targe
while (xfered < len)
{
+ /* Cap the write to 4K */
+ int to_transfer = min(4096, len - xfered);
LONGEST xfer = target_write_partial (ops, object, annex,
(gdb_byte *) buf + xfered,
- offset + xfered, len - xfered);
+ offset + xfered, to_transfer);
if (xfer == 0)
return xfered;