[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: profiling emacs-23.1 vs emacs-22.3
From: |
Kenichi Handa |
Subject: |
Re: profiling emacs-23.1 vs emacs-22.3 |
Date: |
Mon, 24 Aug 2009 15:52:36 +0900 |
In article <address@hidden>, Dan Nicolaescu <address@hidden> 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
address@hidden
--- 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
- profiling emacs-23.1 vs emacs-22.3, Dan Nicolaescu, 2009/08/03
- Re: profiling emacs-23.1 vs emacs-22.3, Leo, 2009/08/04
- Re: profiling emacs-23.1 vs emacs-22.3, Chong Yidong, 2009/08/04
- Re: profiling emacs-23.1 vs emacs-22.3, Dan Nicolaescu, 2009/08/05
- Re: profiling emacs-23.1 vs emacs-22.3,
Kenichi Handa <=
- Re: profiling emacs-23.1 vs emacs-22.3, Dan Nicolaescu, 2009/08/24
- Re: profiling emacs-23.1 vs emacs-22.3, Kenichi Handa, 2009/08/24
- Re: profiling emacs-23.1 vs emacs-22.3, Dan Nicolaescu, 2009/08/24
- Re: profiling emacs-23.1 vs emacs-22.3, Kenichi Handa, 2009/08/25
- Re: profiling emacs-23.1 vs emacs-22.3, Dan Nicolaescu, 2009/08/25
- Re: profiling emacs-23.1 vs emacs-22.3, Kenichi Handa, 2009/08/26
- Re: profiling emacs-23.1 vs emacs-22.3, Dan Nicolaescu, 2009/08/26
- Re: profiling emacs-23.1 vs emacs-22.3, Kenichi Handa, 2009/08/26
- Re: profiling emacs-23.1 vs emacs-22.3, Andreas Schwab, 2009/08/26
- Re: profiling emacs-23.1 vs emacs-22.3, Kenichi Handa, 2009/08/26