From: Tom Tromey <tom@tromey.com>
To: Tom Tromey <tom@tromey.com>
Cc: Pedro Alves <palves@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [RFA 2/2] Simplify the psymbol hash function
Date: Thu, 09 Nov 2017 14:09:00 -0000 [thread overview]
Message-ID: <87efp7r1bk.fsf@tromey.com> (raw)
In-Reply-To: <87tvy4r3k4.fsf@tromey.com> (Tom Tromey's message of "Wed, 08 Nov 2017 12:08:43 -0700")
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> I can add comments to the psymbol hash and comparison functions to
Tom> mention this.
How's this?
Tom
commit a042125cb391b1b489f272353a4c90068fc92954
Author: Tom Tromey <tom@tromey.com>
Date: Thu Nov 2 12:48:44 2017 -0600
Simplify the psymbol hash function
This patch simplifies the psymbol_hash function, by changing it not to
examine the contents of the symbol's name. This change just mirrors
what psymbol_compare already does -- it is checking for name equality,
which is ok because symbol names are interned in symbol_set_names.
This change speeds up psymbol reading. "gdb -nx -batch gdb"
previously took ~1.8 seconds on my machine, and with this patch it now
takes ~1.7 seconds.
gdb/ChangeLog
2017-11-09 Tom Tromey <tom@tromey.com>
* psymtab.c (psymbol_hash): Do not hash string contents.
(psymbol_compare): Add comment.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 03ccf9d57c..014ae04a3d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-09 Tom Tromey <tom@tromey.com>
+
+ * psymtab.c (psymbol_hash): Do not hash string contents.
+ (psymbol_compare): Add comment.
+
2017-11-04 Tom Tromey <tom@tromey.com>
* dictionary.c (dict_hash): Move "TKB" check into the "switch".
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 29d40dcc04..06a65bf26e 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1548,7 +1548,9 @@ psymbol_hash (const void *addr, int length)
h = hash_continue (&lang, sizeof (unsigned int), h);
h = hash_continue (&domain, sizeof (unsigned int), h);
h = hash_continue (&theclass, sizeof (unsigned int), h);
- h = hash_continue (psymbol->ginfo.name, strlen (psymbol->ginfo.name), h);
+ /* Note that psymbol names are interned via symbol_set_names, so
+ there's no need to hash the contents of the name here. */
+ h = hash_continue (&psymbol->ginfo.name, sizeof (psymbol->ginfo.name), h);
return h;
}
@@ -1568,6 +1570,9 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
&& sym1->ginfo.language == sym2->ginfo.language
&& PSYMBOL_DOMAIN (sym1) == PSYMBOL_DOMAIN (sym2)
&& PSYMBOL_CLASS (sym1) == PSYMBOL_CLASS (sym2)
+ /* Note that psymbol names are interned via
+ symbol_set_names, so there's no need to compare the
+ contents of the name here. */
&& sym1->ginfo.name == sym2->ginfo.name);
}
next prev parent reply other threads:[~2017-11-09 14:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-04 16:14 [RFA 0/2] some minor symbol-reading performance improvements Tom Tromey
2017-11-04 16:14 ` [RFA 2/2] Simplify the psymbol hash function Tom Tromey
2017-11-08 11:12 ` Pedro Alves
2017-11-08 11:42 ` Pedro Alves
2017-11-08 19:08 ` Tom Tromey
2017-11-09 14:09 ` Tom Tromey [this message]
2017-11-09 14:10 ` Pedro Alves
2017-11-04 16:14 ` [RFA 1/2] Speed up dict_hash Tom Tromey
2017-11-08 10:46 ` Pedro Alves
2017-11-08 18:44 ` Tom Tromey
2017-11-08 22:41 ` Pedro Alves
2017-11-08 23:01 ` Tom Tromey
2017-11-08 23:51 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87efp7r1bk.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).