From patchwork Sun Jan 11 20:33:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 4615 Received: (qmail 15593 invoked by alias); 11 Jan 2015 20:34:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 15580 invoked by uid 89); 11 Jan 2015 20:34:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-yh0-f52.google.com Received: from mail-yh0-f52.google.com (HELO mail-yh0-f52.google.com) (209.85.213.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 11 Jan 2015 20:34:34 +0000 Received: by mail-yh0-f52.google.com with SMTP id z6so8167932yhz.11 for ; Sun, 11 Jan 2015 12:34:32 -0800 (PST) X-Received: by 10.236.53.65 with SMTP id f41mr16577996yhc.182.1421008472190; Sun, 11 Jan 2015 12:34:32 -0800 (PST) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by mx.google.com with ESMTPSA id f45sm9159930yho.5.2015.01.11.12.34.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Jan 2015 12:34:31 -0800 (PST) From: Doug Evans To: gdb-patches@sourceware.org Subject: [COMMITTED PATCH] symtab.c (eq_symbol_entry): Use SYMBOL_SEARCH_NAME and symbol_matches_domain. Date: Sun, 11 Jan 2015 12:33:43 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. The cache was a bit conservative in checking for hits. This patch makes the cache use the same tests normal lookup does for better hit rates. Regression tested on amd64-linux. btw, I have a gmonster2 perf testcase that provides an example of the speedup. For this program, and 100 shared libraries, #include std::string hello ("Hello."); int main () { return 0; } Measuring the time to do two "ptype hello" commands in a row after running to main, Before (without symbol lookup cache): gmonster2-ptype cpu_time 1-sos 0.115144 gmonster2-ptype cpu_time 10-sos 0.972049 gmonster2-ptype cpu_time 100-sos 17.313381 gmonster2-ptype wall_time 1-sos 0.115725040436 gmonster2-ptype wall_time 10-sos 0.977412939072 gmonster2-ptype wall_time 100-sos 17.4151601791 gmonster2-ptype vmsize 1-sos 201276 gmonster2-ptype vmsize 10-sos 645708 gmonster2-ptype vmsize 100-sos 5084528 After (with symbol lookup cache, plus this patch): gmonster2-ptype cpu_time 1-sos 0.018781 gmonster2-ptype cpu_time 10-sos 0.064274 gmonster2-ptype cpu_time 100-sos 0.860109 gmonster2-ptype wall_time 1-sos 0.0188720226288 gmonster2-ptype wall_time 10-sos 0.0647039413452 gmonster2-ptype wall_time 100-sos 0.865196943283 gmonster2-ptype vmsize 1-sos 201352 gmonster2-ptype vmsize 10-sos 645784 gmonster2-ptype vmsize 100-sos 5084584 I ran the experiment a few times by hand to verify the reported numbers are accurate. This included diff'ing the before/after output to verify they're identical. [btw, seems like the perf test harness needs to truncate wall_time like cpu_time] 2015-01-11 Doug Evans * symtab.c (eq_symbol_entry): Use SYMBOL_SEARCH_NAME and symbol_matches_domain for symbol comparisons. diff --git a/gdb/symtab.c b/gdb/symtab.c index 7193131..3679b43 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1200,27 +1200,53 @@ eq_symbol_entry (const struct symbol_cache_slot *slot, } else { - slot_name = SYMBOL_LINKAGE_NAME (slot->value.found); + slot_name = SYMBOL_SEARCH_NAME (slot->value.found); slot_domain = SYMBOL_DOMAIN (slot->value.found); } /* NULL names match. */ if (slot_name == NULL && name == NULL) - ; - else if (slot_name != NULL && name != NULL) { - if (strcmp (slot_name, name) != 0) + /* But there's no point in calling symbol_matches_domain in the + SYMBOL_SLOT_FOUND case. */ + if (slot_domain != domain) return 0; } + else if (slot_name != NULL && name != NULL) + { + /* It's important that we use the same comparison that was done the + first time through. If the slot records a found symbol, then this + means using strcmp_iw on SYMBOL_SEARCH_NAME. See dictionary.c. + It also means using symbol_matches_domain for found symbols. + See block.c. + + If the slot records a not-found symbol, then require a precise match. + We could still be lax with whitespace like strcmp_iw though. */ + + if (slot->state == SYMBOL_SLOT_NOT_FOUND) + { + if (strcmp (slot_name, name) != 0) + return 0; + if (slot_domain != domain) + return 0; + } + else + { + struct symbol *sym = slot->value.found; + + if (strcmp_iw (slot_name, name) != 0) + return 0; + if (!symbol_matches_domain (SYMBOL_LANGUAGE (sym), + slot_domain, domain)) + return 0; + } + } else { /* Only one name is NULL. */ return 0; } - if (slot_domain != domain) - return 0; - return 1; }