From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Hi-Angel Newsgroups: gmane.emacs.help Subject: Re: Lexical binding doesn't seem to be faster? Date: Sun, 10 Mar 2019 19:14:57 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="248926"; mail-complaints-to="usenet@blaine.gmane.org" Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 10 17:16:41 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h317w-0012dZ-Or for geh-help-gnu-emacs@m.gmane.org; Sun, 10 Mar 2019 17:16:40 +0100 Original-Received: from localhost ([127.0.0.1]:46849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h317v-0002dP-Nr for geh-help-gnu-emacs@m.gmane.org; Sun, 10 Mar 2019 12:16:39 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h317a-0002cx-SI for help-gnu-emacs@gnu.org; Sun, 10 Mar 2019 12:16:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h316U-0006TE-5g for help-gnu-emacs@gnu.org; Sun, 10 Mar 2019 12:15:11 -0400 Original-Received: from mail-io1-xd43.google.com ([2607:f8b0:4864:20::d43]:34642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h316T-0006Sy-U1 for help-gnu-emacs@gnu.org; Sun, 10 Mar 2019 12:15:10 -0400 Original-Received: by mail-io1-xd43.google.com with SMTP id n11so851298ioh.1 for ; Sun, 10 Mar 2019 09:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0FLnt4BrsNNan3DKDAugqdRfbzSEyD6Twtb/bgdlaTo=; b=YlHYL+soDjJmJoQHJ5bI+cnJVDUDAf3Sz7xesaLTAoHpKJ5s7oYlvH9sLMdDtVAuiW /Kmy/lI45FcRghQgVm+WKexj04AihrM8CGtrvxrZb1MJ0Z8F5fYwpcjVhTqMYXZf6lpg mKkzt3R4SPoWZoYKuqszZYo9kGT0hKw9cK6VlvqX5Yiqme8teIO8xjm9ngrBZPvZDlvT Eb49ymfGOih3TXl91XmkuV0IBjM9klvNk3r96GksfyhkPTAnvYyU6jHdSyPIRhqfxE9U yA2iBX7tBpRNT0v5qBMTJhDoA4boej8/njZSuUap8DyZkUn6RAUTdIb6f7Bo1ntsXTk8 VwDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0FLnt4BrsNNan3DKDAugqdRfbzSEyD6Twtb/bgdlaTo=; b=ScFDY+HEo7v23go9hNM7ve3j1kV7ONxH/4v6TdfDDhigyUQ74YsccssWc5v8KBaJm4 DNNt6MsdEAEJdHviz66p6VX78Cyu5aq8LepXIMfiI1Q3IGang6UAoavYCTb5VCz6wf8k sh+Jj4dOKSrXHKnuLOUMLHseOxREIyM4elk3Tzsv8YCl0tDAaPG/Wzv8I9TEHabfUaJU Wxg/cWKxXF1dxYDS8TSWHmgM+63bnkPxg8s9LtxsGgOM10ZiS1vSA21j+Dn+4hpOgSX5 fJ90I/2NTrYd0ZC8xbCz5kmaVQDB2qKGbxInwEbns+C+KkgE7Yfk++OR4GhzQXmqiKCM zECw== X-Gm-Message-State: APjAAAVfe5tWD5JkIozE1h+Ewod57Imax2eaHQqAqCWrWljEL2cl310/ 10qySX94iHQUt6gAVhpxeU3sCwq2oJC2rlyX9PE= X-Google-Smtp-Source: APXvYqyr1Vr3wz1nDOQs//pCE3+99foxthi/ih1/Di9zY4iShJRFDiAAk+iOGT03zQ58UHdCBqNLZ4wRG76MOunTD+s= X-Received: by 2002:a6b:fb02:: with SMTP id h2mr15257637iog.239.1552234509045; Sun, 10 Mar 2019 09:15:09 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::d43 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:119599 Archived-At: On Sun, 10 Mar 2019 at 18:16, Hi-Angel wrote: > > On Sat, 9 Mar 2019 at 18:06, Stefan Monnier wrote: > > > FTR: I re-benchmarked as `(benchmark-run-compiled 10 > > > (c-font-lock-fontify-region 0 (point-max)))`, and also with `emacs -Q` > > > to make sure that none of addons can interfere (I'm using > > > color-identifiers which may add an overhead to fontification). For the > > > same reason I disabled GC (locally I too have it only enabled to run > > > at "idle time"). > > > > Good (except for disabling GC, which makes the measurement different > > from "real life"). > > > > > It's interesting that the difference almost disappeared: > > > > > > nil: (7.463936164 0 0.0) (7.520960622 0 0.0) (7.526411695999999 0 > > > 0.0) (7.537842362999999 0 0.0) > > > t: (7.617106151000001 0 0.0) (7.635044875 0 0.0) > > > (7.6383228789999995 0 0.0) (7.598431915 0 0.0) > > > > > > "nil" still seems to be faster, but it may as well be a statistical variation. > > > > It looks minor but it seems stable enough to be more than just > > statistical variation. > > > > > Either way, I'm happy, as you suggested, to look at per-function > > > overhead to see if there's any difference. Do you think it's still > > > worth it? > > > > Hard to tell. > > > > > And how do I do it though? Shall I do (profiler-start), and > > > then evaluate the benchmark? > > > > Do (profiler-start 'cpu) before running the benchmark and > > (profiler-report) afterwards. And then C-u RET on the top line to expand > > it (recursively). > > Thanks, so, I did that, and without disabling GC results look quite odd. > > For "lexical-binding: t" it is: > > - ... 2 100% > - list 1 50% > - - 1 50% > - let 1 50% > - let 1 50% > - while 1 50% > - funcall 1 50% > - # 1 50% > - c-font-lock-fontify-region 1 50% > - c-before-context-fl-expand-region 1 50% > - mapc 1 50% > - # 1 50% > - c-context-expand-fl-region 1 50% > - c-fl-decl-end 1 50% > - c-literal-start 1 50% > - c-state-semi-pp-to-literal 1 50% > c-parse-ps-state-below 1 50% > Automatic GC 1 50% > > Whereas for "lexical-binding: nil" it's just: > > - ... 1 100% > Automatic GC 1 100% > ----- > > With GC disabled it looks more interesting: > > "lexical-binding: t": > > - ... 1 100% > - list 1 100% > - - 1 100% > - let 1 100% > - let 1 100% > - while 1 100% > - funcall 1 100% > - # 1 100% > - c-font-lock-fontify-region 1 100% > - c-before-context-fl-expand-region 1 100% > - mapc 1 100% > - # 1 100% > - c-context-expand-fl-region 1 100% > - c-fl-decl-end 1 100% > - c-literal-start 1 100% > - c-state-semi-pp-to-literal 1 100% > c-parse-ps-state-below 1 100% > Automatic GC 0 0% > > "lexical-binding: nil": > - ... 1 100% > - funcall-interactively 1 100% > - eval-expression 1 100% > - eval 1 100% > - mytest 1 100% > - let 1 100% > - list 1 100% > - - 1 100% > - let 1 100% > - let 1 100% > - while 1 100% > - funcall 1 100% > - # 1 100% > - c-font-lock-fontify-region 1 100% > - font-lock-default-fontify-region 1 100% > - font-lock-unfontify-region 1 100% > font-lock-default-unfontify-region 1 100% > Automatic GC 0 0% I found that a lot of code resides in `cc-engine.el`, so here's some more statistics, tested with emacs -Q, and "nil" or "t" accord to lexical-binding disabled/enabled in both cc-mode and cc-engine simultaneously. With GC: nil: (9.099007151 87 1.6701303489999995) (9.057014855 85 1.6550994100000007) t: (9.17824316 95 1.792632212) (9.139527843 94 1.8019125349999991) No GC: nil: (7.519520527999999 0 0.0) (7.576073185 0 0.0) t: (7.522527273 0 0.0) (7.514555517 0 0.0