unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Lexical binding doesn't seem to be faster?
@ 2019-03-06 23:36 Hi-Angel
  2019-03-08  5:39 ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Hi-Angel @ 2019-03-06 23:36 UTC (permalink / raw)
  To: help-gnu-emacs

I've stumbled upon a discussion about converting Emacs code to a
faster lexical-binding and that help needed. I noted that cc-mode.el
I'm regularly use doesn't have one, and figured I could help.

So I inserted to cc-mode.el in emacs-git revision I have:

    ;;; -*- lexical-binding: t -*-

The first bad sign happened to be sizes of cc-mode.elc:

    ;;; -*- lexical-binding: t -*-   | 217581
    ;;; -*- lexical-binding: nil -*- | 212542

Lexical-binding bloats byte-code by 5KB. Odd. I tried comparing
assembly, but without experience in reading lisp assembly I haven't
come up with anything. So I thought "Okay, must be heavy inlining;
let's just compare the speed".

So, I took someone's function `with-timer` for benchmarking¹; and then
for both t and nil lexical-binding I did following steps:

1. `byte-compile` `cc-mode.el`
2. `load-file`    `cc-mode.elc`
3. open a 5k lines C file²
4. Execute multiple times `(with-timer (c-font-lock-fontify-region 0
(point-max)))`
5. Kill the buffer.

These are results I got:

    ;;; -*- lexical-binding: t -*-   | 1.174s, 1.144s, 1.177s, 1.125s, 1.177s
    ;;; -*- lexical-binding: nil -*- | 1.037s, 1.061s, 1.037s, 1.037s, 0.991s


1: https://emacs.stackexchange.com/a/541/2671#how-do-i-measure-performance-of-elisp-code
2: https://gitlab.freedesktop.org/libinput/libinput/blob/9a2d6f55b1276da11dd9b2c4c8e22a405576dfea/src/libinput.h



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-03-11 19:26 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).