From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11898 invoked by alias); 3 Feb 2011 21:40:26 -0000 Received: (qmail 11883 invoked by uid 22791); 3 Feb 2011 21:40:26 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL,TW_EG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate7.uk.ibm.com (HELO mtagate7.uk.ibm.com) (194.196.100.167) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 Feb 2011 21:40:19 +0000 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate7.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p13LeAnC031118 for ; Thu, 3 Feb 2011 21:40:10 GMT Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p13LeCQE1957948 for ; Thu, 3 Feb 2011 21:40:12 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p13Le9DB031581 for ; Thu, 3 Feb 2011 14:40:09 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id p13Le89f031563; Thu, 3 Feb 2011 14:40:08 -0700 Message-Id: <201102032140.p13Le89f031563@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 03 Feb 2011 22:40:08 +0100 Subject: Re: performance of multithreading gets gradually worse under gdb To: tromey@redhat.com (Tom Tromey) Date: Thu, 03 Feb 2011 21:40:00 -0000 From: "Ulrich Weigand" Cc: markus@hyperion-imrt.org (Markus Alber), msnyder@vmware.com (Michael Snyder), gdb@sourceware.org, pedro@codesourcery.com In-Reply-To: from "Tom Tromey" at Feb 03, 2011 01:57:12 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00020.txt.bz2 Tom Tromey wrote: > >>>>> "Markus" == Markus Alber writes: > > Markus> See the attached file. It shows a similar behaviour, although it only > Markus> allocates 8kB per iteration. > Markus> You have to wait some time before this happens. > > Thanks. > > I changed 1<<24 to 1<<15, to spare my underpowered machine, and ran gdb > under massif. > > This part is interesting: > > ->20.78% (2,954,016B) 0x8253683: regcache_xmalloc_1 (regcache.c:232) > | ->20.78% (2,954,016B) 0x8253F85: get_thread_arch_regcache (regcache.c:463) > | ->20.78% (2,954,016B) 0x82540B5: get_thread_regcache (regcache.c:488) > | ->20.78% (2,954,016B) 0x81D1579: i386_linux_resume (i386-linux-nat.c:861) > | | ->20.78% (2,954,016B) 0x81D7D32: linux_nat_resume (linux-nat.c:1983) > > > I debugged gdb a little and it does indeed seem to be leaking here. > > I don't understand why registers_changed_ptid unconditionally clears > current_regcache. I suspect that may be the source of the problem. > > Perhaps someone who knows this code better could take a look. It seems this leak was introduced by Pedro's patch here: http://sourceware.org/ml/gdb-patches/2010-04/msg00960.html The function used to free all regcaches in the list and then reset current_regcache. The new code now takes care to selectively free only a subset of regcaches -- and then resets current_regcache anyway ... I guess we should just remove the current_regcache = NULL line now. (Actually, now that every thread always has a thread_info, the best thing would probably be anyway to hang each thread's regcaches off the thread_info, and do away with the global list completely.) Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com