From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#14518: C and Emacs Lisp code parts Date: Wed, 06 Jul 2016 17:52:54 +0300 Message-ID: <83shvmn7i1.fsf@gnu.org> References: <624c3d37-c829-7187-a699-7d7bbc211a20@online.de> <83ziq1u668.fsf@gnu.org> <20160701091653.GA2531@acm.fritz.box> <5fcdeec5-fcde-d0ab-e256-e1b2ceb40ccb@online.de> <83shvttsq6.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1467817862 18231 80.91.229.3 (6 Jul 2016 15:11:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Jul 2016 15:11:02 +0000 (UTC) Cc: 14518@debbugs.gnu.org To: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 06 17:10:53 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bKoTV-00085p-42 for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jul 2016 17:10:53 +0200 Original-Received: from localhost ([::1]:34092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKoTU-0007uV-9S for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jul 2016 11:10:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKoDH-0005Jd-VE for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2016 10:54:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKoDC-0001Xk-Q8 for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2016 10:54:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKoDC-0001Xg-Mf for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2016 10:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bKoDC-00018t-FX for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2016 10:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Jul 2016 14:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14518 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14518-submit@debbugs.gnu.org id=B14518.14678167994340 (code B ref 14518); Wed, 06 Jul 2016 14:54:02 +0000 Original-Received: (at 14518) by debbugs.gnu.org; 6 Jul 2016 14:53:19 +0000 Original-Received: from localhost ([127.0.0.1]:39630 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKoCV-00017w-59 for submit@debbugs.gnu.org; Wed, 06 Jul 2016 10:53:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57908) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKoCU-00017j-71 for 14518@debbugs.gnu.org; Wed, 06 Jul 2016 10:53:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKoCK-0001Hl-Pn for 14518@debbugs.gnu.org; Wed, 06 Jul 2016 10:53:12 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:35195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKoCK-0001HW-MW; Wed, 06 Jul 2016 10:53:08 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4411 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bKoCJ-0006HI-Nl; Wed, 06 Jul 2016 10:53:08 -0400 In-reply-to: (message from Andreas =?UTF-8?Q?R=C3=B6hler?= on Wed, 6 Jul 2016 09:25:54 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:120496 Archived-At: [Please don't cross-post between the bug list and emacs-deve.] > From: Andreas Röhler > Date: Wed, 6 Jul 2016 09:25:54 +0200 > Cc: Eli Zaretskii > > abbrev--describe 36050 15.224345396 0.0004223119 > abbrev-edit-save-buffer 1 8.034011581 8.034011581 > abbrev-edit-save-to-file 1 8.033998314 8.033998314 > abbrev--write 18025 5.8414600190 0.0003240754 > define-abbrevs 1 1.334075568 1.334075568 > abbrev-get 107835 0.5151135200 4.776...e-06 > abbrev-table-get 36964 0.1173239610 3.174...e-06 > abbrev-table-put 18320 0.0690998279 3.771...e-06 > abbrev-table-empty-p 584 0.010703864 1.832...e-05 > abbrev-table-p 584 0.0050513859 8.649...e-06 > abbreviate-file-name 91 0.002899625 3.186...e-05 > abbrev-table-name 2 0.000254252 0.000127126 > abbrev-mode 1 1.4463e-05 1.4463e-05 Thanks. It is better to use profiler.el, because it doesn't change the code being profiled, and also can profile primitives. If you can produce a profile using profiler.el, and present it in fully expanded form, please do. Also, I'm not sure how to read the above (and the elp documentation doesn't really help). What was the total elapsed time it took to run this scenario? Is it the sum of all the numbers in the first column, i.e. about 37 sec? Or does the elapsed time for each function include all of its callers? Either way, the numbers look strange: why did it take abbrev-edit-save-to-file, whose body is almost empty, 8 sec, whereas abbrev--describe took 15 sec? What am I missing? Anyway, I looked at the v22 C implementation of the relevant functions, and I see that the Lisp implementation is essentially identical to C. For example, here's the Lisp implementation of abbrev--describe: (defun abbrev--describe (sym) (when (symbol-value sym) (prin1 (symbol-name sym)) (if (null (abbrev-get sym :system)) (indent-to 15 1) (insert " (sys)") (indent-to 20 1)) (prin1 (abbrev-get sym :count)) (indent-to 20 1) (prin1 (symbol-value sym)) (when (symbol-function sym) (indent-to 45 1) (prin1 (symbol-function sym))) (terpri))) and here's what we had in Emacs 22: static void describe_abbrev (sym, stream) Lisp_Object sym, stream; { Lisp_Object one, count, system_flag; if (INTEGERP (XSYMBOL (sym)->plist)) { count = XSYMBOL (sym)->plist; system_flag = Qnil; } else { count = Fget (sym, Qcount); system_flag = Fget (sym, Qsystem_type); } if (NILP (SYMBOL_VALUE (sym))) return; one = make_number (1); Fprin1 (Fsymbol_name (sym), stream); if (!NILP (system_flag)) { insert_string (" (sys)"); Findent_to (make_number (20), one); } else Findent_to (make_number (15), one); Fprin1 (count, stream); Findent_to (make_number (20), one); Fprin1 (SYMBOL_VALUE (sym), stream); if (!NILP (XSYMBOL (sym)->function)) { Findent_to (make_number (45), one); Fprin1 (XSYMBOL (sym)->function, stream); } Fterpri (stream); } As you see, both versions call the same primitives and do little else. I see the same basic picture with all the functions which are hot spots according to the elp profile. So if indeed the Lisp version is significantly slower, the only way I can explain that is that we have some very basic inefficiency in the byte-code interpreter, something that, if true, is completely unrelated to abbrev.el itself. So please do the same as you did here with Emacs 22.3, and with the same abbrevs list, and tell how much elapsed time this takes on the same system. We should anyway analyze this comparatively, not in absolute terms. (Alternatively, post here the list of the abbrevs you used in your experiment, then others could do these measurements, compare them, and maybe provide more information/investigate deeper.) Thanks.