From: Hi-Angel <hiangel999@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Lexical binding doesn't seem to be faster?
Date: Sun, 10 Mar 2019 19:14:57 +0300 [thread overview]
Message-ID: <CAHGDjgAoVSpqNepKMrTqoLewWgT6fEfU70gcWg3WzkmRG4gLgg@mail.gmail.com> (raw)
In-Reply-To: <CAHGDjgDDBQMrZgxpvGfURHos=0tYqKOoKR5xzGhJ=3JmUVUj7g@mail.gmail.com>
On Sun, 10 Mar 2019 at 18:16, Hi-Angel <hiangel999@gmail.com> wrote:
>
> On Sat, 9 Mar 2019 at 18:06, Stefan Monnier <monnier@iro.umontreal.ca> 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%
> - #<compiled 0x15833de3b0c9> 1 50%
> - c-font-lock-fontify-region 1 50%
> - c-before-context-fl-expand-region 1 50%
> - mapc 1 50%
> - #<compiled 0x15833db80701> 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%
> - #<compiled 0x1585968733a1> 1 100%
> - c-font-lock-fontify-region 1 100%
> - c-before-context-fl-expand-region 1 100%
> - mapc 1 100%
> - #<compiled 0x158596934cbd> 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%
> - #<compiled 0x1580e938690d> 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
next prev parent reply other threads:[~2019-03-10 16:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 23:36 Lexical binding doesn't seem to be faster? Hi-Angel
2019-03-08 5:39 ` Stefan Monnier
2019-03-08 8:30 ` tomas
2019-03-08 13:53 ` Stefan Monnier
2019-03-09 8:21 ` tomas
2019-03-08 13:33 ` Hi-Angel
2019-03-09 15:06 ` Stefan Monnier
2019-03-10 15:16 ` Hi-Angel
2019-03-10 16:14 ` Hi-Angel [this message]
2019-03-10 18:07 ` Stefan Monnier
2019-03-10 18:47 ` Hi-Angel
2019-03-10 18:59 ` Stefan Monnier
2019-03-10 19:53 ` Hi-Angel
2019-03-10 20:48 ` Stefan Monnier
2019-03-10 21:22 ` Hi-Angel
2019-03-11 19:16 ` Hi-Angel
2019-03-11 19:26 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAHGDjgAoVSpqNepKMrTqoLewWgT6fEfU70gcWg3WzkmRG4gLgg@mail.gmail.com \
--to=hiangel999@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.