help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lexical binding doesn't seem to be faster?


From: Hi-Angel
Subject: Re: Lexical binding doesn't seem to be faster?
Date: Sun, 10 Mar 2019 19:14:57 +0300

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]