From: Kenichi Handa <handa@m17n.org>
To: Dan Nicolaescu <dann@ics.uci.edu>
Cc: emacs-devel@gnu.org
Subject: Re: profiling emacs-23.1 vs emacs-22.3
Date: Mon, 24 Aug 2009 15:52:36 +0900 [thread overview]
Message-ID: <E1MfTPw-0005rW-WA@etlken> (raw)
In-Reply-To: <200908032029.n73KTi9h017528@godzilla.ics.uci.edu> (message from Dan Nicolaescu on Mon, 3 Aug 2009 13:29:44 -0700 (PDT))
In article <200908032029.n73KTi9h017528@godzilla.ics.uci.edu>, Dan Nicolaescu <dann@ics.uci.edu> writes:
> It can be seen that 23.1 is quite a bit slower, and that it has a lot of
> extra calls to char_table_ref.
> Are those calls necessary?
I found that the syntax of C is mostly defined in the parent of
CURRENT_SYNTAX_TABLE, and thus, in the call of SYNTAX_ENTRY (C),
the optimization for ASCII in this code (in lisp.h) doesn't work.
/* Almost equivalent to Faref (CT, IDX) with optimization for ASCII
characters. Do not check validity of CT. */
#define CHAR_TABLE_REF(CT, IDX) \
((ASCII_CHAR_P (IDX) \
&& SUB_CHAR_TABLE_P (XCHAR_TABLE (CT)->ascii) \
&& !NILP (XSUB_CHAR_TABLE (XCHAR_TABLE (CT)->ascii)->contents[IDX])) \
? XSUB_CHAR_TABLE (XCHAR_TABLE (CT)->ascii)->contents[IDX] \
: char_table_ref ((CT), (IDX)))
Could you try the attached patch? If it improves the
performance, I'll commit it.
---
Kenichi Handa
handa@m17n.org
--- lisp.h.~1.661.~ 2009-08-21 15:03:39.000000000 +0900
+++ lisp.h 2009-08-24 15:47:02.000000000 +0900
@@ -793,13 +793,37 @@
#define CHAR_TABLE_EXTRA_SLOTS(CT) \
(((CT)->size & PSEUDOVECTOR_SIZE_MASK) - CHAR_TABLE_STANDARD_SLOTS)
+#ifdef __GNUC__
+
+#define CHAR_TABLE_REF_ASCII(CT, IDX) \
+ ({struct Lisp_Char_Table *_tbl = NULL; \
+ Lisp_Object _val; \
+ do { \
+ _tbl = _tbl ? XCHAR_TABLE (_tbl->parent) : XCHAR_TABLE (CT); \
+ _val = (! SUB_CHAR_TABLE_P (_tbl->ascii) ? _tbl->ascii \
+ : XSUB_CHAR_TABLE (_tbl->ascii)->contents[IDX]); \
+ if (NILP (_val)) \
+ _val = _tbl->defalt; \
+ } while (NILP (_val) && ! NILP (_tbl->parent)); \
+ _val; })
+
+#else /* not __GNUC__ */
+
+#define CHAR_TABLE_REF_ASCII(CT, IDX) \
+ (! NILP (XCHAR_TABLE (CT)->ascii) \
+ ? (! SUB_CHAR_TABLE_P (XCHAR_TABLE (CT)->ascii) \
+ ? XCHAR_TABLE (CT)->ascii \
+ : ! NILP (XSUB_CHAR_TABLE (XCHAR_TABLE (CT)->ascii)->contents[IDX]) \
+ ? XSUB_CHAR_TABLE (XCHAR_TABLE (CT)->ascii)->contents[IDX] \
+ : char_table_ref ((CT), (IDX))) \
+ : char_table_ref ((CT), (IDX)))
+
+#endif /* not __GNUC__ */
+
/* Almost equivalent to Faref (CT, IDX) with optimization for ASCII
characters. Do not check validity of CT. */
-#define CHAR_TABLE_REF(CT, IDX) \
- ((ASCII_CHAR_P (IDX) \
- && SUB_CHAR_TABLE_P (XCHAR_TABLE (CT)->ascii) \
- && !NILP (XSUB_CHAR_TABLE (XCHAR_TABLE (CT)->ascii)->contents[IDX])) \
- ? XSUB_CHAR_TABLE (XCHAR_TABLE (CT)->ascii)->contents[IDX] \
+#define CHAR_TABLE_REF(CT, IDX) \
+ (ASCII_CHAR_P (IDX) ? CHAR_TABLE_REF_ASCII ((CT), (IDX)) \
: char_table_ref ((CT), (IDX)))
/* Almost equivalent to Faref (CT, IDX). However, if the result is
next prev parent reply other threads:[~2009-08-24 6:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-03 20:29 profiling emacs-23.1 vs emacs-22.3 Dan Nicolaescu
2009-08-04 17:10 ` Leo
2009-08-04 19:50 ` Chong Yidong
2009-08-04 19:56 ` Dan Nicolaescu
2009-08-05 7:47 ` Dan Nicolaescu
2009-08-24 6:52 ` Kenichi Handa [this message]
[not found] ` <200908240807.n7O87ubg024643@godzilla.ics.uci.edu>
2009-08-24 11:39 ` Kenichi Handa
2009-08-24 18:26 ` Dan Nicolaescu
2009-08-25 6:07 ` Kenichi Handa
2009-08-25 18:47 ` Dan Nicolaescu
2009-08-26 6:01 ` Kenichi Handa
2009-08-26 6:33 ` Dan Nicolaescu
2009-08-26 8:06 ` Kenichi Handa
2009-08-26 20:46 ` Andreas Schwab
2009-08-27 2:02 ` Kenichi Handa
2009-08-27 6:27 ` Kenichi Handa
2009-08-24 22:18 ` Alan Mackenzie
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1MfTPw-0005rW-WA@etlken \
--to=handa@m17n.org \
--cc=dann@ics.uci.edu \
--cc=emacs-devel@gnu.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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).