From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#11657: 24.1.50; Byte compiler is a lot slower now, when run interpreted Date: Sun, 10 Jun 2012 10:48:39 -0400 Message-ID: References: <83pq98u3h8.fsf@gnu.org> <83y5nvswfs.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1339339786 8057 80.91.229.3 (10 Jun 2012 14:49:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 10 Jun 2012 14:49:46 +0000 (UTC) Cc: 11657@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 10 16:49:44 2012 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 1SdjSS-0002sv-UV for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Jun 2012 16:49:37 +0200 Original-Received: from localhost ([::1]:55233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdjSS-0006Wr-OA for geb-bug-gnu-emacs@m.gmane.org; Sun, 10 Jun 2012 10:49:36 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdjSP-0006Wg-ON for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 10:49:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdjSN-0008AA-SK for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 10:49:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55481) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdjSN-0008A2-Ow for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 10:49:31 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SdjUo-0000He-19 for bug-gnu-emacs@gnu.org; Sun, 10 Jun 2012 10:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Jun 2012 14:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11657 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11657-submit@debbugs.gnu.org id=B11657.13393398741038 (code B ref 11657); Sun, 10 Jun 2012 14:52:01 +0000 Original-Received: (at 11657) by debbugs.gnu.org; 10 Jun 2012 14:51:14 +0000 Original-Received: from localhost ([127.0.0.1]:36794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SdjU1-0000Gg-LH for submit@debbugs.gnu.org; Sun, 10 Jun 2012 10:51:13 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:31811) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SdjTz-0000GY-L4 for 11657@debbugs.gnu.org; Sun, 10 Jun 2012 10:51:11 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FAG6Zu09FxIfQ/2dsb2JhbABEsEiDSYEIghUBAQQBViMQCzQSFBgNJIgcBboJkEQDozOBWIMF X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="190911761" Original-Received: from 69-196-135-208.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.196.135.208]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 10 Jun 2012 10:48:40 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 8E7FEAE221; Sun, 10 Jun 2012 10:48:39 -0400 (EDT) In-Reply-To: <83y5nvswfs.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 10 Jun 2012 06:00:23 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:60839 Archived-At: >> One potential source of slowness is the use of `pcase' in macroexp.el: >> when byte-compiled, this is not a problem since it's all macroexpanded >> away into reasonably efficient code. But when interpreted, the `pcase' >> macro might get re-expanded over and over, and it's a macro that's >> costly to expand (because it has to work fairly hard in order to get >> this reasonably efficient code). pcase.el uses a hash-table to memoize >> the recent expansions, but if for some reason this memoization fails and >> the pcase macro gets re-expanded all the time, then an 8-fold slowdown >> would not surprise me. > Is there any way I can help you look into this? I suspect that the slowdown is linked to the stack increase, so if you could show me the (Lisp) backtrace when it hits the 1500 mark, for example, or better yet if we could compare the backtrace when it hits 1000 in the old code and in the new code. Another would be to add some instrumentation code to the `pcase' macro, to output a message everytime the cache misses. E.g. use the patch below. Stefan === modified file 'lisp/emacs-lisp/pcase.el' --- lisp/emacs-lisp/pcase.el 2012-06-09 03:14:44 +0000 +++ lisp/emacs-lisp/pcase.el 2012-06-10 14:47:34 +0000 @@ -215,8 +215,8 @@ (and (symbolp upat) (not (memq upat pcase--dontcare-upats)))) (defun pcase--expand (exp cases) - ;; (message "pid=%S (pcase--expand %S ...hash=%S)" - ;; (emacs-pid) exp (sxhash cases)) + (message "pid=%S (pcase--expand %S ...hash=%S)" + (emacs-pid) exp (sxhash cases)) (let* ((defs (if (symbolp exp) '() (let ((sym (make-symbol "x"))) (prog1 `((,sym ,exp)) (setq exp sym)))))