From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: profiling emacs-23.1 vs emacs-22.3 Date: Mon, 24 Aug 2009 15:52:36 +0900 Message-ID: References: <200908032029.n73KTi9h017528@godzilla.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1251096784 14546 80.91.229.12 (24 Aug 2009 06:53:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Aug 2009 06:53:04 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dan Nicolaescu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 24 08:52:57 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MfTQH-0008AT-3X for ged-emacs-devel@m.gmane.org; Mon, 24 Aug 2009 08:52:57 +0200 Original-Received: from localhost ([127.0.0.1]:34862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MfTQG-0003ZG-9r for ged-emacs-devel@m.gmane.org; Mon, 24 Aug 2009 02:52:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MfTQB-0003YT-Dn for emacs-devel@gnu.org; Mon, 24 Aug 2009 02:52:51 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MfTQ6-0003VU-4k for emacs-devel@gnu.org; Mon, 24 Aug 2009 02:52:50 -0400 Original-Received: from [199.232.76.173] (port=49459 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MfTQ6-0003VR-1A for emacs-devel@gnu.org; Mon, 24 Aug 2009 02:52:46 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:48032) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MfTQ5-0000Aq-Eo for emacs-devel@gnu.org; Mon, 24 Aug 2009 02:52:45 -0400 Original-Received: from mx1.aist.go.jp ([150.29.246.133]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MfTQ4-00086m-2p for emacs-devel@gnu.org; Mon, 24 Aug 2009 02:52:44 -0400 Original-Received: from rqsmtp2.aist.go.jp (rqsmtp2.aist.go.jp [150.29.254.123]) by mx1.aist.go.jp with ESMTP id n7O6qbtN009888; Mon, 24 Aug 2009 15:52:37 +0900 (JST) env-from (handa@m17n.org) Original-Received: from smtp4.aist.go.jp by rqsmtp2.aist.go.jp with ESMTP id n7O6qbW0013386; Mon, 24 Aug 2009 15:52:37 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp4.aist.go.jp with ESMTP id n7O6qbPq014512; Mon, 24 Aug 2009 15:52:37 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken with local (Exim 4.69) (envelope-from ) id 1MfTPw-0005rW-WA; Mon, 24 Aug 2009 15:52:36 +0900 In-reply-to: <200908032029.n73KTi9h017528@godzilla.ics.uci.edu> (message from Dan Nicolaescu on Mon, 3 Aug 2009 13:29:44 -0700 (PDT)) X-Detected-Operating-System: by mx20.gnu.org: Solaris 9 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:114550 Archived-At: In article <200908032029.n73KTi9h017528@godzilla.ics.uci.edu>, Dan Nicolaescu 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