From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29491 invoked by alias); 25 Jul 2013 12:09:20 -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 29482 invoked by uid 89); 25 Jul 2013 12:09:20 -0000 X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_20,RCVD_VIA_APNIC,RDNS_NONE,SPF_SOFTFAIL,TW_CP autolearn=no version=3.3.1 Received: from Unknown (HELO ozlabs.org) (203.10.76.45) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 25 Jul 2013 12:09:19 +0000 Received: from kryten (ppp121-44-48-234.lns20.syd6.internode.on.net [121.44.48.234]) (using SSLv3 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id 5189D2C00CC for ; Thu, 25 Jul 2013 22:09:10 +1000 (EST) Date: Thu, 25 Jul 2013 12:09:00 -0000 From: Anton Blanchard To: gdb-patches@sourceware.org Subject: [PATCH] Improve performance of large restore commands Message-ID: <20130725220858.58184193@kryten> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SW-Source: 2013-07/txt/msg00611.txt.bz2 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 * 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;