From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25106 invoked by alias); 26 Apr 2011 17:26:16 -0000 Received: (qmail 25075 invoked by uid 22791); 26 Apr 2011 17:26:15 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from exprod6og112.obsmtp.com (HELO exprod6og112.obsmtp.com) (64.18.1.29) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Apr 2011 17:26:01 +0000 Received: from cfexcas02.americas.cray.com ([136.162.34.11]) (using TLSv1) by exprod6ob112.postini.com ([64.18.5.12]) with SMTP ID DSNKTbcAKDxVvc924QMXAVKlTytvNjJunumg@postini.com; Tue, 26 Apr 2011 10:26:01 PDT Received: from lnx-andrewg.us.cray.com (172.31.17.22) by cfexcas02.americas.cray.com (172.30.74.226) with Microsoft SMTP Server (TLS) id 8.3.137.0; Tue, 26 Apr 2011 12:25:59 -0500 Message-ID: <4DB70027.2040006@cray.com> Date: Tue, 26 Apr 2011 17:26:00 -0000 From: Andrew Gontarek User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100317 SUSE/3.0.4-2.3 Lightning/1.0b1 Thunderbird/3.0.4 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH] Bug 12705: Extremely poor performance when printing large arrays Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2011-04/txt/msg00483.txt.bz2 Hello, I noticed that when I wanted to print out a very large array, the performance was unbearably slow. This can be observed by setting print repeats and print elements to 0 (unlimited) and then attempting to print a large array. set print repeats 0 set print elements 0 I discovered this behavior while attempting to directly parse a very large array's value directly using gdb/mi with the command -data-evaluate-expression. The following is a patch which fixes this issue: Index: valprint.c =================================================================== RCS file: /cvs/src/src/gdb/valprint.c,v retrieving revision 1.110 diff -c -p -r1.110 valprint.c *** valprint.c 14 Feb 2011 11:35:45 -0000 1.110 --- valprint.c 26 Apr 2011 16:57:39 -0000 *************** val_print_array_elements (struct type *t *** 1247,1261 **** rep1 = i + 1; reps = 1; ! while (rep1 < len && value_available_contents_eq (val, embedded_offset + i * eltlen, val, embedded_offset + rep1 * eltlen, eltlen)) ! { ! ++reps; ! ++rep1; } if (reps > options->repeat_count_threshold) --- 1247,1267 ---- rep1 = i + 1; reps = 1; ! ! /* Only check for reps if repeat_count_threshold is not set to ! UINT_MAX (unlimited) */ ! if (options->repeat_count_threshold < UINT_MAX) ! { ! while (rep1 < len && value_available_contents_eq (val, embedded_offset + i * eltlen, val, embedded_offset + rep1 * eltlen, eltlen)) ! { ! ++reps; ! ++rep1; ! } } if (reps > options->repeat_count_threshold) Index: ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/ChangeLog,v retrieving revision 1.12951 diff -c -p -r1.12951 ChangeLog *** ChangeLog 26 Apr 2011 15:40:56 -0000 1.12951 --- ChangeLog 26 Apr 2011 17:13:39 -0000 *************** *** 1,3 **** --- 1,9 ---- + 2011-04-26 Andrew Gontarek + + * valprint.c (val_print_array_elements): Fixed poor performance + of printing very large arrays with repeat_count_threshold set + to unlimited. New comment. + 2011-04-26 Michael Walle * remote.c (remote_start_remote): Ack packet after sending the -- Andrew Gontarek PE debugger development at CRAY Ph: 651-605-9176