From: Shawn Landden <shawn@git.icu>
To: gdb-patches@sourceware.org
Cc: Shawn Landden <shawn@git.icu>
Subject: [PATCH] Fix slow and non-deterministic behavior of isspace() and tolower()
Date: Sun, 09 Jun 2019 15:17:00 -0000 [thread overview]
Message-ID: <20190609151704.16061-1-shawn@git.icu> (raw)
I was getting 8% and 6% cpu usage in tolower() and isspace(),
respectively, waiting for a breakpoint on ppc64el.
Also, gdb doesn't want non-deterministic behavior here.
---
gdb/utils.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/gdb/utils.c b/gdb/utils.c
index 9686927473..d36b942cc5 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2626,10 +2626,29 @@ strcmp_iw (const char *string1, const char *string2)
user searches for "foo", then strcmp will sort "foo" before "foo$".
Then lookup_partial_symbol will notice that strcmp_iw("foo$",
"foo") is false, so it won't proceed to the actual match of
"foo(int)" with "foo". */
+/* glibc versions of these have non-deterministic locale-dependant behavior,
+ and are very slow, taking 8% and 6% of total CPU time with some use-cases */
+#undef isspace
+static int isspace(int c)
+{
+ return c == ' ' || (unsigned)c-'\t' < 5;
+}
+#undef isupper
+static int isupper(int c)
+{
+ return (unsigned)c-'A' < 26;
+}
+#undef tolower
+static int tolower(int c)
+{
+ if (isupper(c)) return c | 32;
+ return c;
+}
+
int
strcmp_iw_ordered (const char *string1, const char *string2)
{
const char *saved_string1 = string1, *saved_string2 = string2;
enum case_sensitivity case_pass = case_sensitive_off;
--
2.20.1
next reply other threads:[~2019-06-09 15:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-09 15:17 Shawn Landden [this message]
2019-06-09 15:42 ` Eli Zaretskii
2019-06-09 15:51 ` Shawn Landden
2019-06-10 21:14 ` John Baldwin
2019-06-10 21:30 ` [PATCH v2] " Shawn Landden
2019-06-21 17:35 ` Pedro Alves
2019-06-21 17:59 ` Shawn Landden
2019-06-21 18:08 ` Pedro Alves
2019-06-21 19:20 ` [PATCH] " Shawn Landden
2019-06-21 20:12 ` Pedro Alves
2019-06-21 20:30 ` Shawn Landden
2019-06-21 21:14 ` 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=20190609151704.16061-1-shawn@git.icu \
--to=shawn@git.icu \
--cc=gdb-patches@sourceware.org \
/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